Hi everyone,
I’m trying to create a scenario in which the player can jump over a gap in the floor.
This is how I did that and it seems to work:
Understand the command "jump" as something new.
Jumping over is an action applying to one visible thing.
Understand "jump over [something]" and "jump across [something]" and "jump [something]" and "jump" as jumping over;
Report jumping over:
say "Complete waste of time.";
Before jumping over something:
if the player carries the noun:
say "How do you plan to do that?";
stop the action;
if the noun is the player:
say "Don't be silly.";
stop the action;
Then I was able to create the gap in the floor, add some “if the noun is the gap” code and now “Jump over gap” and “Jump across gap” and “Jump gap” all work well.
The problem is that (since the gap lies to the west of the player in the room description) it makes sense that the player should be allowed to jump a direction (west in this case) instead of jumping over the gap and have the same event happen as a result.
Since “jump gap” does what I want, I’m trying to use the same action to get “jump west” to do the same thing, but I can’t figure out how to word the “if the noun is…” code to make it happen.
No matter what I do, Inform ignores it and reports “Complete waste of time.” when the noun the player is jumping over is a direction.
Any thoughts?
1 Like
You’ve made your action apply to one visible thing. A direction is not a thing, but rather a kind of object. (You also don’t need visible in this case, but we can leave that aside for now.) This isn’t exactly how I’d construct my check rules for “jumping over” and it doesn’t actually do anything, but it should give you an idea:
4 Likes
Thank you! I’ll try that out and report back.
I figured the “visible thing” was the problem, but I couldn’t find a different way to word it. I didn’t know “object” was a possibility. I chose “one visible thing” because of how the Inform documentation describes the action “go”:
Going something (past tense gone): applying to one visible thing
That made me think that jumping a direction should apply to one visible thing as well.
2 Likes
‘applying to one visible thing’ isn’t the problem- you’ll find if you use that instead of ‘applying to one object’ the result is the same.
This is an undocumented hidden feature of Inform: ‘object’ in an action declaration is equivalent to ‘visible thing’ (which despite the confusing and unfortunate choice of terminology actually means ‘any object anywhere or nowhere, whether it can be seen or not’); while it is documented that plain ‘thing’ in an action declaration is equivalent to ‘touchable thing’ (although again, that actually means an object that can be touched by the actor*).
The latter wouldn’t work here, because by a special rule the parser rejects commands referring to directions in an action requiring a touchable thing with the admonition ‘you must name something more substantial’.
* a further quirk is that only untouchable things and directions are excluded: rooms and regions are allowed, even though they are untouchable.
EDIT: as proof of this, the code above posted by @BadParser works just fine with ‘visible thing’ substituted for ‘object’ and with the ‘Understand…’ phrases referring to [a direction] removed. [something] already refers to an object in scope, not necessarily a thing, so works for directions (by a special rule, directions are always in scope), whereas [thing], which is restricted to a thing in scope, would not.
3 Likes
That worked! Thank you so much, I really appreciate it.
So, I’m a bit confused. What was the problem with my code? Applying BP’s suggestions to my code solved the problem I was having. Specifically, I switched “visible thing” to “object” and added the “[a direction]” parts to the Understand phrase.
I also added a “Before jumping over a direction…” section which was separate from my “Before jumping over something…” section. Is that what fixed my problem?
@drpeterbatesuk is right, of course. The code I have works for “visible thing” (instead of “object”) and the additional understand lines for “direction” are indeed superfluous. 
As far as your initial issue, without seeing your full code, it’s hard to tell why you were getting unexpected behavior, but it was almost certainly the ordering of your rules.
The best way to debug these is to turn rules tracing on by typing “rules” at the game prompt when running the game in the IDE. This will then show the name of each rule as it is being run while processing a command. (Not all of them, but as far as tracing what’s going on in an action, it’s a great place to start.) Note that this is usually only helpful if you’ve named all your rules. It is considered best practice anyway and I always do it in my own projects, but for brevity, often don’t bother when posting code snippets here. I also don’t usually put conditions in the header of rules like I did here because that affects code ordering in ways that are sometimes not obvious. (I think I may be in the minority as far as that is concerned.) For example:
Probably. Using “a direction” in the header of your rule makes it more specific than “Before jumping over something” so the former rule would be placed – and therefore fire – before the latter regardless of where it occurs in your code.
1 Like
It’s actually more than that. Adding to the pot of Inform’s confusing terminology, ‘something’ in a rule preamble, such as ‘Before jumping over something…’ is restricted to things so won’t apply to a direction. Consequently any subsequent ‘if the noun is a direction’ will never be reached. You can just leave out the ‘something’, so that the rule applies to any jumping over action:
Before jumping over:
if the noun is a direction, say "Wheeee!".
or use ‘an object’ instead:
Before jumping over an object:
if the noun is a direction, say "Wheeee!".
or specify ‘a direction’ in the rule preamble:
Before jumping over a direction: say "Wheeee!".
Rule ordering may differ with these otherwise equivalent possibilities, as @BadParser has suggested: ‘jumping over a direction’ in a rule preamble is more specific than ‘jumping over an object’, which is more specific than just plain ‘jumping over’, meaning rules whose preambles are otherwise identical will be addressed in this order.
EDIT (it makes no sense to discuss whether ‘a direction’ or ‘something’ has higher priority, as in rule preambles the two terms are actually mutually exclusive)
2 Likes
To summarise, since it is so confusing:
In action declarations such as ‘Jumping over is an action applying…’
‘object’ means object *
‘something’ is not allowed
‘thing’ means object **
* equivalent to ‘visible thing’, can’t be specified as touchable or carried
** by default ‘touchable’ but can be specified as ‘visible’, ‘carried’ or ‘touchable’
In grammar tokens such as ‘understand “jump over [something] as …”’
[object] is not allowed (although strangely, [objects] is)
[something] means an object in scope
[thing] means a thing in scope
In rule preambles such as ‘Before jumping over…’ or in other conditions such as ‘if the player is in something…’
‘object’ means object
‘something’ means thing
‘thing’ means thing
6 Likes
@BadParser and @drpeterbatesuk
Thank you again for all your help, to both of you. Not just for helping me with my code, but for helping explain how the innards of Inform work. It’s often hard to find that kind of information in the documentation because I’m not sure how to phrase what I’m searching for!
Thanks again!
2 Likes