Make calling ScriptContext::run nicer
This commit is contained in:
parent
969de84c13
commit
f41fc40995
2 changed files with 26 additions and 7 deletions
|
@ -87,8 +87,7 @@ void MapContext::interact(uint64_t time) {
|
||||||
if (interactScript.first.empty())
|
if (interactScript.first.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Model::ScriptNumber scriptTime(time);
|
scriptContext->run(interactScript.first, interactScript.second, nullptr, time);
|
||||||
scriptContext->run(interactScript.first, interactScript.second, nullptr, &scriptTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapContext::keyPressed(uint16_t key, uint64_t time) {
|
void MapContext::keyPressed(uint16_t key, uint64_t time) {
|
||||||
|
|
|
@ -59,12 +59,32 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
size_t pushArgs(Model::ScriptValue *v, Args ...args) {
|
size_t pushArgs(std::nullptr_t __attribute__((unused)) v, Args ...args) {
|
||||||
if (v)
|
|
||||||
v->push(L);
|
|
||||||
else
|
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
return pushArgs(args...) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
size_t pushArgs(const std::string &v, Args ...args) {
|
||||||
|
lua_pushstring(L, v.c_str());
|
||||||
|
return pushArgs(args...) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename... Args>
|
||||||
|
size_t pushArgs(T v, Args ...args) {
|
||||||
|
lua_pushnumber(L, v);
|
||||||
|
return pushArgs(args...) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
size_t pushArgs(bool v, Args ...args) {
|
||||||
|
lua_pushboolean(L, v);
|
||||||
|
return pushArgs(args...) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
size_t pushArgs(Model::ScriptValue &v, Args ...args) {
|
||||||
|
v.push(L);
|
||||||
return pushArgs(args...) + 1;
|
return pushArgs(args...) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue