Difference between revisions of "MessageBox Tutorial"

1,114 bytes added ,  01:12, 15 September 2007
→‎Activator Disadvantages: How to use the Variable-Set-Loaded method
imported>Haama
(→‎Activator Advantages: Added Ob-Cell reset protection info)
imported>Haama
(→‎Activator Disadvantages: How to use the Variable-Set-Loaded method)
Line 254: Line 254:


====Activator Disadvantages====
====Activator Disadvantages====
* They need to be [[Loaded]] to run every frame (more below)
* They need to be [[Loaded]] to run every frame. The easiest way to keep it loaded is to set one of it's own variables every frame. Setting a variable loads an object into memory, as if it were in the same cell as the player. Like this:
* They can run even when not around the player (though only for a single frame, but enough to cause [[:Category:Tidbits#When_do_remote_activators_run.3F|problems]]).
<pre>short Working
* Both require an extra line of coding (which conveniently work together)
...
begin GameMode
...
  set Working to 1
...
</pre>
* Their script can run even when not around the player (though only for a single frame, but enough to cause [[:Category:Tidbits#When_do_remote_activators_run.3F|problems]]). To solve this problem, set a flag variable (for this tutorial, ''Working'') to 1 when the script should be running, and 0 when it should end. Use an '''if''' test to check ''Working'', like so:
<pre>short Working
...
begin onActivate
...
  set Working to 1
end
 
begin GameMode
  if Working
...
  endif
end</pre>
Set Working to 0 when you wish to keep the script from running.
* These solutions work hand in hand. When the script should be running, and Working is 1, set Working to 1 at the end of every frame to keep it loaded for the next frame. When it's 0, don't set any variables and the activator will be unloaded, preventing the script from errantly running. Combining them looks like this:
<pre>short Working
...
begin onActiavte
...
  set Working to 1
end
 
begin GameMode
  if Working
    if (Choosing == 0)
      set Working to 0
      return
    elseif (Choosing == 1)
...
    endif
    set Working to 1
  endif
end</pre>


====Other methods====
====Other methods====
Anonymous user