Item generation and other misc newb questions...

Okay, so I admit I’m a total newb/noob/n00b/newbie <==== [choose your preference.] I just started designing and Inform 7 about 3 days ago, and it took me hours just to figure out how to have the command “go to the door” replace “go to [specific door name]”.

So I have four issues so far with this program that I have not been able to get over, but here are my basic newbile questions. I’ll start with my main one:

1.) Is there a way to generate items? I don’t mean create items, but actually bring non-existent items into play as an effect. The closest thing I saw to this was in chap. 8.10, on removing things from play, so you can have on-stage/off-stage. I could just make an off-stage item and bring it on-stage, but what if I don’t want a set number of items? E.g., what if I wanted to make a soda-dispensing machine that could theoretically generate an infinite number of soda bottles? I’m asking this because I wanted to make a coffee shop, and I didn’t like the money system they have built in for “Ex. 253 - frozen assets” because you have to take something already on the shelf in order to buy it. You can’t, say, type command in “small” and generate a small coffee. I tried creating a table (basically on the same model from “Ex. 362 - complementary peanuts”) and added entry that lists items, with something like “now player has/carries x entry.” As I expected, it didn’t really like that too much. I’m guessing partly because the item must already be located somewhere in play. But like I said, I really don’t feel like making a limited number of extra items somewhere inaccessible in play. Am I missing something here?

2.) nested ifs - this has been my biggest frustration with Inform 7 so far. I must be missing something, because the colons feel pretty useless. I miss programming with Java, where a nested if is a nested if. For whatever reason, Inform hates me when I try to get it to produce multiple effects. For example, let’s say I have something like this:

if player’s command is topic entry:
if the price of money is less than m entry, say “Sorry bud, you don’t have enough money for that.”;
otherwise:
decrease price of money by m entry;
say “[commentary entry][line break]”;
now player has x entry;
rule succeeds;

I can get it to work one of those effects without the colon. but not all of them. I keep running into this problem. I had to get around it with inefficiency by making phrases, like so:

Understand “go to the door” as door finding.
Understand “go to door” as door finding.
Understand “open the door” as door finding.
Understand “open door” as door finding.
Door finding is an action applying to nothing.
Report door finding: if the player can see a closed nWi door, declare dooring; otherwise say “Where’s a closed door? You’re losing your mind.”
To declare dooring:
if the location contains exactly one closed nWi door, declare doooring;
otherwise say “which door do you mean? There is [list of doors in location].”
To declare doooring:
if the location contains a nWi door (called target), try opening the target.

Again, I must be missing something. It seems silly that I have to make two phrases instead of doing nested ifs. What the heck? What’s the point of the colon if Inform gets mad at me every time I try to use it?

3.) pockets so another thing I’m really struggling with is trying to create pockets on clothes. I’ve made pockets. But what’s really dumb is I cannot seem how to include pocketed items in take inventory. More importantly if I put something in a pocket, then I cannot take it out unless I say command “take [something] out of [pocket name]”, and if I’m wearing a jacket with a pocket + pants with two pockets, this can be a hassle. I’m trying to make some basic take-out commands. Understand “take [things inside] out of [something]” as removing it from. <–so far so good. but the issue is when I need to supply a missing second-noun, which searches through all the containers I’m wearing and takes it out. Actually, I’ve been able to do this, but where I’m stuck is if I need to take all the container component parts of clothes out.

Understand “take [things inside] out” as taking something out.
Understand “take out [things inside]” as taking something out.
Taking something out is an action applying to one thing.

[all the remove it from checks]

Carry out taking something out:
try removing [things inside] from [every container object player is wearing/carrying + every container object that is a part of the object that the player is wearing/carrying

so the problem (to start with) is I cannot seem list all container parts of things worn by the player.

HELP!

4.) conversations last but not least. I would love a simple answer to how to make changing state conversations. So for example if I answer a particular command that matches the topic entry, how can I have the effect be to switch to another conversation table, or change the command prompt, etc?

5.) Okay one last question. If there’s a great downloadable Inform 7 source code that answers any of the above questions and more that someone could recommend, I would really appreciate it. thanks

-P

Partial answers:

1: Yes, you can create brand-new items. It requires an extension. However, don’t do it. Limit the player to so many items. Your game will be better; the player won’t clutter up (and slow down) the game world with a bunch of story-irrelevant cruft.

2: You can nest ifs, but you can’t mix them with the “if thing, comma whatever” format. Use colons everywhere.

if player's command is topic entry:
  if the price of money is less than m entry:
    say "Sorry bud, you don't have enough money for that.";
  otherwise:
    decrease price of money by m entry;
    say "[commentary entry][line break]";
    now player has x entry;
    rule succeeds;

(Also, if you use CODE tags, the bb system won’t flatten out your indentation. This will make your questions easier to read.)

Understand "go to the door" as door finding.
Understand "go to door" as door finding.
Understand "open the door" as door finding.
Understand "open door" as door finding. 

Don’t do this; you’re bypassing the parser. Write rules for the “opening” and “entering” actions to do what you want. (You could have them invoke your “door finding” action if you want, but there are probably easier alternatives.)

Thanks for the comments. Sorry like I said, I’m a noob.

[code]Outdoors is a room. The Coffee Shop is inside from Outdoors. Outdoors is outside from The Coffee Shop.

Instead of asking the Peanut Vendor to try doing something:
repeat through Table of the Peanut Vendor’s Commentary:
if player’s command is topic entry:
if the price of money is less than m entry:
say “Sorry bud. You don’t have enough money for that.”;
otherwise:
decrease price of money by m entry;
say “[commentary entry][line break]”;
now the player has ob entry;
rule succeeds;
say “‘Peanuts! Pretzels! Popcorn!,’ says the Peanut Vendor.”

Asking someone about something is speech.
Telling someone about something is speech.
Answering someone that something is speech.
Asking someone for something is speech.
Instead of speech when the noun is the Peanut Vendor:
repeat through Table of the Peanut Vendor’s commentary:
if the topic understood is topic entry:
if the price of money is less than m entry:
say “Sorry bud. You don’t have enough money for that.”;
otherwise:
decrease price of money by m entry;
say “[commentary entry][paragraph break]”;
now the player has ob entry;
rule succeeds;
say “‘Peanuts! Pretzels! Popcorn!,’ says the Peanut Vendor.”

The Peanut Vendor is a man in Outdoors.

Table of the Peanut Vendor’s Commentary
topic commentary m ob
“Peanuts” “‘here’s your peanuts.’” $1.00 peanuts
“Pretzels” “'Here’s your pretzels.” $2.00 pretzels
“Popcorn” “'Here’s your popcorn.” $3.00 popcorn

peanuts are a thing. peanuts are edible. peanuts are in Outdoors.
pretzels are a thing. pretzels are edible.
popcorn is a thing. popcorn is edible.[/code]

  1. The project I’m working on is small, and I’m not too concerned about it cluttering up. That being said, I’m open to alternatives. I just don’t want to use the frozen assets model of taking items already in play. But maybe moving pre-existing items, or making invisible backdrops visible, or off-stage/on-stage. seems very convoluted to me though. Above is the model I tried but didn’t work (as I pretty much expected). I know there’s something wrong because it does the same thing if I order anything. Besides, if a player decides to do use all his or her money on a vending machine, it’s really the player’s own fault for cluttering up the world at that point :stuck_out_tongue:.

  2. as for the nested if, it seems my issue wasn’t the nested if but just a misplaced quotation mark. However, I seem to have issues with the colons. I haven’t noticed any consistent pattern, so maybe it’s just different errors.

I’m not sure what you mean by bypassing the parser. Are you saying I shouldn’t have different commands like “go to door” and “go to the door”? I just wanted to give players options so they don’t have to keep guessing until they’re like “Ooooh! so it’s ‘enter’ I was supposed to type!” Really not an enjoyable experience for those not all that accustomed to IF conventions (e.g. myself).

The last question I found the answer to, but I’d still love answers to all the other questions. I’m pretty sure I’ll find the answer to #4 if I keep digging.

-P

[code]Outdoors is a room. The Coffee Shop is inside from Outdoors. Outdoors is outside from The Coffee Shop.

Instead of asking the Peanut Vendor to try doing something:
repeat through Table of the Peanut Vendor’s Commentary:
if player’s command includes topic entry:
if the price of money is less than m entry:
say “Sorry bud. You don’t have enough money for that.”;
otherwise:
decrease price of money by m entry;
say “[commentary entry][line break]”;
now the player has ob entry;
rule succeeds;
say “‘Peanuts! Pretzels! Popcorn!,’ says the Peanut Vendor.”

Asking someone about something is speech.
Telling someone about something is speech.
Answering someone that something is speech.
Asking someone for something is speech.
Instead of speech when the noun is the Peanut Vendor:
repeat through Table of the Peanut Vendor’s commentary:
if the topic understood includes topic entry:
if the price of money is less than m entry:
say “Sorry bud. You don’t have enough money for that.”;
otherwise:
decrease price of money by m entry;
say “[commentary entry][paragraph break]”;
now the player has ob entry;
rule succeeds;
say “‘Peanuts! Pretzels! Popcorn!,’ says the Peanut Vendor.”

The Peanut Vendor is a man in Outdoors.

Table of the Peanut Vendor’s Commentary
topic commentary m ob
“Peanuts” “‘Here’s your peanuts.’” $1.00 peanuts
“Pretzels” “‘Here’s your pretzels.’” $2.00 pretzels
“Popcorn” “‘Here’s your popcorn.’” $3.00 popcorn

peanuts are a thing. peanuts are edible. peanuts are in Outdoors.
pretzels are a thing. pretzels are edible.
popcorn is a thing. popcorn is edible.
[/code]

fixed it. I just switched “is” to “include” and it seems to work now. Hm! whew! now for pockets, and the other issues.

What Zarf means with “bypassing the parser” is (I think…) that you shouldn’t “understand” entire phrases like “go to the door”. Instead handle verb phrases and objects separately.

It’s certainly not wrong to make the parser handle different wordings, it’s a matter of how you do it.

For the pockets question:
If you’re talking about having multiple pockets and making the player be careful about what they put where and remember where everything is stashed, I would recommend against that. You will spend a lot of time implementing it, and it will drive your players crazy. This isn’t exactly what you’re looking for, but if I were you, I would make use of the little-known kind, “player’s holdall.” It’s a built-in kind that is sort of based on legacy game design, such as games in which the player can carry around all of their items in a big burlap sack, and it will do things like automatically taking things out of the holdall when the player wants to use them, and automatically put things back in when the player is holding too many things. Then, to make it seem more like the pocket is part of the player’s clothes, simply refuse to allow the player to drop the holdall. If you have a game in which the PC can’t take off their clothes, that’s all you’d need; if they can, you can do the thing where you make it a part of the clothes.

You want to build these in the most generic way possible, so that they apply to whatever the player types.

For example, the standard rules already include the line

Understand “go into/in/inside/through [something]” as entering.

This covers several possible phrasings, and every game object. (So if the player types “enter window”, the response will be action-specific: “That’s not something you can enter”.) It also understands all object synonyms, and “the” for free. On top of that, it accepts “walk into door” and “run through the door”, because “walk” and “run” are declared as synonyms for “go”.

It’s true that “go to” is missing from this list. You could add:

Understand “go to [something]” as entering.

The parser would then understand “go to door”, “walk to the door”, and so on.

Thanks zarf, that makes sense. I was erroneously trying “this”/“that”, not “this/that”. Examples really help clarify things for me. As for the pocket issue, here’s what I have:

[no naked]Instead of taking off clothes, say "...[no line break][one of]so you now want to make like a nudist and walk around campus naked? Gee, that sounds like a swell idea! I have a better one: how about we [italic type]not[roman type] get arrested this time?[or]haven't we already been through this?[or][line break][stopping]"

[pockets]
Everything is either PS [abr. pocket-sized] or not-PS. A thing is usually not-PS.
A pocket is a kind of container. The carrying capacity of a pocket is usually 2.

Instead of inserting a not-PS object into a pocket:
		say "Why are you trying to shove that into your pocket!? Obviously it does not fit. Sometimes I wonder if you're from another planet." [note: in future, might need add a "some condition," for "put some dirt in pocket," etc. Might need to put in a "liquid condition," if player tries to pour a liquid in the pocket."]

Understand "pockets" as every pocket. [understand "check pockets" command? How do you get it to stop asking "which pocket?" <---"which one" under activities section (I think)]

[clothes] clothes are a backdrop. clothes are wearable. The player wears clothes.

pants are a part of clothes. A pocket called the left pocket is part of pants. A pocket called the right pocket is a part of pants.

A jacket is a kind of thing. A jacket is always wearable. [A pocket called the jacket pocket is part of a jacket. [note: should say "every jacket," if other jackets come into play. if we're only dealing with one jacket, this should not be a problem]]The player wears a jacket called your jacket. A pocket called the jacket pocket is part of your jacket.

I’m familiar with the holdall. To begin with, it won’t let me make the pocket a holdall (I believe) because it only lets specific objects be a holdall (understandably). So I cannot say something like “a pocket is the player’s holdall,” because that would make very pocket object the player’s holdall. When I try to make a specific pocket, like the left pocket, the player’s holdall, it gives me this: “You wrote ‘The left pocket is the player’s holdall’, but that seems to contradict ‘A pocket called the left pocket is part of pants’, as a player’s holdall and a pocket are incompatible. (If a player’s holdall were a kind of a pocket or vice versa there’d be no problem, but they aren’t.)” I think it doesn’t like component parts to be the player’s holdall.

Secondly, the holdall issue does not fix either the problem of inventory, or taking items out. The character wears a backpack as his holdall. If I put a camera in the backpack and say “take inventory” it will reply: you are carrying nothing. This is easy to fix, I just need to say something along the lines of, “[list of backpack contents]” <–not exactly that, I know, but I’m sure I can eventually figure that one out if I keep messing around with it. But what I’m having more difficulty with is if I want to say “take out camera” and not “take camera out of backpack,” how do I get it to search all containers the player is wearing and all the component parts of all the items the player is wearing??? How should I supply the second-noun for the modified “remove it from”?

Also, not to add to the list of questions, but does anyone know a good way to make it so you don’t have to say the NPC’s name whenever answering? “Ex. 91 - Sybil 1” does this, but only b/c “say yes,” “say no,” and “say sorry” are already actions in the list of actions. Do I have to add new actions for every response? So for example if the barista asks, “small, medium, or large?” and i don’t want the player to say “barista, small” but just “small,” do I have to make a new action that says “say small” or is there a simpler way to do it?

Yes – or is that no? Anyway, player’s holdall is a kind. You can have several of those. Just assert “A pocket is a kind of player’s holdall” instead of “A pocket is a kind of container”.

Thanks Felix,

You’ve made my life so much easier.
The simple answers are always the best.

So now I’m trying to make a “take out” command:

Understand "take [things inside] out of [something]" as removing it from.
Understand "take out [things inside]" as removing it from.
Understand "take [things inside] out" as removing it from.

Rule for supplying a missing second noun:
[if the player has...]

So i was thinking something along the lines of:
“Let L be the list of player’s holdalls…”
Is there a way to check the contents of each item in list L and supply the second noun for each item that matches [noun]?
If so, I’m not sure how to do it.

It might be simpler just to create a new “taking out” action with one noun instead of supplying a second noun to “remove it from.” Either way, my main issue is I still don’t know how to get to the contents of each holdall. That’s all I need and my problems will be solved.

You could also just understand “take [something] out” as taking; this will let the player take the object from whatever object it’s in, without your having to figure it out. It’ll also let the player get something on the floor by typing “take key out,” but no one will mind that. (Letting the player do extra stuff isn’t a problem; the problem is when the game doesn’t understand something it ought to.)

Hooray! Slowly but surely, I’m getting my problems solved. Last issue with the pockets is the inventory.

Understand "check holdalls" as holdall checking.
Holdall checking is an action applying to nothing.

Carry out holdall checking:
	let L be the list of player's holdalls;
	let N be the number of entries in L;
	while N is greater than 0:
		say "[list of contents in entry N of L]";
		remove 1 from N;

the question is this “[list of contents in entry N of L]”?
And again I’m sure there’s a much simpler solution.

Do you know about repeat… running through loops? I think that’s what you want here:

Repeat with satchel running through the player's holdalls: say "[list of contents of satchel]".

I’m not sure whether this is exactly the best way to handle what you want to do, but this is definitely the right control structure for the code you just posted. See section 11.11 of the documentation.

ETA: And I haven’t worked with holdalls much, but if “the player’s holdall” is a kind you might need to restrict this to holdalls that are carried.

I love the suggestion. This is definitely much nicer looking than where I was trying to go.

So unfortunately, Inform still doesn’t want me to get to these contents. Trumped again. The following attempts all failed

To checkhodall, repeat with satchel running through the player's holdalls: say "[contents of satchel]".
To checkhodall, repeat with satchel running through the player's holdalls: say "[list of contents of satchel]".
To checkhodall, repeat with satchel running through the player's holdalls: say "[list of things contained by satchel]".
To checkhodall, repeat with satchel running through the player's holdalls: say "[is-are a list of things in satchel]".
To checkhodall, repeat with satchel running through the player's holdalls: say "[list of things in satchel]".
To checkhodall, repeat with satchel running through the player's holdalls: try examining satchel.
To checkhodall, repeat with satchel running through the player's holdalls: say "[a list of contents of satchel]".
To checkhodall, repeat with satchel running through the player's holdalls: say "[a list of things contained by satchel]".
To checkhodall, repeat with satchel running through the player's holdalls: say "[a list of things in satchel]".
To checkhodall, repeat with satchel running through the player's holdalls: say "[a list of things held by satchel]".
To checkhodall, repeat with satchel running through the player's holdalls: say "[a list of things held within satchel]".
To checkhodall, repeat with satchel running through hodalls carried by the player: say "[contents of satchel]".
[etc., etc...]

Inform just does not want to recognize the contents of the satchel as a description of items. And It’s definitely the “contents of satchel” part that it has issue with. When I would just put say “test” it worked fine.

So, I’m not quite sure why some of those things don’t work, but the action that will get you the list of things in a container is searching. So you could try this:

To checkhodall, repeat with satchel running through the player's holdalls: try searching satchel.

I went through the Standard Rules to see what searching a container does, but the standard search containers rule isn’t very illuminating; it just gives a library message. Looking through Ron Newcomb’s Custom Library Messages extension to see what that message is (for nonempty containers), it appears to be:

 "In [the noun] [list the contents of noun with as a sentence list option +  tersely list option + not listing concealed items list option + is-are list option]."

which I guess is explained in section 11.14, and you should probably look at the example “Equipment List” found there. But I’m not sure why “list of things in satchel” isn’t working.

(Can I ask you to remind me why you need to do this again? If it’s for the sake of making things show up in the inventory, I think the problem must be that your holdalls are closed opaque containers. If they were open or transparent then their contents would show up in the inventory listing, unless you did something else to change the listing. Looking at 11.14 and “Equipment List” really should help here.)

No, that didn’t work either. I swear, Inform is ensuring it’s impossible to list items in containers attached as parts to items you’re wearing.

Visibility shouldn’t be an issue. It still lists the items in the (closed, opaque) backpack. it’s just those @#$# pockets! Even if it were simply a matter of visibility, I’m making a gumshoe mystery investigation IF that uses a few puzzles where you have to sneak things in through your pockets, so it would seem rather pointless to make the pockets transparent.

Instead of taking inventory: 
    say "What are you [italic type]blind[roman type] or is your amnesia really that severe? You're carrying [a list of things carried by the player][if the player wears something]. You are wearing [a list of things worn by the player including contents][end if]. You currently have [price of money] in cash.".

All I want is to include the pocketed items in this list. Is this too much to ask Inform?

It’s not the end of the world, but there’s just got to be a way to do it. We’ve got to be overlooking something.

the examine containers rule under examining [container] looks something like this:

Carry out examining (this is the examine containers rule):
if the noun is a container:
if the noun is open or the noun is transparent:
if something is in the noun:
if the description of the noun is not “”:
say “[the description of the noun][paragraph break]“;
say “In [the noun] [is-are a list of things in the noun].”;
stop the action.

I just don’t get why it doesn’t work for the pockets. I also tried changing pockets back from holdalls to containers, but still the same issue.

Oh, the holdall is part of a worn thing. I think that’s the problem.

This seems to work, except that the output is fairly crappy and inelegant:

[code]Instead of taking inventory:
say “What are you [italic type]blind[roman type] or is your amnesia really that severe? You’re carrying [a list of things carried by the player][if the player wears something]. You are wearing [a list of things worn by the player including contents][end if]. [If a thing worn by the player incorporates a container][check pockets] [end if]”

To say check pockets:
repeat with satchel running through containers that are part of something worn by the player:
if satchel contains something:
say “In [the satchel] which is part of [a random thing incorporating satchel] [is-are a list of things in satchel].”[/code]

(I left out the cash because I didn’t feel like programming it into the test code.) Anyway, this is probably ooky in various ways, but you can probably see how to turn it into something that doesn’t suck.

[UPDATE: Fixed the error with is-are.]

Thank you Matt.

Worked like a charm. You saved me hours of frustrating time spent trying to figure that out.
I’ve got plenty of other issues, but it feels good to at least have the pockets and the buying down.

I should be good, once I get the issues with conversations resolved.

-P

None of these will work because you used a comma where you needed a colon. For example, this works fine:

[code]To say checkholdall:
repeat with satchel running through player’s holdalls enclosed by the player:
say “[The satchel] contain[s] [contents of satchel].”

Instead of taking inventory:
say “You’re carrying [a list of things carried by the player][if the player wears something]. You are wearing [a list of things worn by the player including contents][end if]. [checkholdall]”.[/code]
The problem is that phrases can contain commas – they are used to delineate “phrase options” (see ch.11.14). In your code, Inform assumed everything after the comma but before the colon (“repeat with satchel, etc.”) was a phrase option – not an actual repeat loop. Since it didn’t know you meant a loop, it didn’t know that “satchel” was meant to be a local variable, and therefore “contents of satchel” was meaningless. Since “satchel” was the first unrecognized thing in your code, that’s what got flagged.

This is very common in I7 because unfortunately, it can’t guess what you mean, it can only go by what you type. Very often, the error in your code is not the part that gets flagged, but the part immediately preceding it. These errors are most commonly typos (e.g. incorrect punctuation as in this case or defining a variable and then misspelling it later when you try to use it).

HTH