summaryrefslogtreecommitdiff
path: root/extranodes/lox.lua
diff options
context:
space:
mode:
authorh-v-smacker <hans-von-smacker+github@gmail.com>2018-05-01 04:52:26 +0300
committerh-v-smacker <hans-von-smacker+github@gmail.com>2018-05-01 04:52:26 +0300
commit2b041dd0f2b5aee06d561310b72e9bb7539ca3bc (patch)
treebb3680e2f197201a4124e6c953369758d10f8cf9 /extranodes/lox.lua
parentd0acc8a8caafe549bb1513cf6be53c0b4b204fa7 (diff)
lox fix
Diffstat (limited to 'extranodes/lox.lua')
-rw-r--r--extranodes/lox.lua53
1 files changed, 24 insertions, 29 deletions
diff --git a/extranodes/lox.lua b/extranodes/lox.lua
index a4831a6..3aaadee 100644
--- a/extranodes/lox.lua
+++ b/extranodes/lox.lua
@@ -16,23 +16,19 @@ local freezing_rules = {
["ethereal:mushroom_dirt"] = "default:dirt_with_snow",
}
-local function freeze(user, pos, radius, itemstack)
+local function freeze(user, pos, radius)
- -- itemstack is true if the function is used in a tool callback
- -- if so, user is a playerref
- -- if itemstack is false, it's a node using the function, and the
- -- user name is plain text string
+ -- if the function is used by a node: user is a string
+ -- if it's called by an item, user is a PlayerRef
- if (itemstack) then
-
- if minetest.is_protected(pos, user:get_player_name()) then
- minetest.record_protection_violation(pos, user:get_player_name())
+ if type(user) == 'string' then
+ if minetest.is_protected(pos, user) then
+ minetest.record_protection_violation(pos, user)
return
end
-
else
- if minetest.is_protected(pos, user) then
- minetest.record_protection_violation(pos, user)
+ if minetest.is_protected(pos, user:get_player_name()) then
+ minetest.record_protection_violation(pos, user:get_player_name())
return
end
end
@@ -66,22 +62,7 @@ local function freeze(user, pos, radius, itemstack)
minetest.sound_play("default_cool_lava", {gain = 1, pos = pos})
end
- if (itemstack) then
-
- itemstack:take_item()
- local uinv = user:get_inventory()
- if uinv:room_for_item("main", "vessels:steel_bottle 1") then
- uinv:add_item("main", "vessels:steel_bottle 1")
- else
- minetest.item_drop(ItemStack("vessels:steel_bottle 1"), user, user:getpos())
- end
-
- user:set_hp(user:get_hp() - 1)
-
- return itemstack
- else
- return true
- end
+ return true
end
@@ -104,7 +85,21 @@ minetest.register_craftitem(":technic:lox", {
if pointed_thing.type ~= "node" then
return itemstack
end
- freeze(user, pointed_thing.under, 2, itemstack)
+
+ itemstack:take_item()
+
+ freeze(user, pointed_thing.under, 2)
+
+ local uinv = user:get_inventory()
+ if uinv:room_for_item("main", "vessels:steel_bottle 1") then
+ uinv:add_item("main", "vessels:steel_bottle 1")
+ else
+ minetest.item_drop(ItemStack("vessels:steel_bottle 1"), user, user:getpos())
+ end
+
+ user:set_hp(user:get_hp() - 1)
+
+ return itemstack
end
})