If-clause with self-defined text


#1

Sorry to ask for help again, but I don’t know what to do here as I don’t see the error. What is wrong here:

[code]The player has some text called CUE. The CUE of the player is usually “”.

The CUE of the player is “now”.

If the CUE of the player is “now”, say “now”.[/code]
The last line gives me an error (“the punctuation here ‘:’ makes me think this should be a definition of a phrase”) but I have no idea why.

Any explanations?


(Daniel Stelzer) #2

It’s because that line is just sitting in the source code, not inside a rule or definition. The compiler needs to know when exactly the code should be run.


#3

I don’t think I can follow. I always use if clauses outside of rules and they work. Could you write an example that works?


#4

To be a little more specific about my question, I want to have a rule that applies when the cue of the player changes to something specific.
Maybe I’m using a wrong approach for an ingame cue here. I hahe multiple cues when something should happen.


(Daniel Stelzer) #5

I don’t believe there’s any time that an if-clause will ever work outside a rule. It’s like putting code outside of a function in C/C++.

Any of these will work:

[code]When play begins:
if the cue of the player is “now”, say now.

Every turn:
if the cue of the player is “now”, say now.

After going nowhere:
if the cue of the player is “now”, say now.[/code]


(Piergiorgio d'errico) #6

I’m wrong, or “now” is a reserved word in I7 ?

(WI 8.11 and passim in WI ch.8)

Best regards from Italy,
dott. Piergiorgio


#7

I’ve found a nice way to do what I want with [code]the player has some text called status.

now the status of the player is “restricted”.

each turn when the player is in the alleyway:
if the status is “restricted”:
bla[/code]
This is what I wanted.