Difference between revisions of "MessageBox Tutorial"

Jump to navigation Jump to search
116 bytes added ,  13:37, 20 July 2007
imported>Haama
imported>Haama
There are 2 and a half problems with the above script:
 
===Only use GetButtonPressed once===
 
First, [[GetButtonPressed]] only returns the player's decision once. On this section of code
<pre> If (GetButtonPressed > -1)
...</pre>
 
===Running after the player's decision is caught===
 
The half problem – any of your code in the <u>''''';whatever you want to do'''''</u> section will only run for a single frame. This is good enough in most cases, however, if you need to run that section for more than one frame (i.e., waiting for another process to finish) you will have to set up things a bit differently. The reason, extending on the previous reason – [[GetButtonPressed]] will only return the player's decision once, and only for one frame. To fix this, set the variable only when [[GetButtonPressed]] returns '''''-1''''', as such:
<pre>...
...</pre>
 
===Starting the whole thing===
 
The second problem is a bit more drastic – every time the player makes a decision the menu will be displayed again. This problem can be fixed by changing the <u>'''''If (Choosing == 0)'''''</u> test to <u>'''''If (Choosing == -1)'''''</u>, and having a clear start to the script (i.e., [[OnActivate]], [[OnAdd]], etc.) that will <u>'''''set Choosing to -1'''''</u>. There are a few ways to start the script off, but my preferred method is to use a persistent activator. The advantages of a persistent activator:
*There's a clear beginning to it ([[OnActivate]])
*And it's simply easier to manage than a spell (if a spell is really possible at all, I haven't seen one yet)
The only disadvantage is that activators need to be in the same cell as the player (loaded in memory) to run, so you will have to remember to add a few lines to move the activator to the player when starting and away when finished. Of course, with some work, quests and tokens can be made to do the same, but I don't find them quite as easy to set up.
 
 
==Creating Your New Menu==
Anonymous user

Navigation menu