summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-05-03 12:56:16 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-05-03 12:56:29 +0200
commiteb9fdd6852fced4ca9125b93585b95eb319dce18 (patch)
tree840aab10aedcdb1f67064310995d1f767e0b6a5e /scripts
parent0261eb73e5588f5732aef5df753311d488c45d06 (diff)
downloadmanaserv-eb9fdd6852fced4ca9125b93585b95eb319dce18.tar.gz
manaserv-eb9fdd6852fced4ca9125b93585b95eb319dce18.tar.xz
manaserv-eb9fdd6852fced4ca9125b93585b95eb319dce18.zip
Made member function tables available as a globals
This way the scripts can add or replace existing member functions, which can be useful. As demonstration chr_money and chr_money_change are now added as Entity.money and Entity.change_money. Also fixed the banker to use ask_number instead of ask_integer (I had decided to rename this and apparently forgot the banker). Mantis-issue: 503 Reviewed-by: Ablu
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lua/libmana.lua28
1 files changed, 14 insertions, 14 deletions
diff --git a/scripts/lua/libmana.lua b/scripts/lua/libmana.lua
index 20a5e13..7393ce6 100644
--- a/scripts/lua/libmana.lua
+++ b/scripts/lua/libmana.lua
@@ -367,27 +367,27 @@ end
-- Below are some convenience methods added to the engine API
---- LUA chr_money_change (inventory)
--- chr_money_change(handle character, int amount)
+--- LUA entity:change_money (inventory)
+-- entity:change_money(int amount)
---
--- Changes the money currently owned by ''character'' by ''amount''.
+-- Valid only for character entities.
+--
+-- Changes the money currently owned by this character by ''amount''.
--
-- **Warning:** Before reducing the money make sure to check if the character
--- owns enough money using chr_money.
-chr_money_change = function(ch, amount)
- ch:set_base_attribute(ATTR_GP,
- ch:base_attribute(ATTR_GP) + amount)
+-- owns enough money using entity:money.
+function Entity:change_money(amount)
+ self:set_base_attribute(ATTR_GP, self:base_attribute(ATTR_GP) + amount)
end
---- LUA chr_money (inventory)
--- chr_money(handle character)
+--- LUA entity:money (inventory)
+-- entity:money()
---
--- Changes the money currently owned by ''character'' by ''amount''.
+-- Valid only for character entities.
--
--- **Warning:** Before reducing the money make sure to check if the character
--- owns enough money using chr_money.
-chr_money = function(ch)
- return ch:base_attribute(ATTR_GP)
+-- Returns the money currently owned by this character.
+function Entity:money()
+ return self:base_attribute(ATTR_GP)
end
-- Register callbacks