summaryrefslogtreecommitdiffstats
path: root/src/scripting/script.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/scripting/script.cpp')
-rw-r--r--src/scripting/script.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/scripting/script.cpp b/src/scripting/script.cpp
index 12aa0d1..3e19305 100644
--- a/src/scripting/script.cpp
+++ b/src/scripting/script.cpp
@@ -23,9 +23,11 @@
#include <map>
-#include "utils/logger.h"
#include "scripting/script.hpp"
+#include "resourcemanager.h"
+#include "utils/logger.h"
+
typedef std::map< std::string, Script::Factory > Engines;
static Engines *engines = NULL;
@@ -60,3 +62,24 @@ void Script::update()
execute();
}
+void Script::loadFile(std::string const &name)
+{
+ ResourceManager *resman = ResourceManager::getInstance();
+ int size;
+ char *buffer = (char *)resman->loadFile(name, size);
+ if (buffer)
+ {
+ load(buffer);
+ free(buffer);
+ }
+}
+
+void Script::loadNPC(int id, int x, int y, char const *prog)
+{
+ load(prog);
+ prepare("create_npc_delayed");
+ push(id);
+ push(x);
+ push(y);
+ execute();
+}