MCPcopy Create free account
hub / github.com/CelestiaProject/Celestia / SetLuaVariables

Function SetLuaVariables

src/celengine/scriptobject.cpp:98–125  ·  view source on GitHub ↗

! Convert all the parameters in an AssociativeArray to their equivalent Lua * types and insert them into the table on the top of the stack. Presently, * only number, string, and boolean values are converted. */

Source from the content-addressed store, hash-verified

96 * only number, string, and boolean values are converted.
97 */
98void
99SetLuaVariables(lua_State* state, Hash* parameters)
100{
101 for (HashIterator iter = parameters->begin(); iter != parameters->end();
102 iter++)
103 {
104 switch (iter->second->getType())
105 {
106 case Value::NumberType:
107 lua_pushstring(state, iter->first.c_str());
108 lua_pushnumber(state, iter->second->getNumber());
109 lua_settable(state, -3);
110 break;
111 case Value::StringType:
112 lua_pushstring(state, iter->first.c_str());
113 lua_pushstring(state, iter->second->getString().c_str());
114 lua_settable(state, -3);
115 break;
116 case Value::BooleanType:
117 lua_pushstring(state, iter->first.c_str());
118 lua_pushboolean(state, iter->second->getBoolean());
119 lua_settable(state, -3);
120 break;
121 default:
122 break;
123 }
124 }
125}

Callers 1

initializeMethod · 0.85

Calls 6

getNumberMethod · 0.80
getStringMethod · 0.80
getBooleanMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected