NetStorm Wiki
Register
Advertisement

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 Basics of Variables

Strangely familiar, yet different...

You say that you've never used variables in your Campaign. Are you sure? Maybe you've used them, but you didn't realize you were using variables. Remember all the stuff you have to put under the [header] section, like myTech="", ai2Collectors=, ai3BridgeDrawRate=, etc? Guess what that stuff is? They're variables. But they're special Netstorm variables.

The kewl thing about Netstorm Script is that you're not limited to just the Netstorm variables. You can create your own. But you need to know a few things first...

Elephants never Forget... and neither does Netstorm

Netstorm remembers all user-defined variables, even after you exit the mission, or remove the variables from your english files! This is very important, (and very powerful for remembering stuff from previous Maps). Think of this as Netstorm saving a huge file of all the user-defined variable names and all user-defined variable values that are used in each and every map that you've ever played. So, once a variable is created by you, the MapMaker, it's always there (it just may not be used).

This means that if custom variables are used in your maps, you should follow a few simple rules:

  • In your maps, or in your guide file, always pre-set your variables to their starting values. You don't want to use a variable in your maps when you're unsure of it's value. So make sure. Don't assume that the value of your variable will begin at 0, or "".

  • Assigning variables:


    "Hold your ground, Priests! I think we have the enemy on the run!"

    - ex Nimbian General


    Say you have 2 AI players: An arch enemy (Lord FOUL) and an ally (Lord of LIGHT). You want to keep track of both, during your Campaign, since either AI may or may not follow you to the next mission in your Campaign, depending on whether they live or die in previous maps. How would you keep track of them? By assigning them each a variable name and variable flag.

    Let's start out by naming the variables. The flags variables, let's call sw_allyDead and sw_enemyDead. The name of the AI's will be sw_allyName and sw_enemyName.

    So, in your first mission, you would set the sw_allyDead and sw_enemyDead flags to 0 (meaning the AI's are alive), and configure your enemy and ally names. How would you do this? With the $Config keyword.

    An Old Friend, $Config

    Ahh, yes $Config. You've used this command before, after a mission was complete (Remember <$Config,Done{mission.fileName}=1>, which is a line that is used in just about every Map out there?). Betcha didn't realize it at the time you used it, but you were actually creating a custom variable in Netstorm.

    So, howdoya use $Config for variable creation? Here's how:

    [Header]
    ....... all normal header stuff.....

    [Init]
    <$Config,sw_allyDead=0>
    <$Config,sw_allyName="Lord of ~yLIGHT~.">
    <$Config,sw_enemyDead=0>
    <$Config,sw_enemyName="Lord ~kFOUL~.">

    [Options]
    [A.]
    <h2>TREACHERY!</h2>
    You awaken one day to find that someone has snuck into your encampment and has stolen your milk! "This means war!", you bellow, as you can't imagine enjoying your breakfast of milk and cookies without milk!

    <p>Your ally, the {sw_allyName} says he saw a fleeing shape early this morning, running off your island with something large in his arms. So, you send out spies to the adjacent islands, and sure enough, you find that your once friend and ally, {sw_enemyName}, is hoarding a whole caseload of milk on his island. "He will pay for this, with his life!", you scream as the war begins!

    $Button=TO WAR,DoNothing,0

    [ai2PriestDead]
    Oh, no! {sw_enemyName} has sacked your ally, the {sw_allyName}! You must fight on alone, and try to get your milk back!

    <$Config,sw_allyDead=1>
    $Button=Next Mission,MissionBegin,sw_noAllyMission

    [ai3PriestDead]
    Horrah! You got your milk back! You and
    {sw_allyName} celebrate with lots of milk and lots of cookies! The celebration lasts for days, and the next thing you know, you wake up with a stomach ache and a sugar rush hangover!

    But, you've shown {sw_enemyName} that he can't steal from you and get away with it!

    <$Config,sw_enemyDead=1>
    $Button=Next Mission,MissionBegin,sw_noEnemyMission

    As can be seen in the above example, AI2 is your ally, while AI3 is the Treacherous enemy. I didn't show it in this example, but if you use this code, you have to insert all the normal header stuff.

    If the ally gets sacked, sw_allyDead gets set to 1, so all future Maps in this Campaign will know there is no more ally. However, if the enemy dies, sw_enemyDead is set to 1.

    Kewl, But...

    Notice a few new things in the example? [Init] is an initialization routine. It's useful for setting up variables or moving the screen to a different location before the Map starts. Very handy.

    Also, notice that once a variable is defined, you can display THE VALUE OF THE VARIABLE, by enclosing the variable name in { }. See {sw_allyName} and {sw_enemyName}? When the map is run, whenever an {sw_allyName} is used, Lord of LIGHT will be displayed in it's place. Wherever you see {sw_enemyName} in the code, Lord FOUL will come up.

    What good is assigning ally and enemy names this way, you say? Well say you've finished your Campaign, but you decide you don't like the enemy name of "Lord FOUL". You want to change it. You want to make it more descriptive. You decide to change it to "Lord FOUL BREATH".

    If you didn't use variables for the enemy name, you'd have to modify every single instance of the enemy's name in all of your maps. Talk about a lot of work! (And I hate to work.) But by doing it with a variable, you just re-name the 1 line of code that defines the enemy name and Voila! Your enemy's name is now what it should be, in all of your maps: "Lord FOUL BREATH".

    Of course, that's a pretty lame example. But you get the idea....

    Well, I think that about wraps up variable basics. There is a lot that can be done with these things, especially when we add conditionals....

Advertisement