____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

script.h File Reference

The configuration language headerfile. More...

#include <string>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"

Go to the source code of this file.

Classes

struct  _lua_user_data_

Defines

#define LuaError(l, args)
#define LuaCheckArgs(l, args)

Typedefs

typedef struct _lua_user_data_ LuaUserData

Enumerations

enum  { LuaUnitType = 100, LuaSoundType }

Functions

int LuaLoadFile (const std::string &file)
int LuaCall (int narg, int clear, bool exitOnError=true)
const char * LuaToString (lua_State *l, int narg)
int LuaToNumber (lua_State *l, int narg)
bool LuaToBoolean (lua_State *l, int narg)
void CclGarbageCollect (int fast)
 Perform garbage collection.
void InitCcl (void)
 Initialise ccl.
void LoadCcl (void)
 Load ccl config file.
void SaveCcl (CFile *file)
 Save CCL module.
void SavePreferences (void)
 Save user preferences.
char * SaveGlobal (lua_State *l, bool is_root)
 For saving lua state.
int CclCommand (const std::string &command, bool exitOnError=true)
 Execute a ccl command.

Variables

lua_State * Lua
 Structure to work with lua files.
std::string CclStartFile
 CCL start file.
int CclInConfigFile
 True while config file parsing.


Detailed Description

The configuration language headerfile.

Definition in file script.h.


Define Documentation

#define LuaCheckArgs ( l,
args   ) 

Value:

do { \
        if (lua_gettop(l) != args) { \
            LuaError(l, "incorrect argument"); \
        } \
    } while (0)

Definition at line 78 of file script.h.

Referenced by CclAddMessage(), CclAddTrigger(), CclAiAttackWithForce(), CclAiCheckForce(), CclAiDebug(), CclAiDump(), CclAiForce(), CclAiForceRole(), CclAiGetSleepCycles(), CclAiNeed(), CclAiPlayer(), CclAiSet(), CclAiSleep(), CclAiWait(), CclAiWaitForce(), CclCenterMap(), CclChangeUnitsOwner(), CclCreateUnit(), CclDefineAi(), CclDefineAnimations(), CclDefineButton(), CclDefineButtonStyle(), CclDefineConstruction(), CclDefineCursor(), CclDefineMapSetup(), CclDefineMissileType(), CclDefinePlayerColorIndex(), CclDefinePlayerColors(), CclDefineUnitType(), CclFilteredListDirectory(), CclGetCompileFeature(), CclGetCurrentLuaPath(), CclGetFogOfWar(), CclGetGodMode(), CclGetLocalPlayerName(), CclGetNumUnitsAt(), CclGetSpeedBuild(), CclGetSpeedTrain(), CclGetUnits(), CclGetUnitVariable(), CclGetVideoFullScreen(), CclGetVideoResolution(), CclGroup(), CclIfNearUnit(), CclIfRescuedNearUnit(), CclKillUnit(), CclKillUnitAt(), CclLoad(), CclLoadBuffer(), CclLog(), CclMakeSound(), CclMakeSoundGroup(), CclMapSound(), CclMoveUnit(), CclNewPlayerColors(), CclNoRandomPlacementMultiplayer(), CclOrderUnit(), CclPlaySound(), CclPresentMap(), CclReplayLog(), CclRevealMap(), CclRightButtonAttacks(), CclRightButtonMoves(), CclSavedGameInfo(), CclSavePreferences(), CclSelection(), CclSetAllPlayersBuildingLimit(), CclSetAllPlayersTotalUnitLimit(), CclSetAllPlayersUnitLimit(), CclSetBuildingCapture(), CclSetDiplomacy(), CclSetFogOfWar(), CclSetFogOfWarGraphics(), CclSetGameCursor(), CclSetGlobalSoundRange(), CclSetGodMode(), CclSetGroupId(), CclSetGroupKeys(), CclSetLocalPlayerName(), CclSetMaxSelectable(), CclSetMinimapTerrain(), CclSetMouseScrollSpeedControl(), CclSetMouseScrollSpeedDefault(), CclSetResourcesHeld(), CclSetSharedVision(), CclSetSoundRange(), CclSetSpeedBuild(), CclSetSpeeds(), CclSetSpeedTrain(), CclSetUnitVariable(), CclSetVideoFullScreen(), and CclSetVideoResolution().

#define LuaError ( l,
args   ) 

Value:

do { \
        fprintf(stdout, "%s:%d: ", __FILE__, __LINE__); \
        fprintf(stdout, args); \
        fprintf(stdout, "\n"); \
        lua_pushfstring(l, args); lua_error(l); \
    } while (0)

Definition at line 70 of file script.h.

Referenced by Ccl2Condition(), CclAddTrigger(), CclAiAttackWithForce(), CclAiForce(), CclAiForceRole(), CclAiWaitForce(), CclChangeUnitsOwner(), CclCreateUnit(), CclDefineAi(), CclDefineAiHelper(), CclDefineAiPlayer(), CclDefineAnimations(), CclDefineBurningBuilding(), CclDefineButton(), CclDefineButtonStyle(), CclDefineConstruction(), CclDefineCursor(), CclDefineDecorations(), CclDefineGameSounds(), CclDefineMissileType(), CclDefinePlayerColors(), CclDefinePlayerTypes(), CclDefineSpell(), CclDefineSprites(), CclDefineUnitType(), CclDefineViewports(), CclFilteredListDirectory(), CclGetNumUnitsAt(), CclGetResourceByName(), CclGetSound(), CclGetUnitType(), CclGetUnitVariable(), CclIfNearUnit(), CclIfRescuedNearUnit(), CclKillUnitAt(), CclLog(), CclMakeSound(), CclMissile(), CclOrderUnit(), CclParseBuilt(), CclParseHarvest(), CclParseMove(), CclParseOrder(), CclParseTrain(), CclPlayer(), CclReplayLog(), CclSavedGameInfo(), CclSelection(), CclSetClickMissile(), CclSetDamageMissile(), CclSetResourcesHeld(), CclSetTitleScreens(), CclSetUnitVariable(), CclSlotUsage(), CclSpellAction(), CclSpellAutocast(), CclSpellCondition(), CclSpellMissileLocation(), CclStratagusMap(), CclUnit(), DefineVariableField(), FindLabel(), HandleCommandKey(), LuaCallback::LuaCallback(), ParseAnimation(), ParseAnimationFrame(), ParseBuildingRules(), ParseButtonStyleProperties(), and TriggerGetPlayer().


Typedef Documentation

typedef struct _lua_user_data_ LuaUserData


Enumeration Type Documentation

anonymous enum

Enumerator:
LuaUnitType 
LuaSoundType 

Definition at line 60 of file script.h.


Function Documentation

int CclCommand ( const std::string &  command,
bool  exitOnError 
)

Execute a ccl command.

Send command to ccl.

Parameters:
command Zero terminated command string.
exitOnError Exit if an error occurs.

Definition at line 716 of file script.cpp.

References Lua, LuaCall(), and report().

Referenced by DoNextReplay(), GameMainLoop(), and InputKey().

void CclGarbageCollect ( int  fast  ) 

Perform garbage collection.

Perform CCL garbage collection

Parameters:
fast set this flag to disable slow GC (during game)

Definition at line 437 of file script.cpp.

References _C_, DebugPrint, and Lua.

Referenced by CEditor::Init(), LoadCcl(), and LoadGame().

void InitCcl ( void   ) 

void LoadCcl ( void   ) 

Load ccl config file.

Load stratagus config file.

Definition at line 1067 of file script.cpp.

References CclGarbageCollect(), CclInConfigFile, CclStartFile, ExitFatal(), LibraryFileName(), LuaLoadFile(), and ShowLoadProgress().

Referenced by EditorMainLoop(), and main().

int LuaCall ( int  narg,
int  clear,
bool  exitOnError 
)

Call a lua function

Parameters:
narg Number of arguments
clear Clear the return value(s)
exitOnError Exit the program when an error occurs
Returns:
0 in success, else exit.

Definition at line 174 of file script.cpp.

References laction(), Lua, luatraceback(), and report().

Referenced by AiExecuteScript(), CallHandler(), CclCommand(), CheckMusicFinished(), HandleCheats(), HandleCommandKey(), InitTriggers(), LuaLoadFile(), TriggerExecuteAction(), and TriggersEachCycle().

int LuaLoadFile ( const std::string &  file  ) 

Load a file and execute it

Parameters:
file File to load and execute
Returns:
0 for success, else exit.

Definition at line 248 of file script.cpp.

References CurrentLuaFile, Lua, LuaCall(), LuaLoadBuffer(), and report().

Referenced by CclLoad(), CclSavedGameInfo(), CreateGame(), CEditor::Init(), LoadCcl(), LoadGame(), LoadReplay(), LoadStratagusMap(), LoadStratagusMapInfo(), and MenuLoop().

bool LuaToBoolean ( lua_State *  l,
int  narg 
)

int LuaToNumber ( lua_State *  l,
int  narg 
)

Convert lua number in C number. It checks also type and exit in case of error.

Parameters:
l Lua state.
narg Argument number.
Returns:
C number from lua.

Definition at line 411 of file script.cpp.

Referenced by CclAiAttackWithForce(), CclAiCheckForce(), CclAiDebugPlayer(), CclAiForce(), CclAiForceRole(), CclAiSet(), CclAiSleep(), CclAiWaitForce(), CclCenterMap(), CclChangeUnitsOwner(), CclCreateUnit(), CclDefineAiPlayer(), CclDefineBurningBuilding(), CclDefineButton(), CclDefineButtonStyle(), CclDefineConstruction(), CclDefineCursor(), CclDefineDecorations(), CclDefineMissileType(), CclDefinePlayerColorIndex(), CclDefinePlayerColors(), CclDefineSpell(), CclDefineSprites(), CclDefineUnitAllow(), CclDefineUnitType(), CclDefineViewports(), CclGetNumUnitsAt(), CclGetUnit(), CclGroup(), CclIfNearUnit(), CclIfRescuedNearUnit(), CclKillUnitAt(), CclLog(), CclMissile(), CclMoveUnit(), CclOrderUnit(), CclParseBuilt(), CclParseHarvest(), CclParseMove(), CclParseOrder(), CclParseTrain(), CclPlayer(), CclPresentMap(), CclReplayLog(), CclSavedGameInfo(), CclSelection(), CclSetAllPlayersBuildingLimit(), CclSetAllPlayersTotalUnitLimit(), CclSetAllPlayersUnitLimit(), CclSetDiplomacy(), CclSetGlobalSoundRange(), CclSetGroupId(), CclSetMaxSelectable(), CclSetMouseScrollSpeedControl(), CclSetMouseScrollSpeedDefault(), CclSetResourcesHeld(), CclSetSharedVision(), CclSetSoundRange(), CclSetSpeedBuild(), CclSetSpeeds(), CclSetSpeedTrain(), CclSetTitleScreens(), CclSetUnitVariable(), CclSetVideoResolution(), CclSlotUsage(), CclSpellAction(), CclSpellAutocast(), CclSpellCondition(), CclSpellMissileLocation(), CclStratagusMap(), CclUnit(), DefineVariableField(), ParseBuildingRules(), ParseButtonStyleProperties(), and TriggerGetPlayer().

const char* LuaToString ( lua_State *  l,
int  narg 
)

Convert lua string in char*. It checks also type and exit in case of error.

Note:
char* could be invalidated with lua garbage collector.
Parameters:
l Lua state.
narg Argument number.
Returns:
char* from lua.

Definition at line 396 of file script.cpp.

Referenced by CclAddMessage(), CclAiDebugPlayer(), CclAiForceRole(), CclDefineAi(), CclDefineAiHelper(), CclDefineAiPlayer(), CclDefineAllow(), CclDefineAnimations(), CclDefineBurningBuilding(), CclDefineButton(), CclDefineButtonStyle(), CclDefineConstruction(), CclDefineCursor(), CclDefineDecorations(), CclDefineDefaultResourceNames(), CclDefineGameSounds(), CclDefineMapSetup(), CclDefineMissileType(), CclDefinePlayerColors(), CclDefinePlayerTypes(), CclDefineSpell(), CclDefineSprites(), CclDefineUnitAllow(), CclDefineUnitType(), CclDefineVariables(), CclDefineViewports(), CclGetCompileFeature(), CclGetResourceByName(), CclGetUnitType(), CclGetUnitVariable(), CclGroup(), CclIfNearUnit(), CclIfRescuedNearUnit(), CclLoad(), CclLoadBuffer(), CclLog(), CclMakeSound(), CclMakeSoundGroup(), CclMapSound(), CclMissile(), CclOrderUnit(), CclParseBuilt(), CclParseHarvest(), CclParseMove(), CclParseOrder(), CclParseTrain(), CclPlayer(), CclPresentMap(), CclReplayLog(), CclSavedGameInfo(), CclSelection(), CclSetDiplomacy(), CclSetFogOfWarGraphics(), CclSetGameCursor(), CclSetGroupKeys(), CclSetLocalPlayerName(), CclSetTitleScreens(), CclSetUnitVariable(), CclSlotUsage(), CclSoundForName(), CclSpellAction(), CclSpellAutocast(), CclSpellCondition(), CclSpellMissileLocation(), CclStratagusMap(), CclUnit(), DefineVariableField(), ParseAnimation(), ParseBuildingRules(), ParseButtonStyleProperties(), LuaListModel::setList(), TriggerGetPlayer(), and TriggerGetUnitType().

void SaveCcl ( CFile file  ) 

Save CCL module.

Save CCL Module.

Parameters:
file Save file.

Definition at line 1092 of file script.cpp.

References GodMode, CFile::printf(), SpeedBuild, and SpeedTrain.

Referenced by SaveGame().

char* SaveGlobal ( lua_State *  l,
bool  is_root 
)

For saving lua state.

For saving lua state (table, number, string, bool, not function).

Parameters:
l lua_State to save.
is_root true for the main call, 0 for recursif call.
Returns:
NULL if nothing could be saved. else a string that could be executed in lua to restore lua state
Todo:
do the output prettier (adjust indentation, newline)

Definition at line 860 of file script.cpp.

References Assert, LuaEscape(), new_strdup(), SaveGlobal(), and strdcat3().

Referenced by SaveGame(), SaveGlobal(), and SavePreferences().

void SavePreferences ( void   ) 

Save user preferences.

Save user preferences

Definition at line 1041 of file script.cpp.

References Lua, SaveGlobal(), and UserDirectory.

Referenced by CclSavePreferences(), and CommandKey().


Variable Documentation

True while config file parsing.

Definition at line 72 of file script.cpp.

Referenced by CclRevealMap(), CclSetFogOfWar(), CclSetVideoFullScreen(), CclSetVideoResolution(), and LoadCcl().

std::string CclStartFile

CCL start file.

Definition at line 70 of file script.cpp.

Referenced by LoadCcl(), and main().

lua_State* Lua


Generated on Sat Feb 21 00:28:18 2009 for Bos Wars by  doxygen 1.5.6