fix adding sticks to active campfire without grille

master
VanessaE 2020-06-03 09:50:03 -04:00
parent 243a0bbfc3
commit cc18a1e9ff
3 changed files with 35 additions and 26 deletions

View File

@ -1,4 +0,0 @@
default
fire
basic_materials
campfire?

View File

@ -184,6 +184,29 @@ local function cooking(pos, itemstack)
end
end
local function add_stick(pos, itemstack)
local meta = minetest.get_meta(pos)
local name = itemstack:get_name()
if itemstack:get_definition().groups.stick == 1 then
local it_val = meta:get_int("it_val") + (new_campfire_ttl);
meta:set_int('it_val', it_val);
effect(
{x = pos.x, y = pos.y+0.4, z = pos.z},
"default_stick.png",
{x=0, y=-1, z=0},
{x=0, y=0, z=0},
1,
6
)
infotext_edit(meta)
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
return itemstack
end
return true
end
end
-- NODES
local sbox = {
@ -308,9 +331,12 @@ minetest.register_node('new_campfire:campfire_active', {
selection_box = sbox,
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local name = itemstack:get_name()
if name == "new_campfire:grille" then
itemstack:take_item()
minetest.swap_node(pos, {name = "new_campfire:campfire_active_with_grille"})
local a=add_stick(pos, itemstack)
if not a then
if name == "new_campfire:grille" then
itemstack:take_item()
minetest.swap_node(pos, {name = "new_campfire:campfire_active_with_grille"})
end
end
end,
@ -416,26 +442,11 @@ minetest.register_node('new_campfire:campfire_active_with_grille', {
sounds = default.node_sound_stone_defaults(),
selection_box = grille_sbox,
node_box = grille_cbox,
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
if itemstack:get_definition().groups.stick == 1 then
local it_val = meta:get_int("it_val") + (new_campfire_ttl);
meta:set_int('it_val', it_val);
effect(
{x = pos.x, y = pos.y+0.4, z = pos.z},
"default_stick.png",
{x=0, y=-1, z=0},
{x=0, y=0, z=0},
1,
6
)
infotext_edit(meta)
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
return itemstack
end
else
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local name = itemstack:get_name()
local a=add_stick(pos, itemstack)
if not a then
cooking(pos, itemstack)
end
end,

View File

@ -1 +1,3 @@
name = new_campfire
depends = default, fire, basic_materials
optional_depends = campfire