a buying question

movie ticket is carried by ticket booth girl.The price of a movie ticket is $8.00.

ok so with the above little snip of code, I can buy a movie ticket from the ticket booth girl. If I wanted to buy 2 tickets or 52 tickets (if I had the money to do so) how would I go about doing that? I tried fishing around with something along the line of:

after buying movie ticket:
Let P be a random movie ticket carried by ticket booth girl;
Now the player carries P.

which of course didnt compile because I just pulled it out of my butt, but I think maybe I am somewhat on the right track but going about it incorrectly?

Are you talking about creating movie tickets while the game is playing? Z-code games need to declare all their objects in the source. I think there’s an extension for glulx that allows run-time creation via a table.

It dosnt have to be while the game is playing, the ticket booth girl can have a endless supply of tickets to dispense in the source code from the start, I just need to find a way to have her have the tickets to sell to the player and not just a single ticket. If the player goes to the movies with another person then buying 2 tickets would be needed.

edited to say that this is glux

It probably would be easier to side-step the issue and just don’t have any tickets on the cashier. Then you can move the appropriate amount from the supply of tickets to the player when necessary.

Ill try to see if I can work that out somehow.

I know this is probably an old question but it’s handy.

To make multiples, you make a “kind” of thing.

A ticket is a kind of thing. A movie admission is a ticket.

The clerk carries 10 movie admissions.

Instead of buying a ticket:
move a random ticket carried by the clerk to the counter.

(not tested, but the idea)

You’ve got some of the right ideas, but you have to lay some groundwork first.

First, if you want there to be multiple tickets, you need to define a ticket as a “kind” of thing, so that you can declare things about tickets in general. The code for this is pretty straightforward:

A ticket is a kind of thing.

Also, you can’t just declare things about the “price of a ticket,” because first you need to define what price is and how to express it in the game:

Price is a kind of value. $10.99 specifies a price. [That just explains how prices are formatted: a dollar sign, up to two digits, a decimal point, and two more digits.] A thing has a price. The price of a thing is usually $0.00. The price of a ticket is usually $8.00. [The last two statements set the default price for things in the game: everything defaults to $0.00, except for tickets, which default to $8.00.]

Now, as some people have already mentioned, having a potentially infinite supply of tickets will be problematic. There is an extension that helps you do it, but it may be more complicated than you want or need. So the question to ask is: are infinite tickets really necessary for your game? Would it destroy your design if, after the player purchases 100 tickets, the ticket booth girl says, “Sorry, that was the last ticket?”

Let’s assume you can live with the ticket booth girl having 100 tickets.

The ticket booth girl carries 100 tickets.

Let’s move on to buying tickets. The default response for the buying action is simply, “There is nothing for sale here.” You’ll need to write rules to change that behavior.

Instead of buying something, say "[The noun] isn't for sale." [This sets the default behavior for buying most things.]

Instead of buying a ticket:
    if the noun is not carried by the ticket booth girl:
       say "That ticket has already been purchased.";
       "You hand over $8.00, and the girl in the booth hands you a ticket.";
       let P be a random ticket carried by the ticket booth girl;
       now P is carried by the player;
    end if.

One problem you will immediately discover is if you have a ticket, and the ticket booth girl has tickets, the game won’t know which you mean when you just say “BUY TICKET.” In fact, it will assume you mean the one you’re carrying. So you’ll want to include a rule that makes the game assume the opposite:

Does the player mean buying a ticket carried by the ticket booth girl: it is very likely.

One final thing to note: in your example, you mentioned buying 2 or 52 tickets. In Inform, the buy action is designed to only understand one format: BUY [noun]. It won’t understand BUY 2 TICKETS unless you create some new grammar lines for that action, which is getting beyond the scope of this post.

I would strongly recommend you check the Inform Recipe Book, Chapter 9.4, “Money,” and in particular example 249, “Frozen Assets.” It’s a complete, playable example that implements a cash system like the one you describe. Study that code, play around with it, see what you can come up with.