summaryrefslogtreecommitdiff
path: root/src/scripting/luascript.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-03-10 23:38:36 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-03-11 16:56:56 +0100
commitb822dcee52d15d41c4186a250e73b85b16c9dc39 (patch)
tree45515c75175b67fe458701f3a70bf0ee8b14bee5 /src/scripting/luascript.cpp
parent2dd3c5c06978584e3e076609554f225ffbabd3e2 (diff)
downloadmanaserv-b822dcee52d15d41c4186a250e73b85b16c9dc39.tar.gz
manaserv-b822dcee52d15d41c4186a250e73b85b16c9dc39.tar.bz2
manaserv-b822dcee52d15d41c4186a250e73b85b16c9dc39.tar.xz
manaserv-b822dcee52d15d41c4186a250e73b85b16c9dc39.zip
Removed the create_npc wrapper and the last two NPC callbacks
When creating an NPC, you now provide its optional talk and update functions directly rather than them being stored in a table on the Lua side and then called in response to a global callback. Also fixed an issue with a missing gender parameter to the delayed NPC creation callback used by NPCs defined on the map (found by Erik while reviewing this patch). Reviewed-by: Erik Schilling
Diffstat (limited to 'src/scripting/luascript.cpp')
-rw-r--r--src/scripting/luascript.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/scripting/luascript.cpp b/src/scripting/luascript.cpp
index e45588b9..36adb912 100644
--- a/src/scripting/luascript.cpp
+++ b/src/scripting/luascript.cpp
@@ -198,6 +198,15 @@ void LuaScript::assignCallback(Script::Ref &function)
function.value = luaL_ref(mRootState, LUA_REGISTRYINDEX);
}
+void LuaScript::unref(Ref &ref)
+{
+ if (ref.isValid())
+ {
+ luaL_unref(mRootState, LUA_REGISTRYINDEX, ref.value);
+ ref.value = -1;
+ }
+}
+
void LuaScript::load(const char *prog, const char *name)
{
int res = luaL_loadbuffer(mRootState, prog, std::strlen(prog), name);
@@ -262,7 +271,7 @@ void LuaScript::getQuestCallback(Character *q,
script->prepareResume(thread);
script->push(value);
- script->resume();
+ q->resumeNpcThread();
}
/**
@@ -280,7 +289,7 @@ void LuaScript::getPostCallback(Character *q,
script->prepareResume(thread);
script->push(sender);
script->push(letter);
- script->resume();
+ q->resumeNpcThread();
}