summaryrefslogtreecommitdiff
path: root/src/scripting
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-13 20:44:25 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-13 20:44:25 +0000
commit01e3326de8fc03cf9f61fd1b288cd4f16915484c (patch)
tree583a1be3466994767dad82a77fab21b85d9356a7 /src/scripting
parentd95c2fbf8fc3fd45b03e27aa802f7886cd930a5e (diff)
downloadmanaserv-01e3326de8fc03cf9f61fd1b288cd4f16915484c.tar.gz
manaserv-01e3326de8fc03cf9f61fd1b288cd4f16915484c.tar.bz2
manaserv-01e3326de8fc03cf9f61fd1b288cd4f16915484c.tar.xz
manaserv-01e3326de8fc03cf9f61fd1b288cd4f16915484c.zip
Implemented buy/sell handler.
Diffstat (limited to 'src/scripting')
-rw-r--r--src/scripting/lua.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 1fdd90e4..636417f9 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -30,6 +30,7 @@ extern "C" {
#include "defines.h"
#include "resourcemanager.h"
+#include "game-server/buysell.hpp"
#include "game-server/character.hpp"
#include "game-server/gamehandler.hpp"
#include "game-server/inventory.hpp"
@@ -299,6 +300,35 @@ static int LuaChr_InvCount(lua_State *s)
return nb_items;
}
+// For testing purpose.
+static int test_NpcBuy(lua_State *s)
+{
+ NPC *p = getNPC(s, 1);
+ Character *q = getCharacter(s, 2);
+ if (!p || !q) return 0;
+ BuySell *t = new BuySell(q, false);
+ t->registerItem(533, 10, 20);
+ t->registerItem(535, 10, 30);
+ t->registerItem(537, 10, 50);
+ t->start(p);
+ return 0;
+}
+
+// For testing purpose.
+static int test_NpcSell(lua_State *s)
+{
+ NPC *p = getNPC(s, 1);
+ Character *q = getCharacter(s, 2);
+ if (!p || !q) return 0;
+ BuySell *t = new BuySell(q, true);
+ t->registerItem(511, 10, 200);
+ t->registerItem(524, 10, 300);
+ t->registerItem(508, 10, 500);
+ t->registerItem(537, 10, 25);
+ t->start(p);
+ return 0;
+}
+
LuaScript::LuaScript(lua_State *s):
mState(s),
nbArgs(-1)
@@ -322,6 +352,8 @@ LuaScript::LuaScript(lua_State *s):
{ "chr_warp", &LuaChr_Warp },
{ "chr_inv_change", &LuaChr_InvChange },
{ "chr_inv_count", &LuaChr_InvCount },
+ { "test_npc_buy", &test_NpcBuy },
+ { "test_npc_sell", &test_NpcSell },
{ NULL, NULL }
};
luaL_register(mState, "tmw", callbacks);