Feedback on scripting design
- From: Timothy Pruett <drakalor.tourist@xxxxxxxxx>
- Date: Fri, 17 Feb 2006 02:56:27 -0600
I'm redoing my scripting system, and just want some feedback or ideas for improvement. I'll try to explain it as briefly as possible. The system is hardcoded in C++, and uses Lua for scripting.
Basically, it works like this. At the start of the game, a startup script is called, which is responsible for setting up all the initial game values, selecting the starting map, and any other miscellaneous things you want taken care of at the beginning of the game. Control is then passed back to the main program, which handles I/O and watches for triggers.
Each map is defined in Lua. When a new map is loaded by the main game script, the map script sends the map data to the main program, and also registers all triggers for that map. The triggers are contained in a list, and are checked every loop.
When a trigger is evaluated true, the appropriate trigger script is processed. Triggers can be placed not only on map tiles, but on creatures and objects as well.
Item interaction is handled via scripts, as well. When any action is performed on an item (using, wielding, attacking with, etc.), the item script is processed.
Creature interaction is also handled with scripts. Each creature has a set of scripts that handle attacking, AI, special abilities, stats, etc.
Here are the C++ functions that are registered with Lua and are usable from game scripts:
Interface_NewMap(int Width, int Height);
// Clears the current map, and replaces it with a map
// of the desired dimension
Interface_SetTile(int TileType, int X, int Y);
// Sets the desired tile on the current map
Interface_PrintMessage(string Msg, int Color);
// Sends a string of the desired color to the
// message buffer to be printed
Interface_Hurt(int MonsterID, int Damage, int DamageTypeFlags);
// Deals damage to selected creature
Interface_CreateNewCreature(int CreatureType, int X, int Y);
// Creates a new creature of the desired type
// at the selected map coordinates
Interface_CreateNewItem(int ItemType, int X, int Y);
// Creates a new item at the desired location
// If X and Y == 0, then place item in inventory
Interface_SetTrigger(Trigger TriggerType, Target TriggerTarget,
string ActionScript);
// Creates a new trigger of selected type, targetting
// the desired target. When evaluated as true, will
// process the ActionScript.
Interface_MoveCreature(int MonsterID, int X, int Y);
// Teleports creature to new coordinates
Interface_UpdateVariables();
// Updates all relevant game variables, so that the Lua
// scripting environment has up-to-date data
Interface_Heal(int MonsterID, int Amount);
// Heals creature by desired amount
Interface_CreateNewObject(int ObjectType, int X, int Y);
// Creates a new object at desired location
Interface_BindKey(int KeyCode, int Action);
// Binds key to perform selected action
Interface_SetFlag(int FlagID, bool Value);
// Sets the selected flag to desired value
Interface_ToggleFlag(int FlagID);
// Toggles selected flag
Interface_DamageItem(int ItemID, int Damage,
int DamageTypeFlags);
// Damages an item
Interface_DamageObject(int ObjectID, int Damage,
int DamageTypeFlags);
// Damages an object
Interface_CanSee(int MonsterID, Target LOSTarget);
// Checks whether a target is visible from the
// creature's viewpoint
Here are a list of trigger types:
OnEnterTile();
OnExitTile();
OnEnterLevel();
OnExitLevel();
OnUse();
OnWield();
OnDrop();
OnBreak();
OnAttack();
OnKill();
OnFlagSet();
OnRead();
OnExamine();
OnHealth();
OnEat();
OnDrink();
OnTalk();
OnInteract();
OnTimer();
Since I still haven't reached an advanced stage with this project, I haven't really had any testing done yet, nor do I have anything playable enough to be able to accurately judge whether the functions and triggers above will be enough to cover all my needs, when the time comes to create the actual game content. Any ideas would be appreciated, especially if you see some missing but needed functionality.
.
- Follow-Ups:
- Re: Feedback on scripting design
- From: Timothy Pruett
- Re: Feedback on scripting design
- From: Ray Dillinger
- Re: Feedback on scripting design
- From: gatti
- Re: Feedback on scripting design
- Prev by Date: Re: Three year roguelike completed!
- Next by Date: Re: hitpointless system
- Previous by thread: DemiseRL - Orc Scenario
- Next by thread: Re: Feedback on scripting design
- Index(es):
Relevant Pages
|