⚙ Swift Mazes - Scripting Framework

 Select entry:

Introduction

⚙ Swift Mazes is a framework to generate 3D dungeons from textual (UTF-8 or ASCII encoded) floorplans. It reads a config file, some prefabs, and then generates a fully working 3D dungeon map for The Dark Mod, dmaps it (via TDM), and packages it together as a playable .PK4 file - all automatic!

This manual section describes the various scripting functions, global variables and scriptobjects provided by the framework.

Global functions

 void debug(float level, string text);
 void debug_base(string text);
 void playSound( entity e, string snd, float channel );
 void swift_close_target( entity child );
 void swift_delay(float delay, string func, entity e);
 string swift_difficulty();
 float swift_difficulty_level();
 float swift_distance(vector A, vector B);
 void swift_douse_target( entity child );
 string swift_engine();
 string swift_engine_name();
 float swift_engine_version();
 void swift_fog_off(entity fl);
 void swift_fog_on(entity fl, vector r, vector c, float s6);
 void swift_frob(entity e);
 void swift_frob_button(entity button);
 void swift_frob_door(entity door);
 void swift_frob_lever(entity lever);
 void swift_init(float d);
 void swift_init_globals(float db_level);
 float swift_lerp_float( float dist, float max_dist, float ol, float nl );
 vector swift_lerp_vector( float dist, float max_dist, vector ol, vector nl );
 void swift_light_target( entity child );
 void swift_move(entity e, vector diff);
 void swift_open_target( entity child );
 boolean swift_player_moving();
 void swift_rand_move(entity e, vector min, vector max);
 void swift_rand_rotate(entity e, vector min_angle, vector max_angle);
 float swift_random_int( entity e, float max );
 vector swift_random_vector( vector min, vector max );
 void swift_reset_target( entity child );
 void swift_rotate(entity e, vector angle);
 void swift_set_difficulty();
 void swift_state_change_button(entity button, boolean bOpen, boolean bLocked, boolean bInterrupted);
 void swift_state_change_door(entity door, boolean bOpen, boolean bLocked, boolean bInterrupted);
 void swift_state_change_lever(entity lever, boolean bOpen, boolean bLocked, boolean bInterrupted);
 void swift_teleport(entity trig, entity ent);
 void swift_test_trigger(entity e);
 void swift_toggle_target( entity child );
 float swift_trigger_close(entity ent, string prefix);
 float swift_trigger_open(entity ent, string prefix);
 float swift_trigger_targets(entity ent, string prefix, string functionName, float actionTime);
 float swift_trigger_toggle(entity ent, string prefix, float actionTime);
 void swift_trigger_touch(entity trig, entity ent);
 float swift_vector_len(vector A);
 float swift_version();
 string swift_version_str();
 string warn(string text);

Global variables

Scriptobjects

swift_array

It provides the following functions:

 float getLastIndex(string name);
 float getFirstIndex(string name);
 void _setLastIndex(string name, float i);
 void _setFirstIndex(string name, float i);
 void _setLength(string name, float i);
 string get(string name, float index);
 string set(string name, float index, string value);
 float getFloat(string name, float index);
 float setFloat(string name, float index, string value);
 float getInteger(string name, float index);
 float setInteger(string name, float index, string value);
 vector getVector(string name, float index);
 vector setVector(string name, float index, string value);
 void init_array(string name);
 boolean array_exists(string name);
 float getLength(string name);
 string pop(string name);
 string shift(string name);
 string removeAt(string name, float N);
 void unshift(string name, string value);
 void push(string name, string value);
 float shiftFloat(string name);
 float appendOther( string name, swift_array other, string oname);
 float append( string name, string oname);

swift_message

A message queue object. Presents messages to the user via the HUD.

swift_message inherits from swift_array and provides the following functions:

 void init();
 void createGUI();
 void addMessage(string message, float delay);
 void showMessage();
 void popMessage();

swift_base_entity

We need to split up certain parts of swift_entity into a base class, so we can declare them before we use them in swift_entity, as TDM scripting does not like forward references to methods in script objects.

The base script object for entities. Should not be used directly, but as base class via inheritance.

It provides the following functions:

 string getSwiftType();
 void registerEntityAs(string category, swift_base_entity e);
 void registerEntity(swift_base_entity e);
 void unRegisterEntity(swift_base_entity e);
 float getNumEntities(string category);
 entity getEntityByType(string category, float N);
 float forEachEntity(string category, string methodName, entity E);
 float forClosestEntity(string category, string methodName, entity E);

swift_brain

Maintains a list of messages and their AABB to show them when the player enters a specific area.

swift_brain inherits from swift_base_entity and provides the following functions:

 void init();
 void changedLocation(string oldLoc, string newLoc);
 void checkEvents();

swift_entity

swift_entity inherits from swift_base_entity and provides the following functions:

 void init();
 boolean canTrigger();
 void _init_state();
 void triggered(entity activator, entity trigger_ent);
 void doRemove();
 float doWaitOn(string arg);
 void playBroken();
 void playAction();
 void doActivate();
 void doDeactivate();
 void setOnce();
 void clearTriggered();
 float think();
 void triggerTargets(entity activator);
 vector moveOrigin(vector moveBy);
 vector getBoundsMin();
 vector getBoundsMax();
 boolean boundsIntersect(entity other);

swift_teleporter

swift_teleporter inherits from swift_entity and provides the following functions:

 void init();
 void Triggered(entity target);

swift_sequence

swift_sequence inherits from swift_entity and provides the following functions:

 void init();
 void Reset();
 void Complete();
 void _onState(string stateName);
 void Signal( string signal );
 void fSignal( float signal );
 void _wait();
 void _wait_reset();
 void doToggle();

swift_trigger

Implements a manual "trigger" box. It checks for entities to pass inside the defined box, and calls a script method on each target's scriptobject, passing along itself and the entity it found inside the trigger. This works around the performance problem of trigger_touch, and around the "only see AI" problem of trigger_multi.

swift_trigger inherits from swift_entity and provides the following functions:

 void init();
 void touchActivate();
 void activateOnTouch();

swift_door

swift_door inherits from swift_entity and provides the following functions:

 void init();
 void playOpenAction();
 void playCloseAction();
 void doOpen();
 void doClose();
 void triggered(entity activator, entity trigger_ent);
 void doToggle();
 void closeOnIdle();
swift_lever

swift_lever inherits from swift_door and provides the following functions:

 void init();
 void turnOn();
 void turnOff();
swift_button

swift_button inherits from swift_lever and provides the following functions:

 void init();

swift_relocator

Relocates the player at map start to one of the random spawnpoints.

It provides the following functions:

 void init();
 void relocatePlayer();

More info

The following manual sections contain more information: