Okay - there were a lot of small syntax problems in your demo. Once I fixed those, I hit a bunch of mechanical problems to do with Inform’s stock ideas about turning things on.
In a sense, the way you’re interacting with the objects in your code at the moment is that… water is a thing which can be turned on and off. But to Inform’s eyes, that makes the water almost like a device with an on and off button. What’s more likely to make sense is that there’s a tap or shower, with a tap that you can turn to start the water. Since the tap/shower is the physical thing, my approach would be to install that, set up commands which toggle the water’s status when the tap is turned, and then reroute ‘turn water on’ to those tap turning commands as a synonym.
But first, I have fixed up the demo doing it your way (water is a device that can be turned on), just so you can see how I tweaked it.
This was your table:
Table of Flags
event flag
"showeron" 0
It’s fine.
Now your code:
Instead of turning on the water:
Choose the row with an event of showeron in the Table of Flags;
If the flag entry is 0:
Say "You turn on the water."
Now the flag entry is 1;
Continue the action.
If the flag entry is 1:
Say "The water is already on."
First problem - when you say ‘row with an event of showeron’… because you have not put inverted commas around ‘showeron’, Inform is looking for a variable somewhere out there called showeron, which doesn’t exist. What you’re really trying to match is a piece of text which says “showeron”. The inverted commas always tells inform something is text. So to fix this line…
Choose the row with an event of "showeron" in the Table of Flags;
Next problem - immediately after “You turn on the water.” there needs to be a semicolon. 99% of the time, all lines that contain code have to end with a semicolon if the next line is more code (main exception - when the present line ended with a colon). Only when a section of code is completely finished and the next line is blank, that’s when you use a period.
So this line becomes:
Say "You turn on the water.";
Next prob: ‘continue the action’ is probably not what you want here. Overall in this demo, you’re saying ‘instead of doing what inform would normally do to turn on this water thing, do the code I wrote here.’ But then at the end of it, when you say ‘continue the action’, you’re saying to Inform, ‘now stop doing it my way, and finish off the processing in your usual way’ - which will result in Inform going to the report rulebooks and such.
You did want to stop doing it your way (to prevent the ‘The water is already on.’ message appearing as well), but you don’t want Inform reporting on the action, because you just did that yourself. Using ‘continue the action’ here essentially makes Inform print both “You turn on the water”, and then its own default message about turning stuff on.
So you want something that stops your action continuing and stops Inform doing any default stuff afterwards, either. That something is probably ‘rule succeeds’. Alternatives are ‘stop the action’ and ‘rule fails’. All 3 will cause the stop, but which one you pick determines the success status for this action. Just being logical, we did turn on the water, so ‘rule succeeds’ seems like the best bet.
And again - after ‘continue the action’, you used a period when a semicolon is needed, so we’re replacing that line with ‘rule succeeds;’
Those were the syntax problems. Having dealt with those, it turns out that Inform can’t just turn anything on. In Inform’s default setup, “turn on” leads to the action “switching on” (I found this by typing ‘actions’ and ‘rules’ to monitor what verbs were going where in the demo, then typing ‘turn on water’) Inform has a kind of thing which can be switched on, which is called a device. So if we said:
the water is a device in Bathroom
That would get us in the ballpark. But I was still having trouble intercepting the action, setting up the water, etc. (I’m inexperienced with devices.) Plus I didn’t like the messages.
So I decided, ‘okay, I’m going to take over the verb ‘turn’ so it does what I want.’
I zapped Inform’s definition of ‘turn’, made a new action called ‘turning on’ that can apply to anything in my demo, and that solved the problem. This would not make much sense in the long run (being able to turn on anything, let alone water) but I did it for the sake of getting the demo running along the lines you originally stated.
Here’s the final product, which works:
[code]“Water On”
Bathroom is a room.
water is a thing in Bathroom. “There’s a shower here.”
Table of Flags
event flag
“showeron” 0
Understand the command “turn” as something new.
turning on is an action applying to one thing.
Understand “turn on [something]” as turning on.
Instead of turning on water:
Choose the row with an event of “showeron” in the Table of Flags;
If the flag entry is 0:
Say “You turn on the water.”;
now the flag entry is 1;
rule succeeds;
If the flag entry is 1:
Say “The water is already on.”
test me with “turn on water / again”.[/code]
Edit - note, I still had ‘water is a device’ when I first posted this. That is unnecessary. I changed it to ‘water is a thing in bathroom’.
As you can see, the stuff after ‘instead of turning water on’ is barely different from what you originally typed - it’s just those syntax issues that righted it. Two semicolons, a pair of inverted commas, and one line changed.