Author Topic: How does Continue() mess up variable storing?  (Read 3893 times)

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6253
  • Gender: Female
  • The perfect moment is now.
How does Continue() mess up variable storing?
« on: August 16, 2007, 01:58:42 PM »
aVENGER mentioned in Xan forum that Continue() can sometimes mess up variable storing. Since some of Xan's blocks use Continue(), and so do some other mods, I believe, I am naturally very curious to know how, why, when, and so on. Please, feel free to tell the public(and me) everything we need to know about this matter.

Offline jcompton

  • Niche Exploiter
  • Administrator
  • Planewalker
  • *****
  • Posts: 7246
Re: How does Continue() mess up variable storing?
« Reply #1 on: August 16, 2007, 02:06:58 PM »
I think in part it's one of those things lost to the mists of time. It's been "well-known"/conventional wisdom that Continue Does Bad Stuff, so nobody really pushes the envelope and tries messing around with it very much.
Cespenar says, "Kelsey and friends be at the Pocket Plane? Ohhh yesssss!" http://www.pocketplane.net

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6253
  • Gender: Female
  • The perfect moment is now.
Re: How does Continue() mess up variable storing?
« Reply #2 on: August 16, 2007, 02:16:47 PM »
Ah, okay then. "So sayeth Jason" is normally enough for me - I'm just worried that, should I avoid Continue() and use EXTEND_BOTTOM for spawning Xan/quest characters instead, some other modder will append blocks to area files that will always read True(), and thus break my mod. That's pretty much the only reason for my EXTEND_TOP's, and I rather wonder how valid it is.

(SConrad also has been pretty insistent about using EXTEND_TOP, so I was kinda wondering if there was something that BIG MODDARZ were not telling us - a cromspiracy or something).

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: How does Continue() mess up variable storing?
« Reply #3 on: August 16, 2007, 02:19:37 PM »
There are a bunch of older posts on this on most forums, but the replicable behavior is that use of Continue() in AI scripting.

Yovanoveth and Cirreck both have a discussion on it somewhere, about localized AI scripting having problems because Continue() appeared to lock the initial variable setting block into collecting actions until the end of the sequence of Continue()s but not setting the variables, resulting in blocks looping (so the actions were aded but the variables were not set to stop the new loop, I think. It has been several months, so I am a little fuzzy). In addition there is an older King Diamond post at SHS.

I think this is one of those areas where testing to replicate Cirreck's tests and KD's tets might make sense.

Offline SimDing0™

  • Back In Black
  • Global Moderator
  • Planewalker
  • *****
  • Posts: 3496
  • Gender: Male
  • Word Enhancer
Re: How does Continue() mess up variable storing?
« Reply #4 on: August 16, 2007, 02:23:21 PM »
If you set a variable and Continue(), you cannot guarantee that the variable will be correctly set until the start of the next script cycle.

Offline berelinde

  • Planewalker
  • *****
  • Posts: 1188
  • Gender: Female
    • Gavin, cleric of Lathander, for Tutu
Re: How does Continue() mess up variable storing?
« Reply #5 on: August 16, 2007, 02:29:08 PM »
Kind of like setting a variable in CHAIN, then checking for that variable inside the same CHAIN? None of it happens until the end?

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6253
  • Gender: Female
  • The perfect moment is now.
Re: How does Continue() mess up variable storing?
« Reply #6 on: August 16, 2007, 02:30:01 PM »
Quote
If you set a variable and Continue(), you cannot guarantee that the variable will be correctly set until the start of the next script cycle.

So it influences only the variable in the block I add - and as I do not care whether my variable is set within the round or not, it's fine with me. Hmm.

Offline devSin

  • Planewalker
  • *****
  • Posts: 1632
  • Gender: Male
Re: How does Continue() mess up variable storing?
« Reply #7 on: August 16, 2007, 06:52:15 PM »
The way it should work is that all triggers are processed in a Continue() "chain" before any actions. So you can SetGlobal("A","GLOBAL",1) Continue(), but be aware that for any triggers checked while the script is Continue()ing, the global won't be set yet.
Code: [Select]
IF
Global("MyVar","GLOBAL",0)
THEN
RESPONSE #100
DisplayStringHead(Myself,1)
SetGlobal("MyVar","GLOBAL",1)
Continue()
END

IF
Global("MyVar","GLOBAL",1)
THEN
RESPONSE #100
DisplayStringHead(Myself,2)
SetGlobal("MyVar","GLOBAL",2)
END

IF
!Global("MyVar","GLOBAL",2)
THEN
RESPONSE #100
DisplayStringHead(Myself,3)
SetGlobal("MyVar","GLOBAL",2)
END
With that code, the expected behavior is that you see String 1 followed by String 3. You shouldn't ever see String 2 (when that trigger is first checked -- because of the Continue() -- MyVar is still 0).

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6253
  • Gender: Female
  • The perfect moment is now.
Re: How does Continue() mess up variable storing?
« Reply #8 on: August 17, 2007, 12:44:55 AM »
A very good example. Thank you very much, everyone. I really like this topic - now, at least, I understand clearly.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: