A few questions concerning custom actions

Hello, newbie here. I was just re-introduced to IF through one of my college classes in which the latest assignment was to play through Bronze by Emily Short. I liked it so much I wanted to make my own and eventually found Inform 7. I’ve been mucking about with it, testing a few things and trying to decide what kind of game I wanted to design. I decided to make a game about something else that I liked…Transformers (Specifically about the Transformers Animated Dinobots). Yes, I’m an odd one, but I figure that if it’s something that I like then I more than likely won’t get bored whilst trying to make it work. And that in trying something like this I’ll be able to get used to using Inform 7 in the process.

Okay, on to the main point - custom actions.

There are twon main ones that are supposed to have a link to the plot : Headbutting and Transforming.

For Headbutting, I already have a really basic one -

Headbutting is an action applying to one visible thing. Understand "headbutt [something]" as headbutting. Report headbutting something: say "You headbutt the [noun] and are left with a bit of an ache in your helm." After headbutting Oak Tree for first time: say "Your helm collides with the trunk, causing a hollow thud. A few leaves float down from the tree." After headbutting Oak Tree for second time: say "Your helm collides with the trunk, causing a hollow thud. An acorn falls out of the tree." After headbutting Oak Tree for third time: say "Your helm collides with the trunk, causing a sharp crack. The trunk appears to have splintered slightly." After headbutting Oak Tree for fourth time: say "Your helm collides with the trunk, causing a sharp crack. With a creaking groan, the tree topples over." After headbutting Grimlock: say "Grimlock growls angrily at you and stomps away."

Edited slightly. It now says the messages I want to appear when headbutting the tree.

However, there are a few things that I want to happen when headbutting the Oak Tree.
Such as -
On the first time I want a few leaves to be dislodged.
On the second time I want an acorn to fall out of the tree.
On the third time I want the trunk to splinter.
On the fourth time I want the tree to fall over and turn into a different object called ‘Fallen Trunk’

I have items for the leaves and the acorn premade.

I’d also want Grimlock to stomp angrily away if he’s headbutted…but I haven’t got to anything regarding NPC movement yet so that can wait.

The other action, Transforming…would be a transition between two states : Bot Mode or Alt Mode.
I want it so that some actions are restricted depending upon which state you are in at the time.
I’d also like it if I could have the description of an NPC and yourself change depending on the state.
I’m pretty sure that this would have something to do with values…but I’m not too certain on how to go about it.

Any help would be greatly appreciated. Thankyou.

  • Arad

Rather than use After rules, my tendency would be to use Instead rules. Note that the leaves, acorn, and fallen tree are initially nowhere: the Instead rules bring them into the location. Note also that I moved the bracket in your Report headbutting rule – this is the more usual way to do it, for technical reasons.

Hope this helps!

–JA

[code]Forest Path is a room. “A massive oak stands here.”

The oak tree is scenery in Forest Path. The oak tree can be cracked or not cracked. The description is “The massive oak tree is [if cracked]split down the middle[otherwise]impressive indeed[end if].”

Grimlock is a man in Forest Path.

Headbutting is an action applying to one visible thing. Understand “headbutt [something]” and “butt [something]” as headbutting. Report headbutting: say “You headbutt [the noun] and are left with a bit of an ache in your helm.”

Instead of headbutting Oak Tree for first time:
now the green leaves are in Forest Path;
say “Your helm collides with the trunk, causing a hollow thud. A few leaves float down from the tree.”

Instead of headbutting Oak Tree for second time:
now the acorn is in Forest Path;
say “Your helm collides with the trunk, causing a hollow thud. An acorn falls out of the tree.”

Instead of headbutting Oak Tree for third time:
now the oak tree is cracked;
say “Your helm collides with the trunk, causing a sharp crack. The trunk appears to have splintered slightly.”

Instead of headbutting Oak Tree for fourth time:
remove the oak tree from play;
now the fallen tree is in Forest Path;
say “Your helm collides with the trunk, causing a sharp crack. With a creaking groan, the tree topples over.”

Instead of headbutting Grimlock:
remove Grimlock from play;
say “Grimlock growls angrily at you and stomps away.”

Some green leaves are a thing. An acorn is a thing.

The fallen tree is scenery. Understand “oak” as the fallen tree. The description is “Once a mighty oak, now it lies fallen.”[/code]

Ooh, okay, that works very well. Thank you very much! :smiley:

Jim: Just curious, wouldn’t “Carry out headbutting Oak Tree” and “Carry out headbutting Grimlock” (with some if statements inside) work as well? When do you decide between the two?

I’m much more of a newbie than others here, so excuse my hubris in addressing this one.

I think you need adjectives (described in 6.5) or either/or properties (4.6).

I don’t know anything about transformers, so excuse my examples. Luckily there’s Wikipedia :smiley:

[code]The lab is a room.

A transformer is a kind of thing. Wheeljack and Bumblebee are transformers in the lab.

There is an oak tree in the lab.

A transformer can be Bot Mode or Alt Mode.

Wheeljack is Alt Mode. Bumblebee is Bot Mode.

The description of Wheeljack is “Wheeljack is the resident inventor and gadgeteer. Right now Wheeljack is in [if wheeljack is bot mode]bot mode.[otherwise]alt mode.[end if]”

The description of Bumblebee is “Bumblebee is small in size and often volunteers for missions where his small size is an asset. Right now Bumblebee is in [if bumblebee is bot mode]bot mode.[otherwise]alt mode.[end if]”

test me with “examine Wheeljack / examine Bumblebee”

[/code]

You could also use if statements anywhere else you normally use them with those states (If Wheeljack is Bot Mode… do this)

Incidentally when I had “Wheeljack is in Alt Mode”, Inform got confused, thinking I was giving a location. So I dropped the “in”.

Yes, that would also work. My general rule of thumb (and it’s largely a matter of coding style, I suppose) is that when I create new actions, I use the Check/Carry Out/Report cycle only for the general process of the action, and Instead rules to handle what happens when the action is applied to some specific thing that needs special handling.

Quite often, that means I only write a Check rule for the new action, since I never want the player to be able to use that action on sundry items:

[code]Check whistling at: say “You tootle a few notes, and are ignored.” instead.

Instead of whistling at Irene: say “Irene slaps your face. ‘How dare you?’”[/code]–JA

Thankyou ShaeSays. That works wonderfully for the transforming of the NPCs.

Though now I’m having another problem with something else.

[code]
Sweeping is an action applying to one visible thing. Understand “sweep [something]” as sweeping.

Clawing is an action applying to one visible thing. Understand “claw [something]” as clawing.

Mud is a thing. Mud can be clawed or not clawed. The description is “Some wonderful squishy mud. It has [if clawed]claw marks in it[otherwise] the perfect consistancy for digging[end if].”

Instead of sweeping some mud:
If mud is clawed:
say “You sweep your tail over the mud, smoothing out the claw marks.”;
now mud is not clawed;
otherwise:
say “You sweep your tail over the mud, spreading it around a little.”

Instead of clawing some mud:
now mud is clawed;
say “You dig at the mud a little, leaving behind some claw marks.”[/code]

The clawing action works just fine, but the sweeping one doesn’t. However there’s no errors being reported concerning it. It’ll play the game but when you type in ‘sweep mud’ it just says ‘You achieve nothing by doing this.’

EDIT : Changed it to clawed or not clawed. Still doesn’t work.

The problem with sweep is that it is already defined by the Inform library; it is a synonym for rub. (The easiest way to see when you’ve run up against an already defined command is to comment out everything you’ve written relating to the command, compile the game, and then do a search in the Actions part of the Index tab for the verb.) To get this going, you just need to amend the action definition like so:

Understand the command "sweep" as something new. Sweeping is an action applying to one visible thing. Understand "sweep [something]" as sweeping.

–Erik

Oh! Thankyou!!