summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--data/scripts/libs/libtmw.lua (renamed from data/scripts/libtmw.lua)0
-rw-r--r--data/scripts/libs/npclib.lua (renamed from data/scripts/npclib.lua)188
-rw-r--r--data/scripts/test.lua (renamed from data/test.lua)12
-rw-r--r--src/scripting/lua.cpp2
5 files changed, 109 insertions, 101 deletions
diff --git a/ChangeLog b/ChangeLog
index 9a518726..6c94efdc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-10-21 Roderic Morris <roderic@ccs.neu.edu>
+
+ * src/scripting/lua.cpp, data/test.lua, data/scripts/test.lua,
+ data/scripts/npclib.lua, data/scripts/libs, data/scripts/libs/npclib.lua,
+ data/scripts/libs/libtmw.lua, data/scripts/libtmw.lua:
+ Changed the ordering of lua scripts in preperation for content
+ conversion.
+
2008-10-21 Bjørn Lindeijer <bjorn@lindeijer.nl>
* src/account-server/account.cpp, src/chat-server/post.cpp,
diff --git a/data/scripts/libtmw.lua b/data/scripts/libs/libtmw.lua
index 5b1792f9..5b1792f9 100644
--- a/data/scripts/libtmw.lua
+++ b/data/scripts/libs/libtmw.lua
diff --git a/data/scripts/npclib.lua b/data/scripts/libs/npclib.lua
index 95857e4f..e85ddc56 100644
--- a/data/scripts/npclib.lua
+++ b/data/scripts/libs/npclib.lua
@@ -1,95 +1,95 @@
-----------------------------------------------------------
--- Library for commonly used NPC scripts --
--- --
--- --
--- Any NPC update function or talk function which could --
--- be used for NPCs on more than one map should be --
--- placed here. --
--- --
-----------------------------------------------------------------------------------
--- Copyright 2008 The Mana World Development Team --
--- --
--- This file is part of The Mana World. --
--- --
--- The Mana World is free software; you can redistribute it and/or modify it --
--- under the terms of the GNU General Public License as published by the Free --
--- Software Foundation; either version 2 of the License, or any later version. --
-----------------------------------------------------------------------------------
-
-module("npclib", package.seeall);
-
-
--- Update function walkaround_small
--- makes the NPC walk around in a 64x64 pixel square around its start location.
--- Useful for NPCs which are supposed to stay on a specific spot but
--- move a bit from time to time.
-
-local wasmall_timer = {}
-local wasmall_startx = {}
-local wasmall_starty = {}
-
-function walkaround_small(npc)
- if not wasmall_timer[npc] then
- wasmall_timer[npc] = 1
- wasmall_startx[npc] = tmw.posX(npc)
- wasmall_starty[npc] = tmw.posY(npc)
- end
-
- wasmall_timer[npc] = wasmall_timer[npc] + 1
-
- if wasmall_timer[npc] == 100 then
- wasmall_timer[npc] = math.random(1, 10)
- local x = math.random(-32, 32) + wasmall_startx[npc]
- local y = math.random(-32, 32) + wasmall_starty[npc]
- tmw.being_walk(npc, x, y, 500)
- end
-end
-
-
--- Update function walkaround_wide
--- makes the NPC walk around in a 256x256 pixel square around its start
--- location. Useful for NPCs which are supposed to be found near a specific
--- location but not nailed to the floor.
-
-local wawide_timer = {}
-local wawide_startx = {}
-local wawide_starty = {}
-
-function walkaround_wide(npc)
- if not wawide_timer[npc] then
- wawide_timer[npc] = 1
- wawide_startx[npc] = tmw.posX(npc)
- wawide_starty[npc] = tmw.posY(npc)
- end
-
- wawide_timer[npc] = wawide_timer[npc] + 1
-
- if wawide_timer[npc] == 50 then
- wawide_timer[npc] = math.random(1, 10)
- local x = math.random(-128, 128) + wawide_startx[npc]
- local y = math.random(-128, 128) + wawide_starty[npc]
- tmw.being_walk(npc, x, y, 500)
- end
-end
-
-
--- Update function walkaround_map
--- makes the NPC wander around the whole map. Useful when the players are
--- supposed to search a bit for the NPC.
-
-local wam_timer = {}
-
-function walkaround_map(npc)
- if not wam_timer[npc] then
- wam_timer[npc] = 1
- end
-
- wam_timer[npc] = wam_timer[npc] + 1
-
- if wam_timer[npc] == 50 then
- wam_timer[npc] = math.random(1, 10)
- local x = math.random(-128, 128) + tmw.posX(npc)
- local y = math.random(-128, 128) + tmw.posY(npc)
- tmw.being_walk(npc, x, y, 500)
- end
+----------------------------------------------------------
+-- Library for commonly used NPC scripts --
+-- --
+-- --
+-- Any NPC update function or talk function which could --
+-- be used for NPCs on more than one map should be --
+-- placed here. --
+-- --
+----------------------------------------------------------------------------------
+-- Copyright 2008 The Mana World Development Team --
+-- --
+-- This file is part of The Mana World. --
+-- --
+-- The Mana World is free software; you can redistribute it and/or modify it --
+-- under the terms of the GNU General Public License as published by the Free --
+-- Software Foundation; either version 2 of the License, or any later version. --
+----------------------------------------------------------------------------------
+
+module("npclib", package.seeall);
+
+
+-- Update function walkaround_small
+-- makes the NPC walk around in a 64x64 pixel square around its start location.
+-- Useful for NPCs which are supposed to stay on a specific spot but
+-- move a bit from time to time.
+
+local wasmall_timer = {}
+local wasmall_startx = {}
+local wasmall_starty = {}
+
+function walkaround_small(npc)
+ if not wasmall_timer[npc] then
+ wasmall_timer[npc] = 1
+ wasmall_startx[npc] = tmw.posX(npc)
+ wasmall_starty[npc] = tmw.posY(npc)
+ end
+
+ wasmall_timer[npc] = wasmall_timer[npc] + 1
+
+ if wasmall_timer[npc] == 100 then
+ wasmall_timer[npc] = math.random(1, 10)
+ local x = math.random(-32, 32) + wasmall_startx[npc]
+ local y = math.random(-32, 32) + wasmall_starty[npc]
+ tmw.being_walk(npc, x, y, 500)
+ end
+end
+
+
+-- Update function walkaround_wide
+-- makes the NPC walk around in a 256x256 pixel square around its start
+-- location. Useful for NPCs which are supposed to be found near a specific
+-- location but not nailed to the floor.
+
+local wawide_timer = {}
+local wawide_startx = {}
+local wawide_starty = {}
+
+function walkaround_wide(npc)
+ if not wawide_timer[npc] then
+ wawide_timer[npc] = 1
+ wawide_startx[npc] = tmw.posX(npc)
+ wawide_starty[npc] = tmw.posY(npc)
+ end
+
+ wawide_timer[npc] = wawide_timer[npc] + 1
+
+ if wawide_timer[npc] == 50 then
+ wawide_timer[npc] = math.random(1, 10)
+ local x = math.random(-128, 128) + wawide_startx[npc]
+ local y = math.random(-128, 128) + wawide_starty[npc]
+ tmw.being_walk(npc, x, y, 500)
+ end
+end
+
+
+-- Update function walkaround_map
+-- makes the NPC wander around the whole map. Useful when the players are
+-- supposed to search a bit for the NPC.
+
+local wam_timer = {}
+
+function walkaround_map(npc)
+ if not wam_timer[npc] then
+ wam_timer[npc] = 1
+ end
+
+ wam_timer[npc] = wam_timer[npc] + 1
+
+ if wam_timer[npc] == 50 then
+ wam_timer[npc] = math.random(1, 10)
+ local x = math.random(-128, 128) + tmw.posX(npc)
+ local y = math.random(-128, 128) + tmw.posY(npc)
+ tmw.being_walk(npc, x, y, 500)
+ end
end \ No newline at end of file
diff --git a/data/test.lua b/data/scripts/test.lua
index cd624822..4dcb9eb6 100644
--- a/data/test.lua
+++ b/data/scripts/test.lua
@@ -15,7 +15,7 @@
-- Software Foundation; either version 2 of the License, or any later version. --
----------------------------------------------------------------------------------
-require "data/scripts/npclib"
+require "data/scripts/libs/npclib"
atinit(function()
create_npc("Test NPC", 200, 50 * TILESIZE + 16, 19 * TILESIZE + 16, npc1_talk, npclib.walkaround_small)
@@ -23,10 +23,10 @@ atinit(function()
create_npc("Scorpion Tamer", 126, 45 * TILESIZE + 16, 25 * TILESIZE + 16, npc5_talk, nil)
create_npc("Guard", 122, 58 * TILESIZE + 16, 15 * TILESIZE + 16, npc6_talk, npc6_update)
create_npc("Fire Demon", 202, 58 * TILESIZE + 16, 35 * TILESIZE + 16, firedemon_talk, firedemon_update)
-
+
tmw.trigger_create(56 * TILESIZE, 32 * TILESIZE, 64, 64, "patrol_waypoint", 1, true)
tmw.trigger_create(63 * TILESIZE, 32 * TILESIZE, 64, 64, "patrol_waypoint", 2, true)
-
+
schedule_every(1 * HOURS + 30 * MINUTES, function()
print("One and a half hour has passed on map 1-1")
end)
@@ -124,13 +124,13 @@ function npc5_talk(npc, ch)
m2 = tmw.monster_create(1, x - TILESIZE, y + TILESIZE)
m3 = tmw.monster_create(1, x + TILESIZE, y - TILESIZE)
m4 = tmw.monster_create(1, x - TILESIZE, y - TILESIZE)
-
+
on_death(m1, function() tmw.being_say(npc, "NOOO!") end)
on_death(m2, function() tmw.being_say(npc, "Please stop this violence!") end)
on_death(m3, function() tmw.being_say(npc, "Stop slaughtering my scorpions!") end)
on_death(m4, function() tmw.being_say(npc, "Leave my scorpions alone!") end)
on_death(m4, function() tmw.being_say(m4, "AAARGH!") end)
-
+
end
end
@@ -178,6 +178,6 @@ function firedemon_update(npc)
i = i + 1
end
end
-
+
npclib.walkaround_map(npc)
end
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 38f5cd25..330e8198 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -787,7 +787,7 @@ LuaScript::LuaScript():
lua_settable(mState, LUA_REGISTRYINDEX);
lua_settop(mState, 0);
- loadFile("scripts/libtmw.lua");
+ loadFile("scripts/libs/libtmw.lua");
}
LuaScript::~LuaScript()