“in the location” that’s the magic phrase. Thank you.
You’re welcome, but there is a slight bug with that. If you try going a direction and can’t, it still ends up dropping the barrel. I’m not good enough with Inform 7 yet to figure out the workaround, so maybe someone can help expound on that.
Fixed it! Try this instead:
Before going from a room to a room: If the barrel is carried by the player: say "It's too heavy to walk with the barrel."; now the barrel is in the location.
Here’s how I’d write it, but the effect is basically the same.
Before going somewhere while the player is carrying the barrel: say "(The barrel is too heavy, so you set it down.)"; silently try dropping the barrel; if the barrel is carried, stop the action.
Yeah for my meager attempt, “somewhere” can also work in place of “from a room to a room”. I don’t know all this yet lol. Probably takes care of other instances too, like getting into or out of an enterable container and such.
Daniel I may be wrong, but I think your first line will throw an error and might need to be “Before going somewhere when the player is carrying the barrel”? I don’t wanna presume over people who know this much better than I do; I do try testing them out a bit, but can’t account for my own newbie-ness.
Oh, yep, you’re right on that bit, I’ll fix it.
Generally, it’s a good idea to be cautious about using unilateral commands like “now” because they bypass the logic of the model world. When freshly written, you know exactly what you’re doing and why, but some months later, you might have forgotten about the “exception” you coded, and bugs can creep in. Take the little example below: both the beer keg and the flypaper are intended to be difficult to get rid of, but there’s a problem…
"flypaper" by "Testa" The player is wearing the super magnetic suit. Check taking off the super magnetic suit: say "What, and lose your super magnetism? Perish the thought!" instead. The hall of nuisance is a room. "Nothing much to see here, apart from the exit to the south." The beer keg is in the hall of nuisance. "A standard metal beer keg lies here, abandoned." The sticky flypaper is in the hall of nuisance. The description of the sticky flypaper is "It's **really** sticky." Check dropping the sticky flypaper: say "Despite your best efforts to be rid of it, the flypaper sticks to your hand." instead. Report taking the beer keg: say "Clang! Attracted by your magnetic suit, the keg jumps up off the floor into your arms!"; stop the action. Check dropping the beer keg: say "Despite your efforts, the keg remains stubbornly magnetized to your suit." instead. Before going south from the hall of nuisance: now the beer keg is in the location; if the player carries the sticky flypaper: try dropping the sticky flypaper; The hall of relief is south of the hall of nuisance. "A bland room with an archway to the north." Test me with "take all / drop keg / drop flypaper / i / s / i".
So although it’s by no means mandatory, it’s safer to code the result you want to get in terms of the PC attempting an in-game action. If the game contained other characters, then
`try the current actor trying dropping the keg`
will cover all the bases.
That’s a great example.
I’ve read about the hierarchy of strength of words (check, report, …) but seeing them all altogether in a concrete example is really instructive. I wonder, if you still have a moment to spare, you’d break down the reasons why you’ve selected each one as it relates to the action.
The three stages of an action itself are Check, Carry Out, and Report. But you can, if you wish, also intervene Before, Instead, and After.
Before rules intervene before any other rules at all have been considered. So you could use a Before rule, and it would work even in darkness, for example.
Instead rules are general purpose rules: they’re run before check rules, so they can be particularly handy for intervening when you want to affect several rules.
Instead of examining, searching, or looking under the bed:
say “'Aha! There’s my hockey stick!”
now the hockey stick is in the location;
But this usefulness comes at a price: all Instead rules are put into a single rulebook (called, not surprisingly, “the Instead rulebook”), so if you use Instead rules a lot, you can end up with the game slowing down because it has to churn its way through the Instead rulebook for every single action.
If you use a Check rule though, the game only has to check the rules for that particular action, in this case the “Check taking” rulebook. In a larger game this can amount to a significant efficiency saving. It’s perfectly okay to include logic in a check rule, but if you want the check to actually prevent the action from occurring, you have to end the rule with either the phrase “stop the action;” or the keyword “instead;”
So an alternative to the hockey stick “instead rule” above might be–
Check searching the bed: try looking under the bed instead; Check examining the bed: try looking under the bed instead; Carry out looking under the bed: if the hockey stick is nowhere: now the hockey stick is in the location; Report looking under the bed: say "'There's my old hockey stick!' you exclaim."; stop the action;
Obviously that’s more typing (not to mention the possibility of then accidentally diverting looking under and ending up with a loop!) but hey, you pays your money and you takes your choice.
Carry out rules shouldn’t print any text - this is so that they can be tried “silently” by the library.
Report rules are intended to amplify the standard library message. So –
Report taking the hockey stick:
say “‘Yippee!’ you say, groping eagerly under the bed.”;
Will result in
take hockey stick
“Yippee!” you say, groping eagerly under the bed.
That’s why the Report looking under the bed rule had “stop the action;” as its second statement. Without it, you’d get:
“There’s my old hockey stick!” you exclaim.
You find nothing of interest.
After rules come after the action has happened, but they supersede the default library message, so –
After taking the hockey stick:
say “‘Yippee!’ you say, groping eagerly under the bed.”;
Will print only that message, there’s no need to suppress the standard library message.
I know that having both “After” and “Report” rulebooks seems redundant, but it comes in handy when you’re animating NPCs and want them to react to what the player’s just done. (of course if you want them to interfere before, you’d use a Check rule.)
"The bedsit" by "Testa" The grubby bedsit is a room. "Nothing much to see here, apart from the usual detritus of life." A lumpy bed is in the grubby bedsit. "A lumpy bed is pushed up against one wall." Your old hockey stick is nowhere. "The handle of your old hockey stick protrudes from under the bed." [ "is nowhere" is optional, simply leaving the initial location unstated would also work, but it tells me, later, that I intended it to begin the game off-stage, and didn't simply forget.] After taking your old hockey stick: if the player can see harriet: say "Harriet gives the hockey stick a disdainful glance."; continue the action; [instead rules can be handy for grouping rules together, to ensure the same code is run despite the player trying a variety of approaches.] Instead of searching or looking under the lumpy bed: say "'Ah! There it is!' you cry. 'My old hockey stick!'"; now your old hockey stick is in the grubby bedsit; Harriet is a woman in the grubby bedsit. "Harriet leans against the wall, looking bored." An umbrella is in the grubby bedsit. Instead of opening the umbrella when the player can see harriet, say "Harriet glares at you. 'Don't you shake that wet thing over me!' she exclaims." Check opening the umbrella: say "You flap the umbrella repeatedly open and shut to rid it of the last of the rain." instead. [instead rule intervenes before this rule is reached.][n.b. note that you'd have to make the umbrella "openable" if you wanted to actually carry out the action. ] Report taking the umbrella: say "You pick up the umbrella and shake the rain off it."; stop the action; After taking the umbrella: if the player can see harriet: say "Harriet raises her eyebrows. 'Can't think what you want that wet old thing for,' she says."; continue the action; The hallway is south of the grubby bedsit. "A narrow hallway with a threadbare carpet." Test me with "take umbrella / open it / s / open it".
This post is a great summary of the action sequence in I7 and is a good read to help authors evolve from the stage where they tend to simplify everything by only using INSTEAD rules. The INSTEAD rulebook doesn’t bother checking any other rules and therefore should be used with an understanding of how it works - ideally in most situations redirecting actions to other actions that are then parsed normally instead of altering the world-state directly, or just giving a blanket denial to an action:
Instead of taking the Crown Jewels when the Guard is in the location: try the Guard arresting the player.
Instead of jumping when the location is Edge of Cliff: say "Clearly that's a bad idea."
Instead of attacking the cherry tree: try chopping the cherry tree.
For this, if there is a specialized action for CHOP [SOMETHING], you’d want to have a rules like:
A thing can be choppable. A cherry tree is in Washington Square. It is fixed in place. Cherry tree is choppable. Check chopping something (this is the axe is required to chop rule): if the player does not carry the sturdy axe: say "What, with your bare hands?" instead. Check chopping something (this is the can't chop up everything randomly rule): if the noun is not choppable: say "Chopping up [the noun] would not be productive." instead. [since we know CARRY OUT won't happen unless all the CHECK rules pass:] [note you can create rules for specific nouns] Carry out chopping the cherry tree: now your father is angry; Carry out chopping something: now the noun is off-stage; Report chopping the cherry tree: say "Okay, your father isn't going to like this. TIMBER!" Report chopping: say "You chop up [the noun] with thorough, maniacal glee."
Instead of chopping the cherry tree: if the cherry tree is off-stage: say "What tree?"; otherwise: if the player carries the sturdy axe: say "Okay, you cannot tell a lie."; now the cherry tree is off-stage; now your father is angry; otherwise: say "What, with your bare hands?";
Psuedo-parsing with INSTEAD may not cause an issue with a simple game, but as the world increases in complexity problems can crop up:
If you write something like
Instead of examining the Dusty Tome: say "You pore through the crumbling pages and learn a spell called FROTZ."; now knows_frotz is true.
That might be a poor example since it’s easier to write a description - but the rule works for what the author wants. However, putting it in the INSTEAD rulebook means that rule will skip normal parsing and disregard every other rulebook and the effect will happen every time the player examines the dusty tome no matter what the world-state is. They can read the book and learn the spell even if they already know the spell, if the tome is in-scope but held by an NPC, in a locked transparent container, or perhaps hidden on a high shelf based on other rules.
The author could account for all of this with a very complicated INSTEAD rule -
Instead of examining the dusty tome when not carried by someone who is not the player and the dusty tome is not enclosed by the hidden bookcase and the dusty tome is not enclosed by the magical glass trunk and knows_frotz is false... - but that’s doing the work the parser and the rule sequence is intended for. It may seem more complicated to split these all into sequenced rules, but you’ll have a much easier time troubleshooting your game later, especially if you name your rules.
Check chopping (this is the you are not Jack Torrance rule): if the noun is not choppable: say "Cool your jets, maniac." instead.
When you have RULES on, it will specify “Failed the you are not Jack Torrance rule’” which is helpful rather than “Failed the Instead of chopping the tree rule”. (which will always fail, since the default outcome of INSTEAD rules is failure no matter whether the rule did what was intended.)
Thank you both for taking the time to explain that.
I’ve got an okay handle on that information and have bookmarked it for future reference as well.
I was particularly interested in the creating choppable. When I went to run it though I got this error:
Problem. You wrote 'Check chopping something (this is the axe is required to chop rule)' , which seems to introduce a rule taking effect only 'chopping something'. But this does not look like an action, since there is no sign of a participle ending '-ing' (as in 'taking the brick', say) - which makes me think I have badly misunderstood what you intended. See the manual: 7.1 > 7.1. Actions
Which is probably due to something I misunderstood but thought maybe it wasn’t.
Sorry, I wrote that code without actually using Inform. You would have to create a specific chopping action. By default, chop is a synonym for cut. Here’s how you’d do it:
Actual Inform 7 Code
Washington Square is a room. Your father is a man. Your father can be angry. A thing can be choppable. A cherry tree is in Washington Square. It is fixed in place. Cherry tree is choppable. The sturdy axe is in Washington Square. A bronze statue is in Washington Square. It is fixed in place. understand the command "chop" as something new. [This is how you steal a synonym back from an existing action] chopping is an action applying to one thing. Understand "chop [something]" and "chop up [something]" and "chop down [something]" as chopping. Check chopping (this is the axe is required to chop rule): if the player does not carry the sturdy axe: say "What, with your bare hands?" instead. Check chopping: if the noun is not choppable: say "It's probably not a good idea to chop that up." instead. Carry out chopping the cherry tree: now your father is angry; Carry out chopping something: now the noun is off-stage; Instead of cutting a choppable thing: try chopping the noun. Report chopping the cherry tree: say "Okay, your father isn't going to like this. TIMBER!" Report chopping: say "You chop up [the noun] with thorough, maniacal glee."
You can see a cherry tree, a sturdy axe and a bronze statue here.
What, with your bare hands?
What, with your bare hands?
What, with your bare hands?
Cutting it up would achieve little.
chop down tree
Okay, your father isn’t going to like this. TIMBER!
You chop up the cherry tree with thorough, maniacal glee.
chop up statue
It’s probably not a good idea to chop that up.
(I realize I should have put in another choppable object that was not the tree to show that the “timber” message won’t fire since it’s specialized.)
Hey that’s great @HanonO – BTW how do you get those neat little folding arrows in your post?
Thank you again for your generosity.
In the editor, click the gear icon on the right, it’s under “Hide Details”. Or type
[details="Summary"] This text will be hidden [/details]
Thanks – it’s useful to know how to prevent lengthy examples from interrupting the overall flow of a post.
Just curious, @Draconis, in which cases could the barrel still be carried, after the “silently try dropping” line?
If some rule intervenes to stop the dropping, e.g., “instead of dropping”. (It would probably have to be a rule you wrote yourself, not sure if the standard rules would ever block dropping something you’re carrying.)
Yeah, it’s for if another rule intervenes. I try to write all my rules as generally as possible, just in case.
Also, if the player is in a container with limited carrying capacity which is full, the dropping action will be blocked with a “There is no more room in [the holder of the actor].”