#include <K3dLua.h>
Inheritance diagram for K3dLua:
Public Member Functions | |
K3dLua (K3dGameData *_pGameData) | |
~K3dLua () | |
void | InitLua () |
Allocate new lua state. | |
void | DeleteLua () |
Delete lua state. | |
void | ResetLua () |
Reset lua. | |
bool | LuaLoadFile (const char *_strFilename) |
Load lua script file. | |
int | LuaPCall (const int _iNumArgs, const int _iNumResults, const int _iErrFunc) |
Call lua script. | |
void | LuaError (const char *_strFmt,...) |
Draw error message to the konsole and close Lua state. | |
void | LuaRegister (const char *_strName, lua_CFunction _f) |
Sets the C function _f as the new value of global _strName. | |
const char * | LuaToString (const int _id) |
Convert parameter from stack to the string. | |
double | LuaToNumber (const int _id) |
Convert parameter from stack to the number. | |
int | LuaToBoolean (const int _id) |
Convert parameter from stack to the boolean. | |
void | LuaGetGlobal (const char *_strVarName) |
Read the value of any global Lua variable. | |
int | LuaIsNumber (const int _id) |
Check if type of a lua_Object is number. | |
int | LuaIsBoolean (const int _id) |
Check if type of a lua_Object is boolean. | |
int | LuaIsString (const int _id) |
Check if type of a lua_Object is string. | |
void | LuaPushString (const char *_strKey) |
Push string key to stack. | |
void | LuaPop (const int _id) |
Pop value from stack. | |
void | LuaGetTable (const int _id) |
Read a value from a table that resides somewhere in the stack. | |
double | LuaGetFieldNumber (const char *_strKey) |
Get double value from table field. | |
bool | LuaGetFieldBool (const char *_strKey) |
Get bool value from table field. | |
const char * | LuaGetFieldString (const char *_strKey) |
Get bool value from table field. | |
int | LuaIsTable (const int _id) |
Get positive if is valid table. | |
bool | LuaCheckStack (const int _iNum) |
Check if is free space in stack for number of values. | |
bool | LuaCheckStack (lua_State *_pState, const int _iNum) |
Check if is free space in stack for number of values. | |
lua_State * | GetLuaState () |
Private Member Functions | |
void | StackDump () |
Check actual stack. | |
Private Attributes | |
K3dGameData * | m_pGameData |
Global game data, data centered game system. | |
lua_State * | m_pLua |
Pointer to Lua state. | |
lua_Debug * | m_pLuaDebug |
Lua debug info. |
Definition at line 53 of file K3dLua.h.
K3dLua::K3dLua | ( | K3dGameData * | _pGameData | ) |
Definition at line 40 of file K3dLua.cpp.
References InitLua(), m_pGameData, m_pLua, and K3dSceneData::SetLua().
K3dLua::~K3dLua | ( | ) |
void K3dLua::StackDump | ( | ) | [private] |
void K3dLua::InitLua | ( | ) |
Allocate new lua state.
Definition at line 92 of file K3dLua.cpp.
References m_pLua.
Referenced by K3dLua(), and ResetLua().
void K3dLua::DeleteLua | ( | ) |
Delete lua state.
Definition at line 109 of file K3dLua.cpp.
References m_pLua.
Referenced by ResetLua(), and ~K3dLua().
void K3dLua::ResetLua | ( | ) |
bool K3dLua::LuaLoadFile | ( | const char * | _strFilename | ) |
Load lua script file.
_strFilename | Filename string |
int | Positive value, if file correctly loaded |
Definition at line 128 of file K3dLua.cpp.
References LuaError(), LuaPCall(), LuaToString(), and m_pLua.
Referenced by K3dConfDataBuild::LoadConf(), K3dStream::LoadIni(), K3dScene::LoadNewScript(), and K3dVM::LoadScript().
int K3dLua::LuaPCall | ( | const int | _iNumArgs, | |
const int | _iNumResults, | |||
const int | _iErrFunc | |||
) |
Call lua script.
_iNumArgs | Number of arguments | |
_iNumResults | Number of results | |
_iErrFunc | Error function index |
Definition at line 144 of file K3dLua.cpp.
References m_pLua.
Referenced by K3dVM::Engine_Delete(), K3dVM::Engine_Init(), K3dVM::Engine_Update(), and LuaLoadFile().
void K3dLua::LuaError | ( | const char * | _strFmt, | |
... | ||||
) |
Draw error message to the konsole and close Lua state.
_strFmt | Input message string |
Definition at line 152 of file K3dLua.cpp.
Referenced by K3dVM::Engine_Delete(), K3dVM::Engine_Init(), K3dVM::Engine_Update(), K3dBlockBuild::LoadBlocks(), K3dFontBmp::LoadBmpFonts(), K3dCameraBuild::LoadCameras(), K3dConfDataBuild::LoadConf(), K3dFaceBuild::LoadFaces(), K3dOptions::LoadFontBmp(), K3dOptions::LoadGraphics(), K3dGui::LoadGui(), K3dGui::LoadGuiButtons(), K3dGui::LoadGuiCheckBoxes(), K3dGui::LoadGuiContainers(), K3dGui::LoadGuiDropDown(), K3dGui::LoadGuiFonts(), K3dGui::LoadGuiIcons(), K3dGui::LoadGuiImages(), K3dGui::LoadGuiLabels(), K3dGui::LoadGuiListBoxes(), K3dGui::LoadGuiListModels(), K3dGui::LoadGuiRadioButtons(), K3dGui::LoadGuiScrollAreas(), K3dGui::LoadGuiSliders(), K3dGui::LoadGuiTextBoxes(), K3dGui::LoadGuiTextFields(), K3dGui::LoadGuiWindows(), K2dImageBuild::LoadImages(), K3dStream::LoadIni(), K3dKeyMapBuild::LoadKeyMap(), K3dLineBuild::LoadLines(), K3dPlaneBuild::LoadPlanes(), K3dRayBuild::LoadRays(), K3dOptions::LoadScript(), K3dVM::LoadScript(), K3dSphereBuild::LoadSpheres(), K3dOptions::LoadTexture(), K3dTextureBuild::LoadTextures(), K3dVertexBuild::LoadVertices(), LuaGetFieldBool(), LuaGetFieldNumber(), LuaGetFieldString(), and LuaLoadFile().
void K3dLua::LuaRegister | ( | const char * | _strName, | |
lua_CFunction | _f | |||
) |
Sets the C function _f as the new value of global _strName.
_strName | Function name | |
_f | Global function |
Definition at line 164 of file K3dLua.cpp.
References m_pLua.
Referenced by K3dVM::RegisterFunctions().
const char * K3dLua::LuaToString | ( | const int | _id | ) |
Convert parameter from stack to the string.
_id | Index of stack position |
string |
Definition at line 172 of file K3dLua.cpp.
References m_pLua.
Referenced by K3dConfDataBuild::LoadConf(), K3dStream::LoadIni(), K3dVM::LoadScript(), and LuaLoadFile().
double K3dLua::LuaToNumber | ( | const int | _id | ) |
Convert parameter from stack to the number.
_id | Index of stack position |
double |
Definition at line 180 of file K3dLua.cpp.
References m_pLua.
Referenced by K3dBlockBuild::LoadBlocks(), K3dFontBmp::LoadBmpFonts(), K3dCameraBuild::LoadCameras(), K3dFaceBuild::LoadFaces(), K3dGui::LoadGuiButtons(), K3dGui::LoadGuiCheckBoxes(), K3dGui::LoadGuiContainers(), K3dGui::LoadGuiDropDown(), K3dGui::LoadGuiFonts(), K3dGui::LoadGuiIcons(), K3dGui::LoadGuiImages(), K3dGui::LoadGuiLabels(), K3dGui::LoadGuiListBoxes(), K3dGui::LoadGuiListModels(), K3dGui::LoadGuiRadioButtons(), K3dGui::LoadGuiScrollAreas(), K3dGui::LoadGuiSliders(), K3dGui::LoadGuiTextBoxes(), K3dGui::LoadGuiTextFields(), K3dGui::LoadGuiWindows(), K2dImageBuild::LoadImages(), K3dLineBuild::LoadLines(), K3dPlaneBuild::LoadPlanes(), K3dRayBuild::LoadRays(), K3dSphereBuild::LoadSpheres(), K3dTextureBuild::LoadTextures(), and K3dVertexBuild::LoadVertices().
int K3dLua::LuaToBoolean | ( | const int | _id | ) |
Convert parameter from stack to the boolean.
_id | Index of stack position |
bool |
Definition at line 188 of file K3dLua.cpp.
References m_pLua.
Referenced by K3dGui::LoadGui().
void K3dLua::LuaGetGlobal | ( | const char * | _strVarName | ) |
Read the value of any global Lua variable.
_strVarName | Variable name |
Definition at line 195 of file K3dLua.cpp.
References LuaCheckStack(), and m_pLua.
Referenced by K3dVM::Engine_Delete(), K3dVM::Engine_Init(), K3dVM::Engine_Update(), K3dBlockBuild::LoadBlocks(), K3dFontBmp::LoadBmpFonts(), K3dCameraBuild::LoadCameras(), K3dConfDataBuild::LoadConf(), K3dFaceBuild::LoadFaces(), K3dOptions::LoadFontBmp(), K3dOptions::LoadGraphics(), K3dGui::LoadGui(), K3dGui::LoadGuiButtons(), K3dGui::LoadGuiCheckBoxes(), K3dGui::LoadGuiContainers(), K3dGui::LoadGuiDropDown(), K3dGui::LoadGuiFonts(), K3dGui::LoadGuiIcons(), K3dGui::LoadGuiImages(), K3dGui::LoadGuiLabels(), K3dGui::LoadGuiListBoxes(), K3dGui::LoadGuiListModels(), K3dGui::LoadGuiRadioButtons(), K3dGui::LoadGuiScrollAreas(), K3dGui::LoadGuiSliders(), K3dGui::LoadGuiTextBoxes(), K3dGui::LoadGuiTextFields(), K3dGui::LoadGuiWindows(), K2dImageBuild::LoadImages(), K3dKeyMapBuild::LoadKeyMap(), K3dLineBuild::LoadLines(), K3dPlaneBuild::LoadPlanes(), K3dRayBuild::LoadRays(), K3dOptions::LoadScript(), K3dSphereBuild::LoadSpheres(), K3dOptions::LoadTexture(), K3dTextureBuild::LoadTextures(), and K3dVertexBuild::LoadVertices().
int K3dLua::LuaIsNumber | ( | const int | _id | ) |
Check if type of a lua_Object is number.
_id | of stack position |
Definition at line 210 of file K3dLua.cpp.
References m_pLua.
Referenced by K3dBlockBuild::LoadBlocks(), K3dFontBmp::LoadBmpFonts(), K3dCameraBuild::LoadCameras(), K3dFaceBuild::LoadFaces(), K3dGui::LoadGuiButtons(), K3dGui::LoadGuiCheckBoxes(), K3dGui::LoadGuiContainers(), K3dGui::LoadGuiDropDown(), K3dGui::LoadGuiFonts(), K3dGui::LoadGuiIcons(), K3dGui::LoadGuiImages(), K3dGui::LoadGuiLabels(), K3dGui::LoadGuiListBoxes(), K3dGui::LoadGuiListModels(), K3dGui::LoadGuiRadioButtons(), K3dGui::LoadGuiScrollAreas(), K3dGui::LoadGuiSliders(), K3dGui::LoadGuiTextBoxes(), K3dGui::LoadGuiTextFields(), K3dGui::LoadGuiWindows(), K2dImageBuild::LoadImages(), K3dLineBuild::LoadLines(), K3dPlaneBuild::LoadPlanes(), K3dRayBuild::LoadRays(), K3dSphereBuild::LoadSpheres(), K3dTextureBuild::LoadTextures(), and K3dVertexBuild::LoadVertices().
int K3dLua::LuaIsBoolean | ( | const int | _id | ) |
Check if type of a lua_Object is boolean.
_id | of stack position |
Definition at line 217 of file K3dLua.cpp.
References m_pLua.
Referenced by K3dGui::LoadGui().
int K3dLua::LuaIsString | ( | const int | _id | ) |
Check if type of a lua_Object is string.
_id | of stack position |
Definition at line 224 of file K3dLua.cpp.
References m_pLua.
Referenced by K3dConfDataBuild::LoadConf().
void K3dLua::LuaPushString | ( | const char * | strKey | ) |
Push string key to stack.
strKey | String key |
Definition at line 231 of file K3dLua.cpp.
References LuaCheckStack(), and m_pLua.
void K3dLua::LuaPop | ( | const int | _id | ) |
Pop value from stack.
_id | of stack position |
Definition at line 245 of file K3dLua.cpp.
References m_pLua.
void K3dLua::LuaGetTable | ( | const int | _id | ) |
Read a value from a table that resides somewhere in the stack.
Definition at line 251 of file K3dLua.cpp.
References m_pLua.
double K3dLua::LuaGetFieldNumber | ( | const char * | _strKey | ) |
Get double value from table field.
_strKey | Field string key |
double | Double value |
Definition at line 259 of file K3dLua.cpp.
References K3dString::GetString(), LuaCheckStack(), LuaError(), and m_pLua.
Referenced by K3dGui::CreateDropDown(), K3dGui::CreateListBox(), K3dGui::CreateScrollArea(), K3dBlockBuild::LoadBlocks(), K3dCameraBuild::LoadCameras(), K3dFaceBuild::LoadFaces(), K3dOptions::LoadGraphics(), K3dGui::LoadGuiButtons(), K3dGui::LoadGuiCheckBoxes(), K3dGui::LoadGuiContainers(), K3dGui::LoadGuiLabels(), K3dGui::LoadGuiListModels(), K3dGui::LoadGuiRadioButtons(), K3dGui::LoadGuiSliders(), K3dGui::LoadGuiTextFields(), K3dGui::LoadGuiWindows(), K2dImageBuild::LoadImages(), K3dLineBuild::LoadLines(), K3dPlaneBuild::LoadPlanes(), K3dRayBuild::LoadRays(), K3dSphereBuild::LoadSpheres(), K3dOptions::LoadTexture(), and K3dVertexBuild::LoadVertices().
bool K3dLua::LuaGetFieldBool | ( | const char * | _strKey | ) |
Get bool value from table field.
_strKey | Field string key |
bool | Bool value |
Definition at line 290 of file K3dLua.cpp.
References K3dString::GetString(), LuaCheckStack(), LuaError(), and m_pLua.
Referenced by K3dCameraBuild::LoadCameras(), K3dOptions::LoadFontBmp(), K3dOptions::LoadGraphics(), K3dGui::LoadGuiCheckBoxes(), K3dGui::LoadGuiContainers(), K3dGui::LoadGuiIcons(), K3dGui::LoadGuiRadioButtons(), K3dGui::LoadGuiWindows(), K2dImageBuild::LoadImages(), and K3dOptions::LoadTexture().
const char * K3dLua::LuaGetFieldString | ( | const char * | _strKey | ) |
Get bool value from table field.
_strKey | Field string key |
bool | Bool value |
Definition at line 321 of file K3dLua.cpp.
References K3dString::GetString(), LuaCheckStack(), LuaError(), and m_pLua.
Referenced by K3dGui::CreateDropDown(), K3dGui::CreateListBox(), K3dGui::CreateScrollArea(), K3dBlockBuild::LoadBlocks(), K3dFontBmp::LoadBmpFonts(), K3dCameraBuild::LoadCameras(), K3dConfDataBuild::LoadConf(), K3dFaceBuild::LoadFaces(), K3dGui::LoadGuiButtons(), K3dGui::LoadGuiCheckBoxes(), K3dGui::LoadGuiContainers(), K3dGui::LoadGuiDropDown(), K3dGui::LoadGuiFonts(), K3dGui::LoadGuiIcons(), K3dGui::LoadGuiImages(), K3dGui::LoadGuiLabels(), K3dGui::LoadGuiListBoxes(), K3dGui::LoadGuiListModels(), K3dGui::LoadGuiRadioButtons(), K3dGui::LoadGuiScrollAreas(), K3dGui::LoadGuiSliders(), K3dGui::LoadGuiTextBoxes(), K3dGui::LoadGuiTextFields(), K3dGui::LoadGuiWindows(), K2dImageBuild::LoadImages(), K3dKeyMapBuild::LoadKeyMap(), K3dLineBuild::LoadLines(), K3dPlaneBuild::LoadPlanes(), K3dRayBuild::LoadRays(), K3dOptions::LoadScript(), K3dSphereBuild::LoadSpheres(), K3dTextureBuild::LoadTextures(), and K3dVertexBuild::LoadVertices().
int K3dLua::LuaIsTable | ( | const int | _id | ) |
Get positive if is valid table.
_id | of stack position |
Definition at line 352 of file K3dLua.cpp.
References m_pLua.
Referenced by K3dBlockBuild::LoadBlocks(), K3dFontBmp::LoadBmpFonts(), K3dCameraBuild::LoadCameras(), K3dConfDataBuild::LoadConf(), K3dFaceBuild::LoadFaces(), K3dOptions::LoadFontBmp(), K3dOptions::LoadGraphics(), K3dGui::LoadGuiButtons(), K3dGui::LoadGuiCheckBoxes(), K3dGui::LoadGuiContainers(), K3dGui::LoadGuiDropDown(), K3dGui::LoadGuiFonts(), K3dGui::LoadGuiIcons(), K3dGui::LoadGuiImages(), K3dGui::LoadGuiLabels(), K3dGui::LoadGuiListBoxes(), K3dGui::LoadGuiListModels(), K3dGui::LoadGuiRadioButtons(), K3dGui::LoadGuiScrollAreas(), K3dGui::LoadGuiSliders(), K3dGui::LoadGuiTextBoxes(), K3dGui::LoadGuiTextFields(), K3dGui::LoadGuiWindows(), K2dImageBuild::LoadImages(), K3dKeyMapBuild::LoadKeyMap(), K3dLineBuild::LoadLines(), K3dPlaneBuild::LoadPlanes(), K3dRayBuild::LoadRays(), K3dOptions::LoadScript(), K3dSphereBuild::LoadSpheres(), K3dOptions::LoadTexture(), K3dTextureBuild::LoadTextures(), and K3dVertexBuild::LoadVertices().
bool K3dLua::LuaCheckStack | ( | const int | _iNum | ) |
Check if is free space in stack for number of values.
_iNum | Number of values where will be pushed to the stack |
bool | True if free space in stack, false if stack overflow |
Definition at line 391 of file K3dLua.cpp.
References m_pLua.
Referenced by K3dVM::K3d_AddVertex(), K3dVM::K3d_ButtonIsPressed(), K3dVM::K3d_GetAimRay(), K3dVM::K3d_GetCamDir(), K3dVM::K3d_GetCamPos(), K3dVM::K3d_GetDistance(), K3dVM::K3d_GetGuiObject(), K3dVM::K3d_GetIntersection(), K3dVM::K3d_GetObject(), K3dVM::K3d_GetRayOrigDir(), K3dVM::K3d_GetSpherePos(), K3dVM::K3d_IsMouseLeft(), K3dVM::K3d_IsMouseLeftUp(), K3dVM::K3d_IsMouseRight(), K3dVM::K3d_IsMouseRightUp(), K3dVM::K3d_Wait(), LuaGetFieldBool(), LuaGetFieldNumber(), LuaGetFieldString(), LuaGetGlobal(), and LuaPushString().
bool K3dLua::LuaCheckStack | ( | lua_State * | _pState, | |
const int | _iNum | |||
) |
Check if is free space in stack for number of values.
_iNum | Number of values where will be pushed to the stack | |
_pState | Lua state |
bool | True if free space in stack, false if stack overflow |
Definition at line 400 of file K3dLua.cpp.
lua_State* K3dLua::GetLuaState | ( | ) | [inline] |
Definition at line 90 of file K3dLua.h.
References m_pLua.
Referenced by K3dVM::Engine_Delete(), K3dVM::Engine_Init(), K3dVM::Engine_Update(), and K3dVM::K3d_LoadMap().
K3dGameData* K3dLua::m_pGameData [private] |
lua_State* K3dLua::m_pLua [private] |
Pointer to Lua state.
Definition at line 56 of file K3dLua.h.
Referenced by DeleteLua(), GetLuaState(), InitLua(), K3dLua(), LuaCheckStack(), LuaGetFieldBool(), LuaGetFieldNumber(), LuaGetFieldString(), LuaGetGlobal(), LuaGetTable(), LuaIsBoolean(), LuaIsNumber(), LuaIsString(), LuaIsTable(), LuaLoadFile(), LuaPCall(), LuaPop(), LuaPushString(), LuaRegister(), LuaToBoolean(), LuaToNumber(), LuaToString(), and StackDump().
lua_Debug* K3dLua::m_pLuaDebug [private] |