Scenario Editing
In newer Glests (3.2.0 beta and newer) lua scripting gives us a new possibility. Scripted Scenarios!
The game includes 2 tutorial scenarios and one scripted normal scenario(storming) now. These demo scenarios show a bit what's possible now. Have a look at them if you want to learn it.
Useful Links:
- Omega's tutorial: tutorial
- Programming in Lua
- lua tutorials
- Lua-Users.org Wiki
The available functions
As there is no list of the possible commands now, here a copy of some things from script_manager.h (from the glest sourcecode) which should contain/show all possible Glest lua-commands.
Message Box Functions
bool getMessageBoxEnabled() const {return !messageQueue.empty();}
GraphicMessageBox* getMessageBox() {return &messageBox;}
string getDisplayText() const {return displayText;}
bool getGameOver() const {return gameOver;}
const PlayerModifiers *getPlayerModifiers(int factionIndex) const {return &playerModifiers[factionIndex];}
Events
void onMessageBoxOk();
void onResourceHarvested();
void onUnitCreated(const Unit* unit);
void onUnitDied(const Unit* unit);
private:
string wrapString(const string &str, int wrapCount);
Wrappers, Commands
void showMessage(const string &text, const string &header);
void clearDisplayText();
void setDisplayText(const string &text);
void setCameraPosition(const Vec2i &pos);
void createUnit(const string &unitName, int factionIndex, Vec2i pos);
void giveResource(const string &resourceName, int factionIndex, int amount);
void givePositionCommand(int unitId, const string &producedName, const Vec2i &pos);
void giveProductionCommand(int unitId, const string &producedName);
void giveUpgradeCommand(int unitId, const string &upgradeName);
void disableAi(int factionIndex);
void setPlayerAsWinner(int factionIndex);
void endGame();
Wrappers, Queries
Vec2i getStartLocation(int factionIndex);
Vec2i getUnitPosition(int unitId);
int getUnitFaction(int unitId);
int getResourceAmount(const string &resourceName, int factionIndex);
const string &getLastCreatedUnitName();
int getLastCreatedUnitId();
const string &getLastDeadUnitName();
int getLastDeadUnitId();
int getUnitCount(int factionIndex);
int getUnitCountOfType(int factionIndex, const string &typeName);
Callbacks, Commands
static int showMessage(LuaHandle* luaHandle);
static int setDisplayText(LuaHandle* luaHandle);
static int clearDisplayText(LuaHandle* luaHandle);
static int setCameraPosition(LuaHandle* luaHandle);
static int createUnit(LuaHandle* luaHandle);
static int giveResource(LuaHandle* luaHandle);
static int givePositionCommand(LuaHandle* luaHandle);
static int giveProductionCommand(LuaHandle* luaHandle);
static int giveUpgradeCommand(LuaHandle* luaHandle);
static int disableAi(LuaHandle* luaHandle);
static int setPlayerAsWinner(LuaHandle* luaHandle);
static int endGame(LuaHandle* luaHandle);
Callbacks, Queries
static int getStartLocation(LuaHandle* luaHandle);
static int getUnitPosition(LuaHandle* luaHandle);
static int getUnitFaction(LuaHandle* luaHandle);
static int getResourceAmount(LuaHandle* luaHandle);
static int getLastCreatedUnitName(LuaHandle* luaHandle);
static int getLastCreatedUnitId(LuaHandle* luaHandle);
static int getLastDeadUnitName(LuaHandle* luaHandle);
static int getLastDeadUnitId(LuaHandle* luaHandle);
static int getUnitCount(LuaHandle* luaHandle);
static int getUnitCountOfType(LuaHandle* luaHandle);