My first map script

From The DarkMod Wiki
Revision as of 09:06, 26 November 2010 by Tels (talk | contribs) (add)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Create the script file

If your map is called for example maps/mydir/mymap.map, you must create a text file maps/mydir/mymap.script.

The contents

The map script needs to contain a main function. This function is called at the very start of your map, e.g. when the map is loaded for the first time. So if you want something to happen later, you need to pause the script and then do something. Here is an example:

// This is a comment and gets ignored by the script engine

// the main function does not take arguments nor returns something
void main () {         

    sys.wait(100);   // wait 100 seconds

    /* $entityName here acts upon a specific entity. Be careful, if you rename
       the entity in DR, your script will break! $player1 is the player entity,
       and this only works in single player mode. However, there is no multiplayer
       in TDM, so we can safely use it for now: */

    // put some information in the console
    sys.println("Going to kill the entity " + $player1.getName() );

    $player1.kill();     // kill the player
}

Other useful things:

  • remove() - removes an entity from the game
  • sys.waitFrame() - waits until the next frame

See also