Definition at line 18 of file ScriptState.h.
Public Member Functions | |
ScriptState () | |
~ScriptState () | |
void | doFile (const Path &file) |
Process script file. | |
void | doString (const std::string &input) |
Process string. | |
bool | callCommand (int funcRef, int param) |
Call "bool function(param)" function. | |
void | unref (int funcRef) |
Remove function from registry. | |
void | registerFunc (const char *name, lua_CFunction func) |
void | registerLeader (Scripter *leader) |
Register light userdata for lua script. |
|
Definition at line 23 of file ScriptState.cpp. 00024 { 00025 m_state = lua_open(); 00026 luaopen_base(m_state); 00027 luaopen_string(m_state); 00028 luaopen_math(m_state); 00029 luaopen_table(m_state); 00030 00031 prepareErrorHandler(); 00032 }
|
|
Definition at line 34 of file ScriptState.cpp. 00035 { 00036 lua_close(m_state); 00037 }
|
|
Call "bool function(param)" function.
Definition at line 128 of file ScriptState.cpp. 00129 { 00130 int numResults = 1; 00131 lua_rawgeti(m_state, LUA_REGISTRYINDEX, funcRef); 00132 lua_pushnumber(m_state, param); 00133 callStack(0, 1, numResults); 00134 00135 if (0 == lua_isboolean(m_state, -1)) { 00136 const char *type = lua_typename(m_state, lua_type(m_state, -1)); 00137 lua_pop(m_state, numResults); 00138 throw ScriptException( 00139 ExInfo("script command failure - boolean expected") 00140 .addInfo("got", type)); 00141 } 00142 bool result = lua_toboolean(m_state, -1); 00143 lua_pop(m_state, numResults); 00144 return result; 00145 }
|
|
Process script file.
Definition at line 95 of file ScriptState.cpp. 00096 { 00097 int error = luaL_loadfile(m_state, file.getNative().c_str()); 00098 callStack(error); 00099 }
|
|
Process string.
Definition at line 106 of file ScriptState.cpp. 00107 {
00108 int error = luaL_loadbuffer(m_state, input.c_str(), input.size(),
00109 input.c_str());
00110 callStack(error);
00111 }
|
|
Definition at line 114 of file ScriptState.cpp. 00115 { 00116 lua_register(m_state, name, func); 00117 }
|
|
Register light userdata for lua script.
Definition at line 162 of file ScriptState.cpp. 00163 { 00164 lua_pushstring(m_state, script_getLeaderName()); 00165 lua_pushlightuserdata(m_state, leader); 00166 lua_rawset(m_state, LUA_REGISTRYINDEX); 00167 }
|
|
Remove function from registry.
Definition at line 152 of file ScriptState.cpp. 00153 { 00154 luaL_unref(m_state, LUA_REGISTRYINDEX, funcRef); 00155 }
|