Improve sticks
Now you can use sticks on items too. When you are creating a furnace, unnecessary coals adds in the furnace. If coals is less than 9, it will not hide.
This commit is contained in:
parent
c882f0e6d9
commit
cd0f7783e1
@ -2,14 +2,19 @@ minetest.register_tool("sticks:sticks", {
|
|||||||
description = "Sticks",
|
description = "Sticks",
|
||||||
inventory_image = "default_sticks.png",
|
inventory_image = "default_sticks.png",
|
||||||
on_use = function(item, user, pointed_thing)
|
on_use = function(item, user, pointed_thing)
|
||||||
if pointed_thing.type ~= "node" then
|
local pos
|
||||||
|
if pointed_thing.type == "node" then
|
||||||
|
pos = pointed_thing.above
|
||||||
|
elseif pointed_thing.type == "object" then
|
||||||
|
pos = pointed_thing.ref:getpos()
|
||||||
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.env:get_node(pointed_thing.above).name == "air" then
|
if minetest.env:get_node(pos).name == "air" then
|
||||||
local objects = minetest.env:get_objects_inside_radius(pointed_thing.above, 0.5)
|
local objects = minetest.env:get_objects_inside_radius(pos, 0.5)
|
||||||
local pos = pointed_thing.above
|
|
||||||
local bonfireb = 0
|
local bonfireb = 0
|
||||||
local furnaceb = 0
|
local furnaceb = 0
|
||||||
|
local coals = {}
|
||||||
for _, v in ipairs(objects) do
|
for _, v in ipairs(objects) do
|
||||||
if not v:is_player() and v:get_luaentity() and v:get_luaentity().name == "__builtin:item" then
|
if not v:is_player() and v:get_luaentity() and v:get_luaentity().name == "__builtin:item" then
|
||||||
local istack = ItemStack(v:get_luaentity().itemstring)
|
local istack = ItemStack(v:get_luaentity().itemstring)
|
||||||
@ -21,13 +26,24 @@ minetest.register_tool("sticks:sticks", {
|
|||||||
v:remove()
|
v:remove()
|
||||||
elseif istack:get_name() == "default:coal_lump" then
|
elseif istack:get_name() == "default:coal_lump" then
|
||||||
furnaceb = furnaceb + istack:get_count()
|
furnaceb = furnaceb + istack:get_count()
|
||||||
|
table.insert(coals,v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if furnaceb >= 9 then
|
||||||
|
if furnace.check_furnace_blocks(pos) then
|
||||||
|
for _, v in ipairs(coals) do
|
||||||
v:remove()
|
v:remove()
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
if furnaceb >= 9 and furnace.check_furnace_blocks(pos) then
|
|
||||||
minetest.env:set_node(pos, {name = "furnace:self"})
|
minetest.env:set_node(pos, {name = "furnace:self"})
|
||||||
elseif bonfireb >= 10 then
|
if furnaceb > 9 then
|
||||||
|
local meta = minetest.env:get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:add_item("fuel", "default:coal_lump "..furnaceb-9)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if bonfireb >= 10 and minetest.env:get_node(pos).name == "air" then
|
||||||
minetest.env:set_node(pos, {name = "bonfire:self"})
|
minetest.env:set_node(pos, {name = "bonfire:self"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user