Turn Script Problems... Again.

XanMag
I know I should have this figured out by now... but... I am me and me is tired and/or clueless.

My situation is this.

1. Player eats bad food and "unflags" healthy.

2. At turns 2, 5, and 8, there are reminders/warning that player must get to restroom.

3. At turn 12 the player either is in the restroom and there is success or player is not in restroom and there is failure. I'm okay so far. Player flag "healthy" returns. All is good.
---
PROBLEM IS:
If player gets to the restroom and "uses toilet" on turn 4 (flags "healthy"), I can make appropriate successful response, but I CANNOT stop the script from running turn scripts 8 and 12 (which registers as the failure response). I have tried damn near EVERYTHING and it is driving me crazy.

I've got a "healthy" flag on after using toilet (with healthy flag tied to disabling turn scripts). I've tried disabling the "sick" turn scripts after using toilet. I've tried nesting 'IF' statements and turning my 4 turn script sick messages into 1 large one (then trying the above). I've tried an 'IF' player has "healthy flag" in game script and in local room scripts. Shouldn't I just be able to disable each of my turn scripts after 'using toilet'?

Bottom line... After the turn script sequence starts, I cannot stop it unless it plays the entire 12 turn script. I've posted my turn scripts below. Let me know what I can do. I'm quite literally going nuts. :?

Eating food removes "healthy flag" starting TS "Sick1"

if (not GetBoolean(Xanadu, "healthy")) {
EnableTurnScript (sick2)
EnableTurnScript (sick3)
EnableTurnScript (sick4)
SetTurnTimeout (2) {
msg ("Your mouth, tongue, and throat have this odd, tingling sensation.")
}
DisableTurnScript (sick1)
}
else {
if (GetBoolean(farthest stall, "unclean")) {
DisableTurnScript (sick1)
DisableTurnScript (sick2)
DisableTurnScript (sick3)
DisableTurnScript (sick4)
}
}


Each turn script above (sick2, sick3, sick4) run at moves 2, 5, 8, 12 respectively and at the end of each TS I disable that specific turn script so the message only prints one time - if I don't do that message 2 (TS "sick 1") will run for the entire duration. Also, starting TS1 enables TS's 2,3,4.

Below is my script when player types "use toilet" before the 12 turn script is finished.

if (GetBoolean(Xanadu, "healthy")) {
play sound ("152979__dianser72__piss-on-the-bath.wav", false, false)
msg ("healthy response to using toilet.")
}
else {
if (game.pov.parent = farthest stall) {
play sound ("58837__opposit__longfart2.wav", false, false)
msg ("unhealthy response to using toilet."<br/><br/>---")
SetObjectFlagOn (Xanadu, "healthy")
SetObjectFlagOn (farthest stall, "unclean")
wait {
msg ("continued unhealthy response to using toilet")
MoveObject (rotten food, Item Warehouse 1)
IncreaseScore (10)
MoveObject (Xanadu, Long Hallway)
UnlockExit (JCLock)
}
}
}


As you see above, I set object flag "healthy" on the player, but I also have tried to disable the "sick" turn scripts as well. Neither kills the TS's early. It always runs through 12. Currently I have a "healthy flag" tied to disabling each turn script.

I'm likely being an idiot here, but I just can't figure this out. Also, I'm not savvy on code (I'm trying to learn), so please consider that when responding. As always, thanks for your help!

XanMag

HegemonKhan
if (not GetBoolean(Xanadu, "healthy")) {
EnableTurnScript (sick2)
EnableTurnScript (sick3)
EnableTurnScript (sick4)
SetTurnTimeout (2) {
msg ("Your mouth, tongue, and throat have this odd, tingling sensation.")
}
DisableTurnScript (sick1)
}
else {
if (GetBoolean(farthest stall, "unclean")) {
DisableTurnScript (sick1)
DisableTurnScript (sick2)
DisableTurnScript (sick3)
DisableTurnScript (sick4)
}
}


You disable TS1 (sick1), thus it's not active, so when you get to the 'farthest stall' and set it to 'unclean=true', it doesn't do any good, as it never gets to cause the running of the:

else {
if (GetBoolean(farthest stall, "unclean")) {
DisableTurnScript (sick1)
DisableTurnScript (sick2)
DisableTurnScript (sick3)
DisableTurnScript (sick4)
}
}


as it is disabled, so it never is checking that 'unclean' is now '=true', and thus your DisableTS (sick1-4), is never executed.

-------

so, two solutions:

don't DisableTS1 (sick1), until you reach the 'farthest stall', or, put your 'DisableTF (sick1-4)' in your 'use toilet' Verb's scripting (this would probably eliminate the need~use of your 'unclean' Boolean Attribute though).

XanMag
I removed the 'flag farthest stall to unclean after using toilet' just to see what would happen. There is no difference in the result. The unclean flag for the far stall is in place to simply unlock a room elsewhere on the map. Am I interpreting what you suggest correctly?

jaynabonne
You should just be able to disable the turn scripts. So the fact that something is going wrong means that there is a problem elsewhere - probably in some code you haven't shown. Is it possible to post the entire game (or a large sample that exhibits the problem)?

XanMag
GAME SCRIPTS:
SetObjectFlagOn (Blerk, "blerkclose")
SetObjectFlagOn (Blerk, "scuttles")
SetObjectFlagOn (Protected Video Recorder, "good")
if (game.pov = Blerk) {
if (ListContains(ScopeVisible(), Xanadu)) {
msg ("Oo ug-lee fer-end Xan is here. Oo ike Xan.")
}
}
if (game.pov = Xanadu) {
if (ListContains(ScopeVisible(), Blerk)) {
msg ("Blerk is here.")
}
}
SetObjectFlagOn (Xanadu, "healthy")
SetObjectFlagOn (nearest stall, "readnear1")
SetObjectFlagOn (middle stall, "readmid1")
SetObjectFlagOn (farthest stall, "readfar1")
SetObjectFlagOff (nearest stall, "readnear2")
SetObjectFlagOff (nearest stall, "readnear3")
SetObjectFlagOff (middle stall, "readnear2")
SetObjectFlagOff (middle stall, "readnear3")
SetObjectFlagOff (farthest stall, "readnear2")
SetObjectFlagOff (farthest stall, "readnear3")
SetObjectFlagOn (Blerk, "cautious")
if (GetBoolean(Xanadu, "healthy")) {
DisableTurnScript (sick1)
DisableTurnScript (sick2)
DisableTurnScript (sick3)
DisableTurnScript (sick4)
}


EATING FOOD THAT STARTS TURNSCRIPT "Sick1":
    <object name="rotten food">
<inherit name="editor_object" />
<inherit name="edible" />
<inroomdescription>There is rotten food here.</inroomdescription>
<look>Well, you think is is food. It is mushy and all sorts of unattractive shades of green and blue and black. You can't imagine what this would do to the living critter that ate this. You shudder at the thought.</look>
<take />
<takemsg>You scoop up the filthy mess of food. Just what do you plan on doing with that?</takemsg>
<attr name="feature_edible" type="boolean">false</attr>
<eathealth type="int">-10</eathealth>
<eatmsg>Ugh. You really hope this is worth it... You bend a piece of it off. The heat from your hand partially melts the blob you now hold in your hand. You swear you feel it squirm and try not to think about what you are about to do. You put the nastiness to your mouth with one hand and pinch your nose closed with the other. It smells like old cheese and vinegar and feels like a snail. You tilt your head back and drop it in your mouth. You stifle back a vomit and force yourself to swallow. You almost immediately regret it...</eatmsg>
<smell>The stench is awful. You move it away from your nose. Why are you even lugging that nastiness around?</smell>
<eat type="script">
if (not GetBoolean(Xanadu, "healthy")) {
msg ("You already feel like your innards are going to become your 'outards', so why would you want to eat more of this?")
}
else {
msg ("Ugh. You really hope this is worth it... You bend a piece of it off. The heat from your hand partially melts the blob you now hold in your hand. You swear you feel it squirm and try not to think about what you are about to do. You put the nastiness to your mouth with one hand and pinch your nose closed with the other. It smells like old cheese and vinegar and feels like a snail. You tilt your head back and drop it in your mouth. You stifle back a vomit and force yourself to swallow. You almost immediately regret it...")
SetObjectFlagOff (Xanadu, "healthy")
EnableTurnScript (sick1)
}
</eat>
</object>


FARTHEST STALL SCRIPT (the only one involving the turn script):
<object name="farthest stall">
<inherit name="editor_room" />
<description>You are in a restroom stall farthest from the door. The walls are adorned with some clever bathroom quips. There is a toilet here that appears to be in normal condition.</description>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<prefix><![CDATA[<b><u>the</b></u>]]></prefix>
<alias><![CDATA[<b><u>farthest stall</b></u>]]></alias>
<object name="Toilet1">
<inherit name="editor_object" />
<alias>Toilet</alias>
<look>This toilet is relatively clean, filled with a reasonable amount of water, and appears in good working order. There is a tank attached to the bowl. It looks ready for use.</look>
<feature_usegive />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<scenery />
<use type="script"><![CDATA[
if (GetBoolean(Xanadu, "healthy")) {
play sound ("152979__dianser72__piss-on-the-bath.wav", false, false)
msg ("You drop your drawers and pop a squat on the toilet. Yes, you do sit down because your aim is THAT bad. After a moment or two you have emptied your bowels into the bowl and, like a good boy, you wipe and flush. Congratulations...")
}
else {
if (game.pov.parent = farthest stall) {
play sound ("58837__opposit__longfart2.wav", false, false)
msg ("With your knees crossed coupled with your difficulty in standing up straight, you are having a hard time getting your pants down.<br/><br/>Just in the nick of time, you do get your pants opened up and you drop them to the floor...<br/><br/>Before you can sit down, however, the dam breaks and the flood gates open. At first, it just sounds like a high pressure fire hose. Sprinkled in are some odd toots and squeaks as the sulfurous emission continues. At the tail end (no pun intended) of your fecal display, the cacophony of noises erupts into a crescendo of honks, bloots, ka-phroops, slurps, and fizzles. Just when you thought the misery was over, the vomiting begins. The projectile barf flies forth in a fancy array of colors. The explosiveness of it all is enough to make Mt. Pinatubo blush. You hurl, spew, chowdergargle, and blow chunks. You upchuck one last time and wipe your mouth on your sleeve. At least you are feeling a little better now.<br/><br/>You wipe your bleary, wet eyes and take in your surroundings.<br/><br/>---")
SetObjectFlagOn (Xanadu, "healthy")
SetObjectFlagOn (farthest stall, "unclean")
wait {
msg ("Wow. Disgusting. I can't even describe how unclean this stall is. There are colors and smells and textures in here that go beyond rational explanation. Is it possible to hold this much filth in one human stomach? Wait... You don't remember eating anything that was neon green. How did shit get on the ceiling? <br/><br/>Anyway, you sheepishly back out of the stall, sneak quietly from the restroom, and walk quickly and quietly down the hallway. Although you feel sorry for whatever poor soul has to clean this up, you hope it gets done pretty quickly. Ick...")
MoveObject (rotten food, Item Warehouse 1)
IncreaseScore (10)
MoveObject (Xanadu, Long Hallway)
UnlockExit (JCLock)
}
}
}
]]></use>
</object>


SICK TURN SCRIPTS:
<turnscript name="sick1">
<script>
if (not GetBoolean(Xanadu, "healthy")) {
EnableTurnScript (sick2)
EnableTurnScript (sick3)
EnableTurnScript (sick4)
SetTurnTimeout (2) {
msg ("Your mouth, tongue, and throat have this odd, tingling sensation.")
}
DisableTurnScript (sick1)
}
else {
if (GetBoolean(farthest stall, "unclean")) {
DisableTurnScript (sick1)
DisableTurnScript (sick2)
DisableTurnScript (sick3)
DisableTurnScript (sick4)
}
}
</script>
</turnscript>
<turnscript name="sick2">
<script>
if (not GetBoolean(Xanadu, "healthy")) {
SetTurnTimeout (5) {
msg ("Aside from the tingly sensation in your mouth and throat, it now feels like little, drunk gymnasts are doing flips and twists in your gut. In doing so, those little gymnasts are somehow also playing an odd assortment of instruments that make some of the strangest gurgling, burbling, and sloshing sounds you have ever heard. Perhaps you should find your way to a restroom?")
}
DisableTurnScript (sick2)
}
else {
if (GetBoolean(farthest stall, "unclean")) {
DisableTurnScript (sick1)
DisableTurnScript (sick2)
DisableTurnScript (sick3)
DisableTurnScript (sick4)
}
}
</script>
</turnscript>
<turnscript name="sick3">
<script><![CDATA[
if (not GetBoolean(Xanadu, "healthy")) {
SetTurnTimeout (8) {
msg ("<i>'Oh, Dear Eight Pound, Six Ounce, Newborn Baby Jesus, in your golden, fleece diapers...'</i> you mutter as you begin your prayers. The twirling in your stomach has escalated to an all out riot. Whatever is in there, is fighting violently to get out. Your esophageal and anal sphincters are now on all out 'pucker mode'. Sweat has beaded on your brow. It is a cold and unwelcome sweat. You really, really, really need to find a restroom.")
}
DisableTurnScript (sick3)
}
else {
if (GetBoolean(farthest stall, "unclean")) {
DisableTurnScript (sick1)
DisableTurnScript (sick2)
DisableTurnScript (sick3)
DisableTurnScript (sick4)
}
}
]]></script>
</turnscript>
<turnscript name="sick4">
<script><![CDATA[
if (not GetBoolean(Xanadu, "healthy")) {
DisableTurnScript (sick4)
SetTurnTimeout (12) {
if (game.pov.parent = farthest stall) {
play sound ("58837__opposit__longfart2.wav", false, false)
msg ("With your knees crossed coupled with your difficulty in standing up straight, you are having a hard time getting your pants down.<br/><br/>Just in the nick of time, you do get your pants opened up and you drop them to the floor...<br/><br/>Before you can sit down, however, the dam breaks and the flood gates open. At first, it just sounds like a high pressure fire hose. Sprinkled in are some odd toots and squeaks as the sulfurous emission continues. At the tail end (no pun intended) of your fecal display, the cacophony of noises erupts into a crescendo of honks, bloots, ka-phroops, slurps, and fizzles. Just when you thought the misery was over, the vomiting begins. The projectile barf flies forth in a fancy array of colors. The explosiveness of it all is enough to make Mt. Pinatubo blush. You hurl, spew, chowdergargle, and blow chunks. You upchuck one last time and wipe your mouth on your sleeve. At least you are feeling a little better now.<br/><br/>You wipe your bleary, wet eyes and take in your surroundings.<br/>---")
wait {
msg ("Wow. Disgusting. I can't even describe how unclean this stall is. There are colors and smells and textures in here that go beyond rational explanation. Is it possible to hold this much filth in one human stomach? Wait... You don't remember eating anything that was neon green. How did shit get on the ceiling? <br/><br/>Anyway, you sheepishly back out of the stall, sneak quietly from the restroom, and walk quickly and quietly down the hallway. Although you feel sorry for whatever poor soul has to clean this up, you hope it gets done pretty quickly. Ick...<br/>---")
MoveObject (rotten food, Item Warehouse 1)
IncreaseScore (10)
MoveObject (Xanadu, Long Hallway)
UnlockExit (JCLock)
SetObjectFlagOn (Xanadu, "healthy")
DisableTurnScript (sick1)
DisableTurnScript (sick2)
DisableTurnScript (sick3)
DisableTurnScript (sick4)
SetObjectFlagOn (farthest stall, "unclean")
}
}
else if (not game.pov.parent = farthest stall) {
play sound ("202527__peridactyloptrix__farts-loud-and-obnoxious-x5.wav", false, false)
msg ("---<br/>You can no longer swallow your bathroom pride...<br/><br/>You drop your pants immediately where you stand. Before they hit the floor, the eruptions begin. There is so much leaving your body (from both ends), you quickly dehydrate and become disoriented. You stumble around, slipping in wet puddles. You remember dancing lights and spinning rooms. You stumble into a cold room and pass out...<br/>---<br/>")
MoveObject (Xanadu, Prison Cell)
DecreaseHealth (10)
SetObjectFlagOn (Xanadu, "healthy")
}
}
}
]]></script>
</turnscript>


ROOM THAT IS UNLOCKED AFTER SETTING "UNCLEAN FLAG" ON FAR STALL:
  <object name="Corner Hallway3">
<inherit name="editor_room" />
<description>This section of the hallway joins the east-west running hallway with a north-south hallway. There is an older looking door to your north. Above the door is a sign.</description>
<alias><![CDATA[<b><u>Corner Hallway</b></u>]]></alias>
<exit alias="northwest" to="Corner Hallway2">
<inherit name="northwestdirection" />
</exit>
<exit alias="east" to="Long Hallway1">
<inherit name="eastdirection" />
</exit>
<exit name="JCLock" alias="north" to="Janitorial Closet">
<inherit name="northdirection" />
<locked />
<lockmessage>This is the only door you have seen so far that looks like a normal locked door. There is no fob keypad here, just a doorknob with a place for a key in the middle. It sounds like someone is on the other side of the door. You probably should leave it alone for now.</lockmessage>
</exit>
<object name="sign7">
<inherit name="editor_object" />
<look>It's a sign. You should read it.</look>
<takemsg>No need to take the sign. Just read it.</takemsg>
<alias>sign</alias>
<read type="script">
msg ("The sign is handwritten and fixed above the door.")
picture ("janitors sign.jpg")
</read>
</object>
<object name="older door">
<inherit name="editor_object" />
<feature_usegive />
<look type="script">
if (not GetBoolean(farthest stall, "unclean")) {
msg ("This older looking door is shut and locked. There is a doorknob with a keyhole in it and a small window in the middle of the door.")
}
else {
msg ("The door is slightly ajar. Whoever was in here moments ago, must have been failed to shut the door completely is their haste to leave.")
}
</look>
<useon type="scriptdictionary">
<item key="key fob E"><![CDATA[
msg ("You're not sure what to expect, but you wave an <i>electronic fob</i> in front of a <i>non-electronic</i> locked door knob. As expected (or not...), nothing spectacular happens. Looks like you'll need a good old fashioned key to get in here?")
]]></item>
</useon>
</object>
<command name="look through window">
<pattern>look through window; look into window</pattern>
<script>
if (GetBoolean(farthest stall, "unclean")) {
msg ("You look through the window into a dark room filled with cleaning supplies. It doesn't appear that anyone is in this room right now.")
}
else {
msg ("You peek through the window into a dark room. It's hard to see much, but it looks to be a room filled with an assortment of cleaning supplies. You also see a man currently turned away from you tending to the shelves on the opposite wall. He appears to be enjoying his job as he is wearing big headphones and bee-bopping to whatever music is issuing from them.")
}
</script>
</command>
<object name="small window">
<inherit name="editor_object" />
<visible />
<look>Just a small window. Try looking through it?</look>
<scenery />
</object>
<command name="knock on door">
<pattern>knock; knock on door; knock on older door</pattern>
<script>
if (GetBoolean(farthest stall, "unclean")) {
msg ("You knock on the door, but no one is in the room to hear your knock.")
}
else {
msg ("He's a janitor, right? Even if he is a Dingo, how tough can he be? You steel yourself and knock on the door. There is no response. You knock louder. Hmmm... Nothing. He's probably got his headphones cranked up so loud that he can't even hear you knocking. No worries though. Probably not worth getting his attention anyway.")
}



Thanks for your help. Again - you all are awesome!

XanMag

jaynabonne
sick2 runs as soon as sick1 kicks it off. It sets a turn timeout. You can't stop a turn timeout once you kick if off, even if you disable sick2. You should have a count in sick2, and take effect when it reaches the desired value. That way if you disable the turn scripts, then all comes to a halt.

XanMag
I've got some tinkering to do when I get home, but I guess I'm still a bit unsure what it takes to execute that. When you say "You should have a count in sick2, and take effect when it reaches the desired value", I'm not really sure what that would look like (actually I interpret what I have as that!!).

I figured by having the 'If object player does not have healthy flag'(which gets flagged after using toilet), that the code would run the 'Else' script and not the 'Then' script. I guess I don't get it but stinker-tinker I shall.

Sorry for making this more difficult than it most certainly is. And a perpetual thank you...

XanMag

HegemonKhan
'tick counter', concept:

x=0
x=x+1 (it doesn't have to be 1, it can be any value, and for that matter, it doesn't have to be a ' + ' ~ addition, it can be any such OPERATOR~operation)

at (if x=5), do script(s)1
at (if x=10), do script(s)2

x=0
x=(0)+1=1
x=(1)+1=2
x=(2)+1=3
x=(3)+1=4
x=(4)+1=5 ---> script(s)1
x=(5)+1=6
x=(6)+1=7
x=(7)+1=8
x=(8)+1=9
x=(9)+1=10 ----> script(s)2

<game name="xxx">
<attr name="x" type="int">0</attr>
</game>

<turnscript name="turnscript1">
<enabled>
<script>
if (game.x = 5) {
msg ("hi")
game.x=game.x+1
} else if (game.x = 10) {
msg ("bye")
game.x = 0
} else {
game.x=game.x+1
}
</script>
</turnscript>

jaynabonne
First, a minor note. In your "Game Script", you have this line

SetObjectFlagOn (Xanadu, "healthy")

followed somewhat further down by

if (GetBoolean(Xanadu, "healthy")) {
DisableTurnScript (sick1)
DisableTurnScript (sick2)
DisableTurnScript (sick3)
DisableTurnScript (sick4)
}

Since in that script, you're setting the "healthy" flag, the "if" will always be true. So technically you don't need it.

As far as what your code is doing, let's do a walkthrough.

1) The player eats the food. In that script, you set "healthy" to false and then enable "sick1".
2) When "sick1" runs after the turn, it will see that "healthy" is not set. It will then enable the other turn scripts and start a "SetTimeout". It will also disable itself. (This all implies that the "else" will never be taken, as "sick1" is only ever enabled when "healthy" is false and then immediately turns itself back off. The same goes for the other turn scripts - they will only ever run if not "healthy", and will then disable themselves right away. So your "else" branches will never ever be taken.)
3) When "sick2" eventually runs, "healthy" is still not set. So it sets a turn timeout for 5 turns in the future and then disables itself.
4) Likewise, "sick3" and "sick4" will also see "healthy" is not set, set their turn timeouts and re-disabled themselves.

At this point, you have four turn timeouts in play and no turn scripts running. There is no way to stop the turn timeouts. So even if you make it to the toilet, there is no code you could execute that will make the turn timeout not fire. That's where your problem lies. What you *could* do is to put another check in the turn timeout to see if the player is still not healthy. Depending on whether or not the turn timeouts will all expire before you can eat the bad food again, that might work. (If the player could make it to the toilet and then back and eat food again before the longest turn timeout expires, then you could end up with the old timeout triggering prematurely on the new unhealthy state).

The code HK posts is along the lines of what I was suggesting (but actually has a fatal flaw which he might realize later - hint: what happens when game.x reaches 5?). What I would do is not bother with the multiple turn scripts or turn timeouts. I'd just have a single turn script like this (the code assumes that the player will always start out healthy). The turn script can always be enabled as well.

<turnscript name="sickturnscript">
<enabled>
<script>
if (GetBoolean(Xanadu, "healthy")) {
// Healthy, so reset the sick count
Xanadu.sickcount = 0
} else {
// Not healthy. See how sick we are.
if (Xanadu.sickcount = 2) {
msg ("Your mouth, tongue, and throat have this odd, tingling sensation.")
} else if (Xanadu.sickcount = 5) {
msg("the long bit of text that happens at 5")
} else if (Xanadu.sickcount = 8) {
msg("the long bit of text that happens at 8")
} else if (Xanadu.sickcount = 12) {
// all the stuff you want to have happen at 12
}
// We get more and more sick with each turn.
Xanadu.sickcount = Xanadu.sickcount + 1
}
</script>
</turnscript>

HegemonKhan
I see it, whoopsy, laughs. Too quick to just give a sample concept, to notice my mistake in code, lol. (if you didn't give that hint though... I might be trying to see~realize it for a long time, lol)

Good lesson to not put the counter inside of an 'if' Script, laughs.

XanMag
I will try and implement that tonight. I had a really bizarre work around in game 1, and I had that mess stuck in my head. It was some funky reset counter that I used at the beginning of the game. Anyway... Hopefully y'all won't hear from me again for a while. No offense! TS's seem to make my brain go bad.

Thank you both a ton.

XanMag
Okay... I'm seriously considering hiring someone as a permanent turn script author... :shock:

I have another turn script that I am having issues with and I think it is very similar coding to the problem I had earlier in this thread. So, I decided to use that solution as a template for writing this turn script. Lo and behold... I am having trouble getting it to fire... again. I know you all are probably rolling your eyes at me for this because it SEEMS like a simple script to correctly write, but... alas, here I am again... and again... So, any help would be greatly appreciated.

Xanadu enters shower for first time and:
SetObjectFlagOn (Xanadu, "trapped")
msg ("<br/><b>Just as you enter the shower and close the curtain, you hear a door slam shut in the locker room. Someone has just entered the room!!</b>")
play sound ("80929__bennstir__door-slam-2.wav", false, false)
LockExit (showerlock)

This happens. So far so good...

Xanadu 'listens to conversation':
msg ("\"I'm telling you... that Dingo is scary.\"  The voice lowers to a whisper and continues, \"Rumor has it, he is the one poisoned the water supply.  Trying to make us immune for the big plans he has.\"<br/><br/>A second voice responds.  \"It's scary, but also respectable.  That guy knows how to scare folks into obedience.  He's gotten my attention for sure.\"  <br/><br/>\"Agreed,\" voice one responds, \"but it's not just us being obedient.  I, for one, believe in his cause.  Our cause, brother.\"<br/><br/>The voices fade to a murmur and you can hear lockers opening.<br/>")
EnableTurnScript (showerconvo)


And that is where it stops functioning properly. The problem is, I think, not getting the turn script 'showerconvo' started. Here is the code I intend to use.

if (GetBoolean(Xanadu, "trapped")) {
Xanadu.showercount = 0
}
else {
if (Xanadu.showercount = 1) {
msg ("<br/>As you struggle to think of a way to get out of this mess... the voices return...a little louder.<br/><br/>\"...area, over by the weights. I overheard a group of seven or eight whispering. They hushed up when they noticed me coming.\"<br/><br/>The second man responds. \"But what did you hear? You get any thing? Dingo is expecting us to report soon.\"<br/><br/>\"Well,\" the voice trails to a whisper again, \"I'm pretty sure... this whole Long John Silver thing going on...\" The voice fades out.<br/><br/>The second voice is still mostly a hush, \"...probably... coup on his... Dingo will NOT like... guess, the ringleader... you know...\" <br/><br/>\"Uh-huh... Mongo... influential for sure... like that?\"<br/><br/>The response is louder and clearer this time, \"I'm okay with blowing the whistle on that guy. Never like him anyway.\"<br/><br/>\"Okay. Deal.\" The voices are getting louder and you can hear footsteps that sound like they are headed your way. \"Let's get showered and we'll go report to Dingo.\"")
}
else if (Xanadu.showercount = 2) {
msg ("<br/>\"Ugh,\" you hear the other voice issue a protest. \"I guess you're right.\"<br/>")
}
else if (Xanadu.showercount = 3) {
msg ("Now is the time to think of some clever way to avoid being detected...<br/>")
}
else if (Xanadu.showercount = 4) {
msg ("One set of footsteps fades away to the right and the other draws closer to your own shower.<br/>")
}
else if (Xanadu.showercount = 5) {
msg ("You see the gnarly knuckles of a dark-skinned, hairy hand grab the curtain in preparation of it being thrown open.<br/>")
}
else if (Xanadu.showercount = 6) {
msg ("The curtain is thrown open and before you stands a very large, very hairy, and very naked mountain of a man. He gasps and takes a step backward in surprise, but his look of shock quickly turns to one of lust and ferocity. Soon, you are being blasted with large fists, massive feet, and other unmentionable anatomical enormities. <br/><br/>Unfortunately, this painful ass pummeling you have received has ended your life. Better luck next time.")
finish
}
else {
if (GetBoolean(farthest shower, "water running")) {
msg ("You see the gnarly knuckles of a dark-skinned, hairy hand grab the curtain in preparation of it being thrown open.<br/>")
wait {
msg ("\"OH!! So, sorry!\" The loud voice exclaims. \"Didn't realize someone was in there.\" You sigh in relief as the hand disappears and the footsteps fade away, apparently on their way to find an unoccupied stall.<br/><br/>\"And don't drop the soap in there, cutie...\" Your sigh ends in an unpleasant shiver as the man cackles at his own bad joke.<br/>")
play sound ("laugh man.mp3", false, false)
UnlockExit (showerlock)
SetObjectFlagOff (Xanadu, "trapped")
}
}
}
}


and here is the code I have to get the "water running"
if (GetBoolean(Xanadu, "trapped")) {
msg ("You lift the lever and the water rushes out and slaps noisily against the drain and tiles. Hopefully this is obvious enough to those thugs outside that this shower is occupied.")
SetObjectFlagOn (lever2, "water running")
}
else {
msg ("You lift the lever and you hear a clank in the pipes followed by a rush of water from them. The water slaps noisily against the tiles and drain. You turn it off immediately, as you don't really need to take a shower right now.")
}


Sorry for mucking this up again! Any help is appreciated! Thanks in advance.

The Pixie
Put a command to print something like "This is running" at the very start of your script, then try it again. If it shows "This is running" each turn, you know the script starts, and the issue is the logic in the script. If it does not, you know the turn script is not being turned on.

When does Xanadu.showercount get changed?

jaynabonne
The first thing I would do is put a big fat msg at the top of the turn script, something like "TURN SCRIPT FIRED". If you don't even see that, then you know you have a problem elsewhere. If you do see that, then try putting msg's in at various places to work out the path the code is taking through the turn script. (Edit: just saw The Pixie's. :) )

Does it matter that you set "water running" on "lever2" but check for it on "farthest shower"?

But for your first turn script, if "trapped" is true, it sets showercount to 0 and does nothing else. If "trapped" is not true, then if the showercount is not 1-6 and "water running" is not set on "farthest shower", then it does nothing.

XanMag
*SEE EDIT AT BOTTOM FIRST!* Thanks!

I don't get it. I switched things up a bit to better match my previous script that worked (which Jay helped me on).

I enter the farthest shower and I run this code upon first entering.
SetObjectFlagOff (Xanadu, "freetomove")

I set the flag 'freetomove' in the game script at start.

I then require the player to type 'listen to men', 'listen' etc, which enables 'showerconvo' turnscript and it starts...
if (not GetBoolean(Xanadu, "freetomove")) {
Xanadu.showercount = 0
msg ("THE SCRIPT IS FVCKING RUNNING!!")
}

because my message runs.

But this never fires...
else {
if (Xanadu.showercount = 1) {
msg ("blah blah blah.")
}


Now, it seems obvious that showercount never increases. I looked in my previous code and tried to find a spot where I had a code that increased my sickcount by one with each turn the player took but couldn't find one. So, I assume it is there but I couldn't find it. I need to increase the turn counter (showercount) by one with each turn the player takes. I'm guessing, but I think there is no showercount (attribute? turn counter?) to increase and that I need to have coded that somewhere once I have entered the farthest shower. In short, I think Pixie's question (when does xanadu.showercount get changed?) has something to do with this not firing?

Also, the lever and far shower check is a mistake (lol) but I haven't gotten my script that far to have noticed it. It has been corrected. Thanks in advance... again... =(

*EDIT* When I play the game in this state, I get "THE SCRIPT IS FVCKING RUNNING!!" after every turn, which means I am always running the 'If' part and never the 'Else' part, so I switched the 'If' to this:
if (GetBoolean(Xanadu, "freetomove")) {
Xanadu.showercount = 0
msg ("THE SCRIPT IS FVCKING RUNNING!!")


and then I get this message... Error running script: Error compiling expression 'Xanadu.showercount = 1': CompareElement: Operation 'Equal' is not defined for types 'Object' and 'Int32'

So, I think my previous assumption is correct... I don't have a showercount turn counter, but how do I establish that? Thanks again!

jaynabonne
You need to initialise showercount to 0 somewhere. The fact that you're getting that error message means that Xanadu.showercount is not defined.

As far as incrementing the shower count, generally you need to put a line like this somewhere:

Xanadu.showercount = Xanadu.showercount+1

probably somewhere in the turn script.

XanMag
I went ahead and threw this bit of code at the top of my 'showerconvo' turn script:

Xanadu.showercount = Xanadu.showercount+1
if (GetBoolean(Xanadu, "freetomove")) {
Xanadu.showercount = 0
msg ("RUNNING SCRIPT IF")
}
else {
if (Xanadu.showercount = 1) {
msg ("blah blah blah")
}


and I get the following message once I 'listen' (which start the script running):

Error running script: Error compiling expression 'Xanadu.showercount+1': ArithmeticElement: Operation 'Add' is not defined for types 'Object' and 'Int32'

EDIT**: I copy-pasted my code from my sickcount into a text box in word and I copy-pasted my code for showercount in a text box. I set them side-by-side and made the code IDENTICAL (other than the printed messages) and I get this as a response immediately when entering the farthest shower: Error running script: Error compiling expression 'Xanadu.showercount = 1': CompareElement: Operation 'Equal' is not defined for types 'Object' and 'Int32'

That means that there is an error when I unset the 'freetomove' flag. Suggestions/solutions please! =/

Thanks.

HegemonKhan
for your turn script, have your 'Xanadu.showercount = Xanadu.showercount + 1' at the bottom (and not indented at all, nor within any other script~code block: not inside an 'if~whatever' script):

if (GetBoolean(Xanadu, "freetomove")) {
Xanadu.showercount = 0
msg ("RUNNING SCRIPT IF")
}
else {
if (Xanadu.showercount = 1) {
msg ("blah blah blah")
}
}
Xanadu.showercount = Xanadu.showercount+1


the reason it is good to put the 'increaser' (or any other such 'state~game state' Attribute) at the end of your main global turnscript, is because it eliminates any possibility of it increasing before your script can act upon that prior~lower value, and thus prevent that script from ever firing~activating~running, which you don't want. Think of it as the last thing to happen, thus in effect, it's like it happens AFTER your turn is over, but before your next turn starts.

-----------------

for your initial setting of your 'Xanadu.showercount', it should be added~created within your 'Xanadu' Object:

<object name="Xanadu">
// blah code lines
<attr name="showercount" type="int">0</attr>
// blah code lines
</object>


--------

I'd recommend not using caps at all (such as with your 'Xanadu' Object), unless you're really rigorous in paying attention to caps (upper case) vs lower case usage ...

XanMag
I SOLVED IT, I SOLVED IT!! Very excited at the prospect of NOT using turn scripts for the remainder of this game!!

Hopefully this thread will remain dormant for quite some time now! And... with school almost over, this game is slated for release within a month's time! WOO-HOO!!

Thanks again for all your help!

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums