Aller au contenu

Photo

how can I delay a Set Plot Flag?


  • Veuillez vous connecter pour répondre
9 réponses à ce sujet

#1
psiiijay

psiiijay
  • Members
  • 258 messages
That's the Q. I need to Delay the plot flag to stop after some time but you can't do it with delay command... Is there a way? 

#2
psiiijay

psiiijay
  • Members
  • 258 messages
Oooops, Yes you can :)
Sorry!

#3
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
In general, for non-void functions you want to set on delay, you can just use a wrapper function:

void DelaySetPlotFlag(int iPlot) {
SetPlotFlag(iPlot);
}

and then use the wrapper in your main script:

DelayCommand(12.0, DelaySetPlotFlag(FALSE));

#4
psiiijay

psiiijay
  • Members
  • 258 messages
great thanks- but I think that just delaying it normally compiles fine- won't it still work?

#5
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Yeah, but the wrapper is how you deal with other functions that don't compile.

#6
psiiijay

psiiijay
  • Members
  • 258 messages
Btw- for some reason my delaycommand does not work and the wrapper you gave me does not compile.

#7
diophant

diophant
  • Members
  • 116 messages
Lugaids script does not compile because the object of the plot flag is missing. It should be:

void DelaySetPlotFlag(object oTarget, int iPlot) {
SetPlotFlag(oTarget, iPlot);
}

call it by

DelayCommand(12.0, DelaySetPlotFlag(OBJECT_SELF, FALSE));

If it is still not working:
From where do you call the function? If you destroy that object, also all of its delayed function will be canceled. If that is the problem, write a wrapper script "delayedSetPlotFlag" where you call DelayCommand(...), and call this script with ExecuteScript("delayedSetPlotFlag", GetModule()) from your original script.

#8
rjshae

rjshae
  • Members
  • 4 507 messages
That's probably it; a delayed command forgets the calling object.

#9
Tchos

Tchos
  • Members
  • 5 080 messages
So if it works for delayed commands, does that mean it's safe to use ExecuteScript in an OnDeath slot to make sure the entire contents fire when a creature is dying?

#10
diophant

diophant
  • Members
  • 116 messages

Tchos wrote...

So if it works for delayed commands, does that mean it's safe to use ExecuteScript in an OnDeath slot to make sure the entire contents fire when a creature is dying?


Yes, that is safe, although not bullet proof. The problem is if the player saves and reloads. Delayed commands are not stored in the savegame, so never put anything in a delayed command if the failure of its execution is game-breaking.