NetStorm Wiki

Editing and making your own campaigns Getting Started,
Advanced Editing 1.Images | 2.Links and E-mails | 3.More [Options] Sections. 4.Options | 5.More [Header] Variables Header Variables | 6.Changing Text Colors | 7.Sacrificing for Knowledge | 8.Branching using MissionBegin | 9.Using denySalvage | 10.Outposts in Your Campaign | 11.Branching with MissionFork | 12.The Tell Command | 13.Creating Menus with $Menu | 14.Formatting Text and Graphics | 15.The $Timeout event | 16.The $OnExit event | 17.adding a DEMO to your Campaign | 18.Re-positioning the Text Window (with $MoveDialog)| 19.Timing with [@ ] | 20.Using the Debug Hotkey | 21.Moving the screen window with $View| 22.Variable basics | 23.IF/THEN Conditionals | 24.The $PlaySound command | 25.Netstorm Command List

view this alone

The $OnExit Event

Exiting, stage left


This event appears to be pretty basic. So what does $OnExit do? Well, just like its name suggests, this will cause something to happen once a $Button event or a $Menu event has been called.

The syntax for $OnExit is very much like the syntax for many of the other Netstorm events ($Button, $Menu):

$OnExit=description,command,command extension

The description is what the player will see inside a button. Note: description is optional. If you don't use it, you still have to have a comma before the command. You should know the Netstorm  commands by heart by now: either MissionBegin, MissionFork, MissionAbort, MissionRestart, MissionReview, MissionEnd, Tell, GetTechnology or ShowTechnology. Command extension has to do with the command that you use. Refer to the advanced editing section to see what these commands need for their extensions.

An example:

Let's try an example. Say in your campaign you want the player to have a choice: either he allies with Mr Evil, or he fights against him. In either case, you want the storyline to branch to a section called [continue]. One way of doing this would be to use the $OnExit command as follows:


Mr Evil, your sworn arch enemy for years, asks for an alliance. Do you agree?<br>

$OnExit= ,Tell,continue

<p>While you were deciding whether or not you wanted to ally with Mr. Evil, he has brazenly attacked your island!

$Button=To Battle,DoNothing,0

So, no matter what is chosen, when a button is clicked on either YES or NO, the game will branch to the [continue] routine. Also, check out the $OnExit line. See the first comma? Make sure there's a space between the equals sign and the comma, or else the command won't work.

Another example:

Wait a second, swelb. Can I have a menu, and then after the player picks something from it, use the $OnExit command to continue with the story? Of course you can. Here's how you'd do it:


Breaking into the enemy's encampment at night, you find plans for new weapons. You only have time to take one plan. Which will it be?<br>

$Menu=~[IrainCannon.3]rain cannon,GetTechnology,129
$Menu=~[IsunCannon.3]sun cannon,GetTechnology,128
$OnExit= ,Tell,gotweapon


A good choice! However, you've awakened the enemy! Prepare for battle!


There's one problem with using $OnExit. And that has to do with the above example. When you run the code and the player picks the weapon, the GetTechnology screen is shown, then immediately the program branches to [gotweapon], and that screen is shown on top of the GetTechnology screen. Here's what you'll see before you select your Tech:


So far so good, but what happens when you select what weapon you want? Well, in theory, you should get the standard Technology Gained screen, then another screen that tells you that what you selected was a good choice. Well, you do get those things, but....


see the problem? The Good Choice window draws over the Tech Gained window, which isn't really quite what we want. It would be nice to have the Good Choice window behind the other window.

So, howdoyadothat, you say? I dunno. Haven't figured it out, yet. But we'll keep at it.