summaryrefslogtreecommitdiff
path: root/example/scripts/npcs/banker.lua
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/banker.lua
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/banker.lua')
-rw-r--r--example/scripts/npcs/banker.lua60
1 files changed, 30 insertions, 30 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