No, my friend, it was my idiocy and lack of knowledge. Your code worked just fine.
No, what I said was that
Understand the command "pick" as "take".
won’t work, due to interference from other grammar lines specified by the Standard Rules.
(EDIT: And that the OP would be better off doing what drpeterbatesuk recommended, i.e. using
Understand "pick [things]... – which was, despite its new timestamp below, posted prior to this comment on the separate thread that has now been merged with this one.)
If I were being fussy (and, let’s face it), I would recommend
Understand "pick [things]" as taking.
Not because the card action specifically needs to accept multiples, but because the standard TAKE / PICK UP grammar is defined this way. If the new grammar behaves exactly the same as the old grammar, that’s one less thing you have to worry about.
Trying to pick a tarot card from a list of three. But for example if the correct card is the two of wands, I can’t pick the two of wands because I get the warning – You can’tt use multiple objects with that word.
picking is an action applying to multiple objects. understand "pick [something]" as taking. instead of taking a tarot card: if the noun is correct card: say "'That's correct!' says the gypsy."; increase songnum by 1; assign the next correct card; otherwise: say "'That's incorrect' says the gypsy. 'Now you must start over.'"; repeat through the Table of Correct Tarot Cards: now usedyet entry is false; repeat through the Table of Distract: now usedyet entry is false; assign the next correct card;
Your action definition here is at fault. Try
picking is an action applying to one thing. understand "pick [something]" as picking.
Actions only ever act on things one-at-a-time. If you want your action to be run for multiple objects in sequence from one command (like ‘Take all’, for example), you specify it in your ‘Understand’ phrase like this, for example:
picking is an action applying to one thing. understand "pick [things]" as picking.
which allows the action to be run multiple times over from one command for things listed or specified in the command that match the action definition and understand phrase.
EDIT although I see that here you also aren’t referencing this ‘Understand’ phrase to your picking action, but to the inbuilt taking action, so it’s not clear exactly what’s going on from the code you’ve posted. ‘picking is an action applying to multiple objects.’ shouldn’t even compile!
You’ve attached the “pick” grammar to taking–you’ll want to do something more like this (as documented here):
Picking is an action applying to one. Understand "pick [things]" as picking.
As far as I can tell, Inform’s default grammar limits us to two things affected by a single command, outside of this grammar.
As drpeterbatesuk notes, the example code that you provided shouldn’t even compile, so your actual code must be different. I’m assuming that you’re using a modified version of what Afterward worked out in the other thread.
It sounds like for your purposes it would be better to use the declaration
Understand the command "pick" as "take".
Understand "pick [something]" as taking.
Doing so means that all of the built-in grammar lines for
the taking action will apply, including the line that allows taking multiple things at once.
EDIT: Oops. That’s what I get for not testing. What I said won’t work because of other built-in grammar lines:
Understand "pick up [things]" or "pick [things] up" as taking.
So really you want to do what drpeterbatesuk says above.
How can I change the name of an object to match a table entry?
I can change the printed name:
now the printed name of dc1 is Tarot card entry;
I can change the description:
now the description of dc1 is Tarot card entry;
but when I do the picking action:
picking is an action applying to one thing. understand "pick [things]" as picking. instead of picking a tarot card: if the noun is tarotcard1: say "'That's correct!' says the gypsy."; increase songnum by 1; assign the next correct card; otherwise: say "'That's incorrect' says the gypsy. 'Now you must start over.'";
I must still use the proper name, for example dc2.
I need to be able to say something like:
understand "[Tarot Card Entry]" as dc2
Knowing how you’ve modified the scenario makes it easier to understand how you could be getting that specific error message: the word “two” in player input must not be matching to a specific card. In the example by Afterward, each card is explicitly named, so that should not be happening if the
Two of Wands card is actually present.
For example, I can get the following:
You can see a Four of Cups, a Four of Pentacles and a Three of Wands here. >PICK TWO OF WANDS You can't use multiple objects with that verb.
if and only if the grammar line provided is
Understand "pick [something]" as taking., and note the varying errors for other commands with the same cards present:
>PICK TWO OF SWORDS You can't use multiple objects with that verb. >TAKE TWO OF WANDS Only one of those is available. >TAKE TWO OF SWORDS You can't see any such thing.
There is more about what’s going on under the hood that may be helpful to make sense of this.
- Declaring an action (
Picking is an action...) creates an action in the world model. That’s all it does. Unless you provide a “grammar line” via
Understand... as picking., the player will never be able to perform that action.
- Declaring the grammar line tells the parser how to match user input to an action in the world model. Where you say
Understand "pick [something]" as taking.you’re linking a command like >PICK TWO OF WANDS to
the taking action, which is already built in. You’re also defining what can follow the specific word >PICK in player input. In this case, the token
[something]means a single object.
- The parser will go through all defined grammar lines to try to find one that matches. It begins the match by looking at the first word. A command beginning with >TAKE can be treated differently than one beginning with >PICK. Once the parser has used the grammar line to determine the action being asked for by the player, it no longer cares what specific words the player typed. All parts of the grammar line (i.e. specific words and tokens) must match for the grammar line to be accepted.
- The action processing rules must reference the action interpreted by the parser. If you write an
Instead of taking...rule, it cannot apply to
the picking action. Again, >PICK TWO OF WANDS would result in
the taking actiongiven the grammar line that you show in the first example above.
- As drpeterbatesuk notes, whether or not the parser error above happens does not depend on the action definition, it depends on the grammar line definitions. The built-in rules already includes
Understand "take [things]" as taking., but since you can’t equate the words “pick” and “take” in this case, it needs a grammar line that starts with the word “pick”. The first example above lacks a grammar line allowing multiple things.
- You can get that parser error if you have linked >PICK… to
the taking actionbut are trying to pick a card that is not present. The normal
You can't see any such thing.parser error is not provided because the parser thinks that the word “TWO” in player input is supposed to mean two of some kind of thing, because it does not match to the names of any cards visible to the player character. (Again, this should not be happening when the
Two of Wandscard is present unless something is going wrong with name-matching.)
In your latest example everything relevant to #1 through #5 seems to be sorted out, though you are using a custom
picking action, which may not be advisable because it will complicate rule-writing. (Does
the picking action meaningfully differ from
the taking action?) If you post the
Understand... lines related to cards, that may help.
You may find WWI 16.16 Defining things with tables to be helpful.
If the table’s first column is defined as the kind of the thing being defined, that column will be interpreted as the name of the instance defined by the row.
Thank you for taking the time to write this. Slowly (slowly) I learn.
Did it actually solve your problem?
Not yet. But it gave me some insight into how things work. My problem is that I only have a superficial concept of commands. I can figure out what to do from the examples (sometimes) and the rest is just experimentation or help from strangers.
This last puzzle is a doozy. I went in an renamed the initial column as a non-text version of the card (two of wands instead of “two of wands” but it treats it like a thing which means I have to define all 76 cards as things. I don’t have a deeper understanding. If I couldn’t do it forty years ago in BASIC then I’m struggling with it here.
Anyway, thank you for your help and your time, it is greatly appreciated!
Yeah, if you didn’t want to do this then you’d have to go about this in a completely different way to the one Ryan Veeder outlined.
If the cards are not things, then you can’t match them in a command to [something] or [thing] or [things]
You could match them instead as a topic in a command to a topic column in a table, but that would require a substantial rewrite of the code Ryan supplied. If you want to go down that route instead, I could supply some outline code for you.
Yes, Ryan’s code didn’t work but it did teach me a few things. I am working now with a version of Mike Russo’s suggestion. Third time starting over, but I’ll get there.
For what it’s worth I was also assuming you’d implement the cards as independent objects, and since it sounds like you do want to be able to restart/redo the draw once it’s started, I agree with Ryan that the “used yet” column is a better idea than blanking out rows - so all told I’m not sure there’d be a significant difference between the approach I outlined and the code Ryan wrote.
One quick question – now that I have returned to Ryan’s code. How does Ryan’s code know which is the right card?
It looks like he’s got a table where he manually listed the correct cards (you might want to pick them randomly or by some other method - the code should still work as long as you end up with a Table of Correct Tarot cards formatted like his). Then his “to assign the next correct card” rule just steps through that table entry by entry, and assigns whichever card is next to the “correct card” variable, which gets compared to whatever card the player chooses during the “instead of taking a tarot card” rule. Does that make sense?
I thought I’d take a whack at a version in which only the three cards are things per se and the tarot trumps are a kind of object.