summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlockMen <nmuelll@web.de>2015-10-14 09:27:37 +0200
committerBlockMen <nmuelll@web.de>2015-10-14 09:27:37 +0200
commit6a84d6d3089b032d33c500998dc0ebd4fb0c3c91 (patch)
tree78cfac70fb0de9325b6738d37cb75c6acbc48850
parente3126f7b8ec63551132e63c2b1fcd3095a7d7726 (diff)
Don't crash on invalid given values
-rw-r--r--functions.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/functions.lua b/functions.lua
index a7575a5..adcc2ca 100644
--- a/functions.lua
+++ b/functions.lua
@@ -212,6 +212,10 @@ function hunger.eat(hp_change, replace_with_item, itemstack, user, pointed_thing
local def = food[item]
if not def then
def = {}
+ if type(hp_change) ~= "number" then
+ hp_change = 1
+ core.log("error", "Wrong on_use() definition for item '" .. item .. "'")
+ end
def.saturation = hp_change * 1.3
def.replace = replace_with_item
end