Post new topic    
Liquid Metal Slime
Send private message
Script Executing Prematurely? 
 PostWed Aug 10, 2011 9:22 pm
Send private message Reply with quote
I have a script that shows a menu and an animated backdrop behind it. When you select one particular option, it goes to another script; which shows a text box that has a choice conditional.

For some reason when you select that menu option that goes to the text box, it automatically plays the ambient music of the map you teleport to by selecting the "no" option (otherwise the ELSE section in the second script) before you even make a choice.

This leads me to believe that the tag that is supposed to be checked is getting checked prematurely and already teleporting you to the map as if you chose the NO option from the text box; which is pretty annoying. I'm sure it's a simple fix, but I can't seem to figure it out. I feel pretty certain that it has to do with the loop in the BACKDROP script because everything worked fine until I created that.

Sorry if the code is a little messy or not clean. The SEQUENCE script in particular is from 2007, so I'm sure it could be simplified nowadays.

Here's the menu/backdrop script:

Code:
script, backdrop, begin
   play song (28)
   open menu (3,false)
   while (checktag (tag:backdrop loop) == off) do (
      show backdrop (45)
      wait (5)
      show backdrop (46)
      wait (5)
   )
   show map
end


This is the script that is called from the menu option in question:

Code:
script, sequence, begin
  stop song
  suspendplayer
  showtextbox (76)
  wait for all
  show map
  if (checktag (tag:Intro) == 1) then (
    suspendboxadvance
    fadescreenout (0, 0, 0)
    teleporttomap (map:Burg Intro, 0, 0)
    waitforall
    fadescreenin
    focuscamera (8, 13, 2)
    waitforcamera
    focuscamera (18, 21, 2)
    showtextbox (1)
    wait (80)
    advancetextbox
    waitforcamera
    focuscamera (18, 31, 2)
    waitforcamera
    focuscamera (32, 31, 2)
    showtextbox (2)
    wait (80)
    advancetextbox
    waitforcamera
    focuscamera (40, 40, 2)
    waitforcamera
    focuscamera (49, 12, 2)
    settag (235, on)
    showtextbox (3)
    wait (80)
    advancetextbox
    waitforcamera
    fadescreenout (0, 0, 0)
    camerafollowshero (me)
    teleporttomap (map:Burg Castle Intro, 4, 4)
    waitforcamera
    fadescreenin
    waitforall
    focuscamera (25, 21, 2)
    showtextbox (4)
    wait (80)
    advancetextbox
    waitforcamera
    wait (100)
    tweakpalette (-10, -10, -10, 0, 255)
    updatepalette
    playsound (sfx:Quake, false, false)
    pancamera (up, 3, 25)
    waitforcamera
    pancamera (down, 3, 25)
    waitforcamera
    pancamera (up, 3, 25)
    waitforcamera
    pancamera (down, 3, 25)
    waitforcamera
    pancamera (up, 3, 25)
    waitforcamera
    pancamera (down, 3, 25)
    waitforcamera
    pancamera (up, 3, 25)
    waitforcamera
    pancamera (down, 3, 25)
    waitforcamera
    fadescreenout (0, 0, 0)
    waitforall
    camerafollowshero (me)
    teleporttomap (map:World Map Intro, 8, 11)
    waitforcamera
    stopsound (sfx:Quake)
    waitforall
    fadescreenin
    playsound (sfx:Quake, false, false)
    pancamera (up, 3, 25)
    waitforcamera
    pancamera (down, 3, 25)
    waitforcamera
    pancamera (up, 3, 25)
    waitforcamera
    pancamera (down, 3, 25)
    waitforcamera
    pancamera (up, 3, 25)
    waitforcamera
    pancamera (down, 3, 25)
    waitforcamera
    pancamera (up, 3, 25)
    waitforcamera
    pancamera (down, 3, 25)
    waitforcamera
    pancamera (up, 3, 25)
    waitforcamera
    pancamera (down, 3, 25)
    waitforcamera
    pancamera (up, 3, 25)
    waitforcamera
    pancamera (down, 3, 25)
    waitforcamera
    pancamera (up, 3, 25)
    waitforcamera
    pancamera (down, 3, 25)
    waitforcamera
    pancamera (up, 3, 25)
    waitforcamera
    pancamera (down, 3, 25)
    waitforcamera
    focuscamera (8, 21, 2)
    waitforcamera
    focuscamera (8, 35, 5)
    waitforcamera
    focuscamera (8, 46, 10)
    waitforcamera
    focuscamera (8, 72, 15)
    wait (50)
    suspendnpcs
    fadescreenout (0, 0, 0)
    camerafollowshero (me)
    teleporttomap (map:Larry Intro, 10, 0)
    setnpcdirection (1, 3)
    waitforall
    fadescreenin
    wait (80)
    setnpcdirection (1, 2)
    wait (80)
    walknpc (1, down, 12)
    focuscamera (17, 14, 2)
    waitfornpc (1)
   destroy npc (1)
    waitforall
   wait (30)
    fadescreenout (0, 0, 0)
    camerafollowshero (me)
    teleporttomap (map:Shore Intro, 8, 65)
    waitforall
    fadescreenin
    waitforall
    focuscamera (8, 9, 2)
    showtextbox (361)
    wait (80)
    advancetextbox
    waitforcamera
    wait (325)
    waitforall
    walknpc (2, right, 8)
    waitfornpc (2)
    walknpc (2, down, 6)
    waitfornpc (2)
    setnpcdirection (2, 1)
    waitfornpc (2)
    wait (15)
    setnpcdirection (2, 3)
    waitfornpc (2)
    wait (15)
    setnpcdirection (2, 1)
    waitfornpc (2)
    wait (15)
    setnpcdirection (2, 3)
    waitfornpc (2)
    wait (15)
    setnpcdirection (2, 2)
    waitfornpc (2)
    wait (15)
    walknpc (2, down, 3)
    waitfornpc (2)
    wait (15)
    alterNPC (2, NPCstat:picture, 20)
    suspendobstruction
    setnpcspeed (2, 1)
    setnpcspeed (1, 1)
    wait (30)
    walknpc (2, up, 9)
    wait (1)
    walknpc (1, up, 9)
    waitforall
    fadescreenout (0, 0, 0)
    teleporttomap (map:Derf Interior, 7, 6)
    stopsong
    setheroposition (0, 1, 4)
    camerafollowshero (me)
    setheropicture (0, 22, outside battle)
    setheropalette (0, 15, outside battle)
    setherodirection (me, down)
    waitforhero (me)
    alterNPC (2, NPCstat:picture, 19)
    waitfornpc (2)
    waitforall
    resetpalette
    updatepalette
    fadescreenin
    walknpc (2, right, 3)
    waitfornpc (2)
    walknpc (2, up, 1)
    waitfornpc (2)
    wait (30)
    fadescreenout (0, 0, 0)
    alterNPC (2, NPCstat:picture, 23)
    setNPCposition (2, 9, 4)
    setnpcdirection (2, 0)
    setherospeed (0, 2)
    resumeobstruction
    waitforall
    stopsong
    wait (80)
    fadescreenin
    wait (15)
    playsound (sfx:Mine, false, false)
    setnpcdirection (2, 2)
    waitfornpc (2)
    wait (15)
    setnpcdirection (2, 0)
    waitfornpc (2)
    wait (17)
    playsound (sfx:Mine, false, false)
    setnpcdirection (2, 2)
    waitfornpc (2)
    wait (17)
    setnpcdirection (2, 0)
    waitfornpc (2)
    wait (17)
    playsound (sfx:Mine, false, false)
    setnpcdirection (2, 2)
    waitfornpc (2)
    wait (17)
    setnpcdirection (2, 0)
    waitfornpc (2)
    wait (17)
    playsound (sfx:Mine, false, false)
    setnpcdirection (2, 2)
    waitfornpc (2)
    wait (13)
    setnpcdirection (2, 0)
    waitfornpc (2)
    wait (17)
    fadescreenout (0, 0, 0)
    alterNPC (2, NPCstat:picture, 19)
    setNPCposition (2, 3, 6)
    setnpcdirection (2, 3)
    resumeboxadvance
    waitforall
    wait (80)
    fadescreenin
    playsong (song:Derf)
    wait (100)
    setherodirection (me, right)
    waitforhero (me)
    wait (30)
    setherodirection (me, down)
    waitforhero (me)
    wait (15)
    setherodirection (me, right)
    waitforhero (me)
    wait (50)
    setherodirection (me, down)
    waitforhero (me)
    wait (50)
    setherodirection (me, up)
    waitforhero (me)
    wait (30)
    setnpcdirection (2, 0)
    waitfornpc (2)
    wait (30)
    showtextbox (5)
    waitfortextbox
    walknpc (2, up, 1)
    waitfornpc (2)
    walknpc (2, left, 1)
    waitfornpc (2)
    walknpc (2, up, 1)
    waitfornpc (2)
    setnpcdirection (2, 3)
    waitfornpc (2)
    showtextbox (6)
    waitfortextbox
    setherodirection (me, right)
    waitforhero (me)
    wait (5)
    setherodirection (me, up)
    waitforhero (me)
    wait (5)
    setherodirection (me, right)
    waitforhero (me)
    wait (5)
    setherodirection (me, up)
    waitforhero (me)
    wait (5)
    setherodirection (me, right)
    waitforhero (me)
    wait (5)
    setherodirection (me, up)
    waitforhero (me)
    wait (5)
    showtextbox (8)
    waitfortextbox
    walknpc (2, down, 1)
    waitfornpc (2)
    walknpc (2, right, 4)
    waitfornpc (2)
    setnpcdirection (2, 3)
    waitfornpc (2)
    showtextbox (9)
    waitfortextbox
    walknpc (2, left, 1)
    waitfornpc (2)
    walknpc (2, up, 1)
    waitfornpc (2)
    showtextbox (13)
    waitfortextbox
    setnpcdirection (2, 3)
    waitfornpc (2)
    wait (15)
    setnpcdirection (2, 2)
    waitfornpc (2)
    wait (15)
    showtextbox (14)
    waitfortextbox
    suspendherowalls
    setheropicture (0, 11, outside battle)
    walkhero (me, right, 1)
    waitforhero (me)
    walkhero (me, down, 1)
    waitforhero (me)
    walkhero (me, right, 1)
    waitforhero (me)
    showtextbox (15)
    waitfortextbox
    setherodirection (me, down)
    waitforhero (me)
    setheropicture (0, 43, outside battle)
    wait (15)
    showtextbox (17)
    waitfortextbox
    wait (65)
    showtextbox (189)
    waitfortextbox
    walknpc (2, down, 1)
    waitfornpc (2)
    walknpc (2, left, 1)
    waitfornpc (2)
    setheropicture (0, 11, outside battle)
    setherodirection (me, right)
    waitforhero (me)
    wait (30)
    showtextbox (190)
    waitfortextbox
    walknpc (2, right, 1)
    waitfornpc (2)
    setnpcdirection (2, 3)
    waitfornpc (2)
    showtextbox (18)
    waitfortextbox
    fadescreenout (0, 0, 0)
    stopsong
    playsong (song:Sleep)
    setheroposition (0, 2, 4)
    waitforhero (me)
    setherodirection (me, down)
    setNPCposition (2, 3, 6)
    wait (75)
    waitfornpc (2)
    waitforall
    fadescreenin
    stopsong
    playsong (song:Derf)
    wait (25)
    setnpcdirection (2, 0)
    waitfornpc (2)
    showtextbox (21)
    waitfortextbox
    walkhero (me, down, 1)
    waitforhero (me)
    walkhero (me, right, 1)
    waitforhero (me)
    setherodirection (me, down)
    waitforhero (me)
    showtextbox (22)
    waitfortextbox
    forceequip (0, slot:Chest, item:Brigand)
    forceequip (0, slot:Arms, item:Chain)
    forceequip (0, slot:Legs, item:Chain 2)
   forceequip (0, slot:Weapon, item:Epee)
    getitem (item:Ribeye, 2)
    getitem (item:Grape, 2)
    getitem (item:Fabric, 1)
    setherospeed (0, 4)
   )
else (
    forceequip (0, slot:Chest, item:Brigand)
    forceequip (0, slot:Arms, item:Chain)
    forceequip (0, slot:Legs, item:Chain 2)
   forceequip (0, slot:Weapon, item:Epee)
    getitem (item:Ribeye, 2)
    getitem (item:Grape, 2)
    getitem (item:Fabric, 1)
    setherospeed (0, 4)
    setheropicture (0, 11, outside battle)
    setheropalette (0, 15, outside battle)
    teleporttomap (map:Derf Interior, 7, 6)
   )
  waitforall
  resumenpcs
  resumeplayer
  resumeherowalls
  resumeobstruction
end


Any help on this would be much appreciated.
Cornbread Chemist
Liquid Metal King Slime
Send private message
 
 PostWed Aug 10, 2011 10:29 pm
Send private message Reply with quote
Your script does not work because of the "wait for all" command.

"Wait for all" has been broken forever. When I first implemented it back in the QuickBasic days, it was broken then, and was not fixed until July 6 of this year, when tmc noticed what was wrong with it. wait for all works reliably in nightly builds, and it will work fine in the future Alectormancy stable release.

Apparently very few people use the command, because nobody ever reported the problem (although I do remember a few people complaining that the command seemed "messed up" without details)

Anyway, the main problem here is that "wait for all" is NOT intended to wait for text boxes. The following is wrong:

Code:

  showtextbox (76)
  wait for all


Even after tmc's fixes in the nightly builds, this would not actually wait for the text box.

I'll update the documentation for the "wait for all" command to make this clearer.
Metal Slime
Send private message
 
 PostThu Aug 11, 2011 4:46 am
Send private message Reply with quote
I've always assume that "wait for all" problems were conceptual errors on my end and not errors with the command.
Liquid Metal Slime
Send private message
 
 PostThu Aug 11, 2011 1:04 pm
Send private message Reply with quote
That seems to have fixed it; thanks for the help!
Cornbread Chemist
Liquid Metal King Slime
Send private message
 
 PostThu Aug 11, 2011 4:00 pm
Send private message Reply with quote
Mystic wrote:
I've always assume that "wait for all" problems were conceptual errors on my end and not errors with the command.


Nope! It is the command that was crazy, not you ;)

Meatballsub wrote:
That seems to have fixed it; thanks for the help!


Excellent! :)
Liquid Metal Slime
Send private message
 
 PostFri Aug 12, 2011 10:00 pm
Send private message Reply with quote
I thought it was fixed but I'm still having an issue where the backdrop will show up for a split second right after the first textbox in the SEQUENCE script. I've tried about all I know today to fix it but to no avail. It only happens sometimes, not all the time...
Cornbread Chemist
Metal Slime
Send private message
 
 PostFri Aug 12, 2011 11:39 pm
Send private message Reply with quote
This is just a hunch:

Could it be that your backdrop script is being interrupted by the text box in the middle of its two backdrops? As in, somehow the following is occurring:

1. backdrop script is called
2. backdrop script shows backdrop 45
3. while backdrop script is waiting, that's when the tag is changed
4. backdrop script shows 46 before checking to see if it should continue running the while loop

This would explain why it only seems to happen sometimes - it only happens if you happen to catch the tag during the 5 tick wait between backdrops 45 and 46. You could avoid this problem (if it IS the problem) by altering your backdrop script like so:
Code:
   while (checktag (tag:backdrop loop) == off) do (
      show backdrop (45)
      wait (5)
      if(checktag (tag:backdrop loop) == off) then (show backdrop (46))
      wait (5)


See if this takes care of it (although I suppose it will be difficult to test, if it was only happening some of the time).
I am Srime
Metal King Slime
Send private message
 
 PostSat Aug 13, 2011 11:13 am
Send private message Reply with quote
James Paige wrote:
"Wait for all" has been broken forever. When I first implemented it back in the QuickBasic days, it was broken then, and was not fixed until July 6 of this year


Actually it was fixed on July 6 2010.
Liquid Metal Slime
Send private message
 
 PostMon Aug 15, 2011 1:36 pm
Send private message Reply with quote
Thanks, I've tried your suggestion and it is working so far. I'll report back if I see a hiccup in it.
Cornbread Chemist
Metal Slime
Send private message
 
 PostTue Aug 16, 2011 1:00 am
Send private message Reply with quote
You're welcome. I'm thinking we've solved the problem.
I am Srime
Display posts from previous: