diff options
author | BlockMen <nmuelll@web.de> | 2015-09-24 15:46:06 +0200 |
---|---|---|
committer | BlockMen <nmuelll@web.de> | 2015-09-24 15:46:06 +0200 |
commit | 4a0f1d03c569148768041fbe4c209e290cb797a0 (patch) | |
tree | 21e6a4b47b56a37826cbece80e28e02a9505ea8c | |
parent | 12e4fa8a9238b762a7648700952ce8c4208d013c (diff) |
Fix unhandled exception
-rw-r--r-- | functions.lua | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/functions.lua b/functions.lua index 57db844..a7575a5 100644 --- a/functions.lua +++ b/functions.lua @@ -68,7 +68,7 @@ function hunger.handle_node_actions(pos, oldnode, player, ext) if not name or not hunger[name] then return end - + local exhaus = hunger[name].exhaus if not exhaus then hunger[name].exhaus = 0 @@ -223,7 +223,10 @@ function hunger.item_eat(hunger_change, replace_with_item, poisen, heal, sound) return function(itemstack, user, pointed_thing) if itemstack:take_item() ~= nil and user ~= nil then local name = user:get_player_name() - local sat = tonumber(hunger[name].lvl) + if not hunger[name] then + return itemstack + end + local sat = tonumber(hunger[name].lvl or 0) local hp = user:get_hp() -- Saturation if sat < HUNGER_MAX and hunger_change then |