diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-02-14 23:12:07 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-02-14 23:12:07 +0100 |
commit | 0b3e29dea9863c4b5ca0c77958bbcb32a05867ca (patch) | |
tree | f96454b1c29d73ee5c083b5b2fdb988bc574542d /src/model | |
parent | f05141f1f78d9e0d917b2cc07f0fb09fd7f62801 (diff) | |
download | rpgedit-0b3e29dea9863c4b5ca0c77958bbcb32a05867ca.tar rpgedit-0b3e29dea9863c4b5ca0c77958bbcb32a05867ca.zip |
Some work towards scriptable events
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/Entity.hpp | 15 | ||||
-rw-r--r-- | src/model/ScriptValue.hpp | 6 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/model/Entity.hpp b/src/model/Entity.hpp index fc1debb..b14e122 100644 --- a/src/model/Entity.hpp +++ b/src/model/Entity.hpp @@ -28,19 +28,23 @@ #include "Direction.hpp" +#include "Scriptable.hpp" #include <string> +#include <utility> namespace RPGEdit { namespace Model { -class Entity { +class Entity : public Scriptable { private: std::string name; + std::pair<std::string, std::string> scriptInteract; + Direction direction; public: @@ -60,8 +64,13 @@ public: direction = dir; } - void interact(uint64_t time) { - std::fprintf(stderr, "Tried to interact with `%s' entity at %llu\n", name.c_str(), (unsigned long long)time); + const std::pair<std::string, std::string> & getScriptInteract() const { + return scriptInteract; + } + + void setScriptInteract(const std::string &script, const std::string &name) { + scriptInteract.first = script; + scriptInteract.second = name; } }; diff --git a/src/model/ScriptValue.hpp b/src/model/ScriptValue.hpp index a82ba8e..04c4e55 100644 --- a/src/model/ScriptValue.hpp +++ b/src/model/ScriptValue.hpp @@ -116,13 +116,13 @@ public: class ScriptTable : public ScriptValue { public: - typedef std::unordered_map<std::string, std::shared_ptr<ScriptValue>> MapType; + typedef std::unordered_map<std::shared_ptr<ScriptValue>, std::shared_ptr<ScriptValue>> MapType; private: MapType value; public: - std::shared_ptr<ScriptValue> & operator[](const std::string &key) { + std::shared_ptr<ScriptValue> & operator[](const std::shared_ptr<ScriptValue> &key) { return value[key]; } @@ -130,7 +130,7 @@ public: lua_createtable(L, 0, value.size()); for (const auto &entry : value) { - lua_pushstring(L, entry.first.c_str()); + entry.first->push(L); entry.second->push(L); lua_settable(L, -3); |