summaryrefslogtreecommitdiff
path: root/example/scripts/npcs
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-03-11 18:16:16 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-03-11 19:27:32 +0100
commit5ff34fd2458dff28d664c90fb93f455231f8633c (patch)
tree533151e5f3002c1e24ce4d44e5cd32c66c026b51 /example/scripts/npcs
parentb822dcee52d15d41c4186a250e73b85b16c9dc39 (diff)
downloadmanaserv-5ff34fd2458dff28d664c90fb93f455231f8633c.tar.gz
manaserv-5ff34fd2458dff28d664c90fb93f455231f8633c.tar.bz2
manaserv-5ff34fd2458dff28d664c90fb93f455231f8633c.tar.xz
manaserv-5ff34fd2458dff28d664c90fb93f455231f8633c.zip
Register Lua script API functions into the global namespace
Scripts mostly execute the Mana script API, and it seems like just unnecessary verbosity to refer to the 'mana' table all the time. This table no longer exists now. Reviewed-by: Erik Schilling
Diffstat (limited to 'example/scripts/npcs')
-rw-r--r--example/scripts/npcs/banker.lua60
-rw-r--r--example/scripts/npcs/barber.lua20
-rw-r--r--example/scripts/npcs/debugger.lua68
-rw-r--r--example/scripts/npcs/emotemaker.lua6
-rw-r--r--example/scripts/npcs/healer.lua8
-rw-r--r--example/scripts/npcs/merchant.lua20
-rw-r--r--example/scripts/npcs/postman.lua18
-rw-r--r--example/scripts/npcs/shaker.lua14
8 files changed, 107 insertions, 107 deletions
diff --git a/example/scripts/npcs/banker.lua b/example/scripts/npcs/banker.lua
index 762e0bbe..e6e1e284 100644
--- a/example/scripts/npcs/banker.lua
+++ b/example/scripts/npcs/banker.lua
@@ -11,22 +11,22 @@
----------------------------------------------------------------------------------
function Banker(npc, ch)
- if mana.being_get_gender(ch) == GENDER_MALE then
- mana.npc_message(npc, ch, "Welcome to the bank, sir!")
- elseif mana.being_get_gender(ch) == GENDER_FEMALE then
- mana.npc_message(npc, ch, "Welcome to the bank, madam!")
+ if being_get_gender(ch) == GENDER_MALE then
+ npc_message(npc, ch, "Welcome to the bank, sir!")
+ elseif being_get_gender(ch) == GENDER_FEMALE then
+ npc_message(npc, ch, "Welcome to the bank, madam!")
else
- mana.npc_message(npc, ch, "Welcome to the bank... uhm... person of unspecified gender!")
+ npc_message(npc, ch, "Welcome to the bank... uhm... person of unspecified gender!")
end
- local account = tonumber(mana.chr_get_quest(ch, "BankAccount"))
+ local account = tonumber(chr_get_quest(ch, "BankAccount"))
local result = -1
if (account == nil) then --Initial account creation, if needed
- mana.npc_message(npc, ch, "Hello! Would you like to setup a bank account? There is a sign-on bonus right now!")
- result = mana.npc_choice(npc, ch, "Yes", "No")
+ npc_message(npc, ch, "Hello! Would you like to setup a bank account? There is a sign-on bonus right now!")
+ result = npc_choice(npc, ch, "Yes", "No")
if (result == 1) then
- mana.chr_set_quest(ch, "BankAccount", 5)
- mana.npc_message(npc, ch, "Your account has been made. Your sign-on bonus is 5GP.")
+ chr_set_quest(ch, "BankAccount", 5)
+ npc_message(npc, ch, "Your account has been made. Your sign-on bonus is 5GP.")
account = 5
end
end
@@ -36,42 +36,42 @@ function Banker(npc, ch)
local input = 0
result = 1
while (result < 3) do --While they've choosen a valid option that isn't "Never mind"
- account = tonumber(mana.chr_get_quest(ch, "BankAccount")) --Why do I need to convert this?
- mana.npc_message(npc, ch, "Your balance: " .. account .. ".\nYour money: " .. mana.chr_money(ch) .. ".")
- result = mana.npc_choice(npc, ch, "Deposit", "Withdraw", "Never mind")
+ account = tonumber(chr_get_quest(ch, "BankAccount")) --Why do I need to convert this?
+ npc_message(npc, ch, "Your balance: " .. account .. ".\nYour money: " .. chr_money(ch) .. ".")
+ result = npc_choice(npc, ch, "Deposit", "Withdraw", "Never mind")
if (result == 1) then --Deposit
- money = mana.chr_money(ch);
+ money = chr_money(ch);
if (money > 0) then --Make sure they have money to deposit
- mana.npc_message(npc, ch, "How much would you like to deposit? (0 will cancel)")
- input = mana.npc_ask_integer(npc, ch, 0, money, 1)
- money = mana.chr_money(ch)
+ npc_message(npc, ch, "How much would you like to deposit? (0 will cancel)")
+ input = npc_ask_integer(npc, ch, 0, money, 1)
+ money = chr_money(ch)
if (input > 0 and input <= money) then --Make sure something weird doesn't happen and they try to deposit more than they have
- mana.chr_money_change(ch, -input)
- mana.chr_set_quest(ch, "BankAccount", account + input)
- mana.npc_message(npc, ch, input .. " GP deposited.")
+ chr_money_change(ch, -input)
+ chr_set_quest(ch, "BankAccount", account + input)
+ npc_message(npc, ch, input .. " GP deposited.")
elseif (input > money) then --Chosen more than they have
- mana.npc_message(npc, ch, "You don't have that much money. But you just did....")
+ npc_message(npc, ch, "You don't have that much money. But you just did....")
end
else
- mana.npc_message(npc, ch, "You don't have any money to deposit!")
+ npc_message(npc, ch, "You don't have any money to deposit!")
end
elseif (result == 2) then --Withdraw
if (account > 0) then --Make sure they have money to withdraw
- mana.npc_message(npc, ch, "How much would you like to withdraw? (0 will cancel)")
- input = mana.npc_ask_integer(npc, ch, 0, account, 1)
+ npc_message(npc, ch, "How much would you like to withdraw? (0 will cancel)")
+ input = npc_ask_integer(npc, ch, 0, account, 1)
if (input > 0 and input <= account) then --Make sure something weird doesn't happen and they try to withdraw more than they have
- mana.chr_money_change(ch, input)
- mana.chr_set_quest(ch, "BankAccount", account - input)
- mana.npc_message(npc, ch, input .. " GP withdrawn.")
+ chr_money_change(ch, input)
+ chr_set_quest(ch, "BankAccount", account - input)
+ npc_message(npc, ch, input .. " GP withdrawn.")
elseif (input > account) then --Chosen more than they have
- mana.npc_message(npc, ch, "You don't have that much in your account. But you just did....")
+ npc_message(npc, ch, "You don't have that much in your account. But you just did....")
end
else
- mana.npc_message(npc, ch, "Your account is empty!")
+ npc_message(npc, ch, "Your account is empty!")
end
end
end --This ends the while loop
end
- mana.npc_message(npc, ch, "Thank you. Come again!")
+ npc_message(npc, ch, "Thank you. Come again!")
end
diff --git a/example/scripts/npcs/barber.lua b/example/scripts/npcs/barber.lua
index 79f92526..70efb435 100644
--- a/example/scripts/npcs/barber.lua
+++ b/example/scripts/npcs/barber.lua
@@ -79,11 +79,11 @@ function Barber(npc, ch, data)
-- Choose an appropriate message
if result == 1 then
- mana.npc_message(npc, ch, "Hello! What style would you like today?")
+ npc_message(npc, ch, "Hello! What style would you like today?")
elseif result == 2 then
- mana.npc_message(npc, ch, "Hello! What color would you like today?")
+ npc_message(npc, ch, "Hello! What color would you like today?")
else
- mana.npc_message(npc, ch, "Hello! What can I do for you today?")
+ npc_message(npc, ch, "Hello! What can I do for you today?")
end
print("#styles ==", #styles)
@@ -91,7 +91,7 @@ function Barber(npc, ch, data)
-- Repeat until the user selects nothing
repeat
if (result == 1) then -- Do styles
- result = mana.npc_choice(npc, ch, "Bald", styles, "Surprise me", "Never mind")
+ result = npc_choice(npc, ch, "Bald", styles, "Surprise me", "Never mind")
result = result -1
@@ -104,16 +104,16 @@ function Barber(npc, ch, data)
print("Style ==", result)
if (result == 0) then
- mana.chr_set_hair_style(ch, 0)
+ chr_set_hair_style(ch, 0)
result = 1
elseif (result <= #styles) then
- mana.chr_set_hair_style(ch, style_ids[result])
+ chr_set_hair_style(ch, style_ids[result])
result = 1
else --"Never mind"
result = 3
end
elseif (result == 2) then -- Do colors
- result = mana.npc_choice(npc, ch, colors, "Surprise me", "Never mind")
+ result = npc_choice(npc, ch, colors, "Surprise me", "Never mind")
--Random
if (result == #colors + 1) then
@@ -121,7 +121,7 @@ function Barber(npc, ch, data)
end
if (result <= #colors) then
- mana.chr_set_hair_color(ch, color_ids[result - 1])
+ chr_set_hair_color(ch, color_ids[result - 1])
result = 2
else --"Never mind"
result = 3
@@ -130,10 +130,10 @@ function Barber(npc, ch, data)
-- If we have both styles and colors, show the main menu
if #styles > 0 and #colors > 0 then
- result = mana.npc_choice(npc, ch, "Change my style", "Change my color", "Never mind")
+ result = npc_choice(npc, ch, "Change my style", "Change my color", "Never mind")
end
until result >= 3 --While they've choosen a valid option that isn't "Never mind"
-- Let's close up
- mana.npc_message(npc, ch, "Thank you. Come again!")
+ npc_message(npc, ch, "Thank you. Come again!")
end
diff --git a/example/scripts/npcs/debugger.lua b/example/scripts/npcs/debugger.lua
index 80f765c9..621ba0f6 100644
--- a/example/scripts/npcs/debugger.lua
+++ b/example/scripts/npcs/debugger.lua
@@ -12,67 +12,67 @@
function npc1_talk(npc, ch)
on_remove(ch, function() print "Player has left the map." end);
- mana.npc_message(npc, ch, "Hello! I am the testing NPC.")
- local rights = mana.chr_get_rights(ch);
+ npc_message(npc, ch, "Hello! I am the testing NPC.")
+ local rights = chr_get_rights(ch);
if (rights >= 128) then
- mana.npc_message(npc, ch, "Oh mighty server administrator, how can I avoid your wrath?")
+ npc_message(npc, ch, "Oh mighty server administrator, how can I avoid your wrath?")
elseif (rights >= 8) then
- mana.npc_message(npc, ch, "How can I be of assistance, sir gamemaster?")
+ npc_message(npc, ch, "How can I be of assistance, sir gamemaster?")
elseif (rights >= 4) then
- mana.npc_message(npc, ch, "What feature would you like to debug, developer?")
+ npc_message(npc, ch, "What feature would you like to debug, developer?")
elseif (rights >= 2) then
- mana.npc_message(npc, ch, "How can I assist you in your testing duties?")
+ npc_message(npc, ch, "How can I assist you in your testing duties?")
elseif (rights >= 1) then
- mana.npc_message(npc, ch, "What do you want, lowly player?")
+ npc_message(npc, ch, "What do you want, lowly player?")
else
- mana.npc_message(npc, ch, "...aren't you supposed to be banned??")
+ npc_message(npc, ch, "...aren't you supposed to be banned??")
end
- local v = mana.npc_choice(npc, ch, "Guns! Lots of guns!",
+ local v = npc_choice(npc, ch, "Guns! Lots of guns!",
"A Christmas party!",
"To make a donation.",
"Slowly count from one to ten.",
"Tablepush Test")
if v == 1 then
- mana.npc_message(npc, ch, "Sorry, this is a heroic-fantasy game, I do not have any gun.")
+ npc_message(npc, ch, "Sorry, this is a heroic-fantasy game, I do not have any gun.")
elseif v == 2 then
- local n1, n2 = mana.chr_inv_count(ch, 524, 511)
+ local n1, n2 = chr_inv_count(ch, 524, 511)
if n1 == 0 or n2 ~= 0 then
- mana.npc_message(npc, ch, "Yeah right...")
+ npc_message(npc, ch, "Yeah right...")
else
- mana.npc_message(npc, ch, "I can't help you with the party. But I see you have a fancy hat. I could change it into Santa's hat. Not much of a party, but it would get you going.")
- v = mana.npc_choice(npc, ch, "Please do.", "No way! Fancy hats are classier.")
+ npc_message(npc, ch, "I can't help you with the party. But I see you have a fancy hat. I could change it into Santa's hat. Not much of a party, but it would get you going.")
+ v = npc_choice(npc, ch, "Please do.", "No way! Fancy hats are classier.")
if v == 1 then
- mana.chr_inv_change(ch, 524, -1, 511, 1)
+ chr_inv_change(ch, 524, -1, 511, 1)
end
end
elseif v == 3 then
- if mana.chr_money_change(ch, -100) then
- mana.npc_message(npc, ch, string.format("Thank you for you patronage! You are left with %d GP.", mana.chr_money(ch)))
- local g = tonumber(mana.chr_get_quest(ch, "001_donation"))
+ if chr_money_change(ch, -100) then
+ npc_message(npc, ch, string.format("Thank you for you patronage! You are left with %d GP.", chr_money(ch)))
+ local g = tonumber(chr_get_quest(ch, "001_donation"))
if not g then g = 0 end
g = g + 100
- mana.chr_set_quest(ch, "001_donation", g)
- mana.npc_message(npc, ch, string.format("As of today, you have donated %d GP.", g))
+ chr_set_quest(ch, "001_donation", g)
+ npc_message(npc, ch, string.format("As of today, you have donated %d GP.", g))
else
- mana.npc_message(npc, ch, "I would feel bad taking money from someone that poor.")
+ npc_message(npc, ch, "I would feel bad taking money from someone that poor.")
end
elseif v == 4 then
- mana.being_say(npc, "As you wish...")
- schedule_in(2, function() mana.being_say(npc, "One") end)
- schedule_in(4, function() mana.being_say(npc, "Two") end)
- schedule_in(6, function() mana.being_say(npc, "Three") end)
- schedule_in(8, function() mana.being_say(npc, "Four") end)
- schedule_in(10, function() mana.being_say(npc, "Five") end)
- schedule_in(12, function() mana.being_say(npc, "Six") end)
- schedule_in(14, function() mana.being_say(npc, "Seven") end)
- schedule_in(16, function() mana.being_say(npc, "Eight") end)
- schedule_in(18, function() mana.being_say(npc, "Nine") end)
- schedule_in(20, function() mana.being_say(npc, "Ten") end)
+ being_say(npc, "As you wish...")
+ schedule_in(2, function() being_say(npc, "One") end)
+ schedule_in(4, function() being_say(npc, "Two") end)
+ schedule_in(6, function() being_say(npc, "Three") end)
+ schedule_in(8, function() being_say(npc, "Four") end)
+ schedule_in(10, function() being_say(npc, "Five") end)
+ schedule_in(12, function() being_say(npc, "Six") end)
+ schedule_in(14, function() being_say(npc, "Seven") end)
+ schedule_in(16, function() being_say(npc, "Eight") end)
+ schedule_in(18, function() being_say(npc, "Nine") end)
+ schedule_in(20, function() being_say(npc, "Ten") end)
elseif v == 5 then
function printTable (t)
@@ -80,7 +80,7 @@ function npc1_talk(npc, ch)
print (k, ":", v)
end
end
- local t1, t2, t3, t4, t5 = mana.test_tableget();
+ local t1, t2, t3, t4, t5 = test_tableget();
print("---------------");
print ("Table 1:");
printTable (t1)
@@ -95,6 +95,6 @@ function npc1_talk(npc, ch)
print("---------------");
end
- mana.npc_message(npc, ch, "See you later!")
+ npc_message(npc, ch, "See you later!")
end
diff --git a/example/scripts/npcs/emotemaker.lua b/example/scripts/npcs/emotemaker.lua
index 4aa39e80..0f546634 100644
--- a/example/scripts/npcs/emotemaker.lua
+++ b/example/scripts/npcs/emotemaker.lua
@@ -21,8 +21,8 @@ function emote_talk(npc, ch)
elseif emo_state == EMOTE_HAPPY then
state = "happy"
end
- mana.npc_message(npc, ch, string.format("The emotional palm seems %s.", state))
- v = mana.npc_choice(npc, ch,
+ npc_message(npc, ch, string.format("The emotional palm seems %s.", state))
+ v = npc_choice(npc, ch,
"Stupid palm, you are ugly and everyone hates you!",
"You are such a nice palm, let me give you a hug.",
"Are you a cocos nucifera or a syagrus romanzoffiana?")
@@ -40,6 +40,6 @@ function emote_update(npc)
emo_count = emo_count + 1
if emo_count > 50 then
emo_count = 0
- mana.effect_create(emo_state, npc)
+ effect_create(emo_state, npc)
end
end
diff --git a/example/scripts/npcs/healer.lua b/example/scripts/npcs/healer.lua
index 478047bf..35696736 100644
--- a/example/scripts/npcs/healer.lua
+++ b/example/scripts/npcs/healer.lua
@@ -5,11 +5,11 @@
--]]
function Healer(npc, ch)
- mana.npc_message(npc, ch, "Do you need healing?")
- local c = mana.npc_choice(npc, ch, "Heal me fully", "Heal 100 HP", "Don't heal me")
+ npc_message(npc, ch, "Do you need healing?")
+ local c = npc_choice(npc, ch, "Heal me fully", "Heal 100 HP", "Don't heal me")
if c == 1 then
- mana.being_heal(ch)
+ being_heal(ch)
elseif c == 2 then
- mana.being_heal(ch, 100)
+ being_heal(ch, 100)
end
end
diff --git a/example/scripts/npcs/merchant.lua b/example/scripts/npcs/merchant.lua
index 71d05441..2ef0a6b7 100644
--- a/example/scripts/npcs/merchant.lua
+++ b/example/scripts/npcs/merchant.lua
@@ -13,7 +13,7 @@
function Merchant(npc, ch, buy_sell_table)
local function say(message)
- mana.npc_message(npc, ch, message)
+ npc_message(npc, ch, message)
end
-- Important note: You can add two tables made of trinoms here when calling the
@@ -22,11 +22,11 @@ function Merchant(npc, ch, buy_sell_table)
-- buy_sell_table[1] will corresponds to the first table (used to list
-- boughtable items, and buy_sell_table[2] listing sellable items.
- local rights = mana.chr_get_rights(ch);
+ local rights = chr_get_rights(ch);
if (rights >= 128) then
- mana.announce(mana.being_get_name(ch) .. " the big administrator was at my shop!",
- mana.being_get_name(npc))
+ announce(being_get_name(ch) .. " the big administrator was at my shop!",
+ being_get_name(npc))
say "Oh mighty server administrator, how can I avoid your wrath?"
elseif (rights >= 8) then
say "How can I be of assistance, sir gamemaster?"
@@ -35,7 +35,7 @@ function Merchant(npc, ch, buy_sell_table)
elseif (rights >= 2) then
say "How can I assist you in your testing duties?"
elseif (rights >= 1) then
- if mana.being_get_gender(ch) == GENDER_FEMALE then
+ if being_get_gender(ch) == GENDER_FEMALE then
say "What do you want, Madam?"
else
say "What do you want, Sir?"
@@ -56,7 +56,7 @@ function Merchant(npc, ch, buy_sell_table)
table.insert (choice_table, "Tell me about the objects on this map")
table.insert (choice_table, "Nevermind...")
- local v = mana.npc_choice(npc, ch, choice_table)
+ local v = npc_choice(npc, ch, choice_table)
--Debug and learning purpose
--for i,k in ipairs(choice_table) do print(i,k) end
@@ -67,7 +67,7 @@ function Merchant(npc, ch, buy_sell_table)
if v == 1 then
-- "To buy."
- local buycase = mana.npc_trade(npc, ch, false, buy_sell_table[1])
+ local buycase = npc_trade(npc, ch, false, buy_sell_table[1])
if buycase == 0 then
say "What do you want to buy?"
elseif buycase == 1 then
@@ -80,7 +80,7 @@ function Merchant(npc, ch, buy_sell_table)
if buy_sell_table[2] == nil then
-- "To sell stuff..."
- local sellcase = mana.npc_trade(npc, ch, true)
+ local sellcase = npc_trade(npc, ch, true)
if sellcase == 0 then
say "Ok, what do you want to sell?"
elseif sellcase == 1 then
@@ -90,7 +90,7 @@ function Merchant(npc, ch, buy_sell_table)
end
else
-- "Can you make me a price for what I have?"
- local sellcase = mana.npc_trade(npc, ch, true, buy_sell_table[2])
+ local sellcase = npc_trade(npc, ch, true, buy_sell_table[2])
if sellcase == 0 then
say "Here we go:"
elseif sellcase == 1 then
@@ -102,7 +102,7 @@ function Merchant(npc, ch, buy_sell_table)
elseif v == 3 then
- local objects = mana.map_get_objects()
+ local objects = map_get_objects()
say("There are " .. #objects .. " objects on this map, their names are:")
for i=1,#objects do
say(tostring(i) .. ": " .. objects[i]:name())
diff --git a/example/scripts/npcs/postman.lua b/example/scripts/npcs/postman.lua
index ef64b169..95e6844e 100644
--- a/example/scripts/npcs/postman.lua
+++ b/example/scripts/npcs/postman.lua
@@ -11,20 +11,20 @@
----------------------------------------------------------------------------------
function post_talk(npc, ch)
- mana.npc_message(npc, ch, "Hello " .. mana.being_get_name(ch))
- local strength = mana.being_get_attribute(ch, ATTR_STRENGTH)
- mana.npc_message(npc, ch, "You have " .. tostring(strength) .. " strength")
- mana.npc_message(npc, ch, "What would you like to do?")
- local answer = mana.npc_choice(npc, ch, "View Mail", "Send Mail", "Nothing")
+ npc_message(npc, ch, "Hello " .. being_get_name(ch))
+ local strength = being_get_attribute(ch, ATTR_STRENGTH)
+ npc_message(npc, ch, "You have " .. tostring(strength) .. " strength")
+ npc_message(npc, ch, "What would you like to do?")
+ local answer = npc_choice(npc, ch, "View Mail", "Send Mail", "Nothing")
if answer == 1 then
- local sender, post = mana.chr_get_post(ch)
+ local sender, post = chr_get_post(ch)
if sender == "" then
- mana.npc_message(npc, ch, "No Post right now, sorry")
+ npc_message(npc, ch, "No Post right now, sorry")
else
- mana.npc_message(npc, ch, tostring(sender) .. " sent you " .. tostring(post))
+ npc_message(npc, ch, tostring(sender) .. " sent you " .. tostring(post))
end
end
if answer == 2 then
- mana.npc_post(npc, ch)
+ npc_post(npc, ch)
end
end
diff --git a/example/scripts/npcs/shaker.lua b/example/scripts/npcs/shaker.lua
index ac6b152a..768fc126 100644
--- a/example/scripts/npcs/shaker.lua
+++ b/example/scripts/npcs/shaker.lua
@@ -15,8 +15,8 @@ function shaker_update(npc)
if shake_count > 20 then
shake_count = 0
- center_x = mana.posX(npc)
- center_y = mana.posY(npc)
+ center_x = posX(npc)
+ center_y = posY(npc)
tremor(center_x, center_y, 300)
end
end
@@ -28,17 +28,17 @@ function square(x)
end
function tremor (center_x, center_y, intensity)
- for dummy, object in ipairs(mana.get_beings_in_circle(center_x, center_y, intensity)) do
- if mana.being_type(object) == TYPE_CHARACTER then
- object_x = mana.posX(object)
- object_y = mana.posY(object)
+ for dummy, object in ipairs(get_beings_in_circle(center_x, center_y, intensity)) do
+ if being_type(object) == TYPE_CHARACTER then
+ object_x = posX(object)
+ object_y = posY(object)
dist_x = object_x - center_x
dist_y = object_y - center_y
dist = math.sqrt(square(dist_x) + square(dist_y))
intensity_local = intensity - dist
intensity_x = (intensity - dist) * (dist_x / dist) / 5
intensity_y = (intensity - dist) * (dist_y / dist) / 5
- mana.chr_shake_screen(object, intensity_x, intensity_y)
+ chr_shake_screen(object, intensity_x, intensity_y)
end
end
end