summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-02-14 23:44:20 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-02-14 23:44:20 +0100
commitf41fc409959c5c050c3774c654e655589e744e22 (patch)
treef17ae2a95c112f96961502ac61dc4ea3fbca1c52 /src
parent969de84c135ed73db31aa96ef12fe1d589460aed (diff)
downloadrpgedit-f41fc409959c5c050c3774c654e655589e744e22.tar
rpgedit-f41fc409959c5c050c3774c654e655589e744e22.zip
Make calling ScriptContext::run nicer
Diffstat (limited to 'src')
-rw-r--r--src/control/MapContext.cpp3
-rw-r--r--src/control/ScriptContext.hpp30
2 files changed, 26 insertions, 7 deletions
diff --git a/src/control/MapContext.cpp b/src/control/MapContext.cpp
index 8065b04..246ee96 100644
--- a/src/control/MapContext.cpp
+++ b/src/control/MapContext.cpp
@@ -87,8 +87,7 @@ void MapContext::interact(uint64_t time) {
if (interactScript.first.empty())
return;
- Model::ScriptNumber scriptTime(time);
- scriptContext->run(interactScript.first, interactScript.second, nullptr, &scriptTime);
+ scriptContext->run(interactScript.first, interactScript.second, nullptr, time);
}
void MapContext::keyPressed(uint16_t key, uint64_t time) {
diff --git a/src/control/ScriptContext.hpp b/src/control/ScriptContext.hpp
index 9416d0e..13279ec 100644
--- a/src/control/ScriptContext.hpp
+++ b/src/control/ScriptContext.hpp
@@ -59,12 +59,32 @@ private:
}
template<typename... Args>
- size_t pushArgs(Model::ScriptValue *v, Args ...args) {
- if (v)
- v->push(L);
- else
- lua_pushnil(L);
+ size_t pushArgs(std::nullptr_t __attribute__((unused)) v, Args ...args) {
+ 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;
}