Hello everyone, I just discovered Inform yesterday and started learning how to use it. Flotz on the iPhone reintroduced me to IF which I haven’t played since the Zork days. I’m running into trouble trying to overwrite the throwing action to throw an item. Any help would be appreciated, thanks!
Understand the command “throw” as something new.
Throwing is an action applying to one carried thing and one visible thing. Understand “throw [something] at [someone]” as Throwing.
report throwing something at someone: say “You throw the [the second noun] at [the noun]”.
Understand the command "throw" as something new.
Slinging it at is an action applying to one carried thing and one visible thing. Understand "throw [something] at [someone]" as slinging it at.
Report slinging something at someone: say "You throw the [the noun] at [the second noun]."
“Throwing” is already defined in the standard library so we’ll have to call this something else, like “slinging”. Even then “slinging” isn’t enough when there are two nouns, you need the “at” somewhere there, therefore “slinging it at”. “It” refers to the first noun.
Though the easiest way to replace a library action is just
Before throwing something at something:
stop the action.
but if you just want to fine-tune how throwing things work or report itself, neither of these options is the optimal one.
Perhaps it is enough to use Before in this case, but the general solution would be something like
[code]The block throwing at rule is not listed in the check throwing it at rules.
Carry out throwing something at something:
now the noun is in the location.
Report throwing something at the dragon:
say “[The noun] hits the dragon on the nose.”[/code]
Now, if you want to enable throwing a knife at the dragon, killing the dragon in the process, you can add something like this:
Report throwing the knife at the dragon:
say "[The noun] hits the dragon straight in the eye, its blade sliding in all the way. The dragon lets out a menacing growl as it slowly falls down and dies. You retrieve the knife from the corpse.";
now the knife is carried by the player;
remove the dragon from play;
stop the action.
and modify the original report throwing something at the dragon rule to add the same “stop the action” clause to it, just in case.
First, some very quick theory on rules and rulebooks (for further information, I suggest reading chapter 18 in the Inform 7 manual) and how to get at this phrase:
If you compile your game in progress and go to the index tab and click actions and then in the section Actions concerning other people on the magnifying glass after Throwing it at, you’ll see at the bottom a list of rules regarding the action throwing it at.
One of the rules (a check an actor throwing something at rule, to be specific) is called the block throwing at rule, and it is the one responsible for the You lack the nerve when it comes to the crucial moment output and for stopping further processing of the command.
If you look in the Inform 7 documentation (Chapter 18, Section 1 - On Rules), you’ll see a list of rulebooks available. Before, instead, after, check, carry out and report are rulebooks dependent upon a specific action. (In this case, the action is throwing it at.) The rulebook in which the rule we want to disable is (from the above paragraph) the check throwing it at rulebook, as the block throwing at rule is listed in it.
Now we get to the meaning of the phrase above:
The block throwing at rule is not listed in the check throwing it at rules.
This is a procedural rule; basically a rule modifying how other rules work. What we name here is the rule we want (block throwing at) and the rulebook we want (check throwing it at), and say that we don’t want the first mentioned rule running when the rulebook is run through - that the rule is not listed in the specified rulebook.
Sine the rule originally was in that rulebook, we get the effect that it is removed from it, which allows for the action to proceed onward instead of being blocked.
Thanks for the response, I especially liked the index tip
I’m having trouble establishing a simple loop. I copied it exactly from the documentation and still keep getting an error:
repeat with X running from 1 to 10:
if X is 4, next;
say "[X] ";
if X is 7, break;
Problem. You wrote ‘repeat with X running from 1 to 10’ : but the punctuation here ‘:’ makes me think this should be a definition of a phrase and it doesn’t begin as it should, with either ‘To’ (e.g. ‘To flood the riverplain:’), ‘Definition:’, a name for a rule (e.g. ‘This is the devilishly cunning rule:’), ‘At’ plus a time (e.g. ‘At 11:12 PM:’ or ‘At the time when the clock chimes’) or the name of a rulebook followed by some description of the current action (e.g. ‘Instead of taking something:’).
Phrases, such as "repeat… " or "if… then… " are not valid commands in and of themselves. They can only be contained within a command. You have to give inform some context as to when this loop should be performed, for example:
Instead of throwing the knife: