Can someone point me in the right direction? I've added new action,
called "bribing", which seems to work OK. However, as it's a new
action, players might not think to try it. So, if we "give" something
to someone, well, that's what bribing is, basically, right? But I
can't seem to program this in Inform.
The code snippet:
Bribing is an action applying to two things.
Understand "bribe [something] with [something]" as bribing.
instead of giving, try bribing instead;
In the game:
>give silver to barkeep
You must supply a noun.
>bribe barkeep with silver
he snaffles the silver piece, and silently waves you behind the bar.
So, my action works, but equating it with a built in verb doesn't
work. If I try disabling give checks IE "The block giving rule is not
listed in the check giving it to rules.", then giving silver to the
barkeep somewhat hilariously, but not usefully, gives the barkeep to
the silver coin - the barkeep disappears.
Can someone help a bit?
Cheers.
Something like
Instead of giving, try bribing the second noun with the noun instead.
Instead of giving, try bribing (with nouns reversed).
Also, as a general rule, it's a good idea to give actions that take two
nouns a slightly bigger definition:
Bribing it with is an action applying to two things.
...and again, I'm not loading up I7 right now to check, but I think this
might be clearer:
Bribing it with is an action applying to one person and one thing.
Worth trying, anyway.
--JA
Khelwood's right, but for that to work, you need to define your bribing
action with placeholders (as Jim Suggested) so that the above phrase
will be understood correctly by inform:
[code]
Bribing it with is an action applying to two things.
Understand "bribe [something] with [something]" as bribing it with.
Instead of giving, try bribing the second noun with the noun.
[/code]
BTW, the "with nouns reversed" option that Jim mentioned only works with
grammar definitions (i.e. 'Understand "give [someone] [something
preferably held]" as giving it to (with nouns reversed)'.)
Excellent, that works a treat! :-)
Would you be kind enough to explain the use of "it with" in this
context?
Cheers,
Zed
>
> Would you be kind enough to explain the use of "it with" in this
> context?
While not strictly necessary in all cases, it's good practice because it
makes the code easier to read.
In some cases, you may want to define two different actions that use the
same "action word" -- for instance, you might want the player to be able
to use the commands PAINT THE FENCE and also PAINT THE FENCE WITH THE
PAINTBRUSH. As far as Inform is concerned, these are separate actions.
So you would need to create an action (painting) that takes only one
noun, and a separate action (painting it with) that takes two nouns.
--JA
I'll try to without being too confusing. :)
As an author, you are dealing with two parsers in inform -- the in -
game parser that tries to understand what the player types, and the
inform compiler's parser, which tries to understand what you as a
*programmer* are trying to say in the code itself. The second one is
necessarily more strict. For example, just because the standard rules
understands what a player means by "put the ball in the box," you as an
author can't make a rule like "Instead of putting the ball in the
box..." because there is no action called "putting it in"; the action is
called "inserting it into."
When you create a new action, inform assumes that you will use whatever
name you used to create it, and anything else that follows that name
will be the noun. This works fine for actions with one noun, like
"taking." When you have two nouns, you need some way of letting the
compiler know how you plan on wording the action so that it's clear what
the nouns are.
For example, if you create an action called simply "bribing" and then
use a phrase like "try bribing the second noun with the noun," inform's
compiler will interpret that as "carry out the bribing action on some
object called 'the second noun with the noun'" which won't make sense
unless you happen to have an object in the world called that. (Remember,
just because you used the word "with" in the understand line, doesn't
tell inform's *compiler* what to do with that word in the context of the
code.)
When you create an action called "bribing it with," you're adding a
placeholder (the word "it") for the noun and a divider word ("with"),
which will then be followed when necessary by the second noun. Now you
can write rules like "Instead of bribing Sam with the coin..." Note that
although "it" is mandatory, the divider word can be pretty much
anything. Most authors use prepositions, since they read better, but you
could for example, code this:
[code]
Bribing it blah is an action applying to two things.
Understand "bribe [something] with [something]" as bribing it blah.
Instead of giving, try bribing the second noun blah the noun.
[/code]
EDIT: Jim's right that the use of "it" as a placeholder is not strictly
speaking mandatory in the sense that the compiler won't reject your code
if you don't do it. In the case of two - noun actions, however, I think
it should be. Without the use of "it" as a placeholder, it becomes
impossible to create rules and phrases (as illustrated above) to
effectively utilize a new action. IMHO, the fact that you *can* create
two - noun actions without using this syntax is a bug in inform.
HTH,
Skinny Mike
zed