Determining which object is in the room with the player.

Hey all,

I’m working on a game where one of the core themes/mechanics are temptations. However I’m having a tough time getting them to work.

The temptations are objects that are placed in rooms. They have a bunch of values that refer to their difficultly to resist.

I have an after action that activates my tempting action (to tempt:)

But I cannot figure out how to tell inform that the temptation I want to pull the values from is the one that is currently in the room with the player. I’ve tried variations of: the temptation in the presence of the player, the temptation in the room that contains the player. I haven’t found a combination that will allow me to designate the temptation as the “active” temptation. I can pull the properties I want if I refer to a specific temptation aka, the strength of the chocolates but I can’t find a general for.

Suggestions? Is there some command that I’m over looking?

Thanks!

Try “a random temptation in the location of the player”. The word “random” is needed because there’s nothing preventing there ever being more than one in the same location and the phrase must always be unambiguous.

Thanks that worked! Although I’m not sure what do to if there actually are two temptations with the player. (More advanced temptations might be carried around

You could get ‘a list of temptations enclosed by the location of the player’ or ‘a list of touchable temptations’. I think. Then you could handle every temptation in the vicinity of the player.

Or, if you’ve defined a comparative, you could say something like “the temptingest temptation in the location of the player” if that’s what you want. See sections 6.7 and 6.8 of the documentation on how to use comparatives and superlatives.

Thanks for the suggestions. I’ve got it working with the random bit but I’m trying now to transition to lists. However Lists don’t appear to be working at all!

I can copy paste a list command right out of the documentation:

let L be {60, 80};

And it gives me this You wrote ‘let L be {60, 80}’ : but I can’t find a verb here that I know how to deal with, so I am ignoring this sentence altogether. (and then complains about the commas.)

I looked in my phrase book and it looks like there is no let for lists. What’s going on?

The list declaration in that form must be inside a rule or phrase, it needs a context. If you want to create a global list variable:

L is a list of numbers that varies. L is {60, 80}.

Judging by the error message the “let L be…” line isn’t inside a rule, but if it is, you’ll have to show it completely to say anything more definite.

Thanks guys. I’ve now got it working with lists that it can iterate through.

One thing I’ve noticed is that the list seems to be very temporary or specific to the block that is running. I can’t call another function that will use a list defined in the first.

What I had at first was a block that would cycle the list and then called a tempt action which was defined as a to tempt:

The to Tempt function could not call on the lists defined in the original action (After the player going to a room containing a temptation:) Despite the list being declared outside that block. Any time tempt refered to entry 1 of the list I get a error that the list is empty.

What I had to do was move the contents of tempt inside the action which is okay but my code is starting to get long and I have more functions to write that could use the information in that list. Can I copy the list between blocks somehow?

Thanks!

A list defined as a global variable (Juhana’s example) should work anywhere. But maybe you’re accidentally clearing the list, or trying to use it before it’s filled in.

You’ll have to post sample code for us to figure out what’s going on.