diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2013-05-03 12:56:16 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2013-05-03 12:56:29 +0200 |
commit | eb9fdd6852fced4ca9125b93585b95eb319dce18 (patch) | |
tree | 840aab10aedcdb1f67064310995d1f767e0b6a5e /scripts/lua | |
parent | 0261eb73e5588f5732aef5df753311d488c45d06 (diff) | |
download | manaserv-eb9fdd6852fced4ca9125b93585b95eb319dce18.tar.gz manaserv-eb9fdd6852fced4ca9125b93585b95eb319dce18.tar.bz2 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/lua')
-rw-r--r-- | scripts/lua/libmana.lua | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/scripts/lua/libmana.lua b/scripts/lua/libmana.lua index 20a5e13f..7393ce60 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 |