I'm probably missing something obvious, but I'm trying to make a function for a lighter. I have two objects that can be lit, and both of them should result in different fires. I'm running a random number generator and if I get the right number then I want to start the node on fire, actually just call a swap_node. I can't seem to get it to work though. I've tried googleing, but I'm not really sure what to look for. I've tried replacing the and with if and elseif but it makes no difference.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
function burn(pointed_thing) --kindling doesn't always start from the first spark
ignite_chance = math.random(10)
if ignite_chance == 1
and string.find(minetest.get_node(pointed_thing.under).name, 'more_fire:kindling')
then
minetest.env:swap_node(pointed_thing.under, {name = 'more_fire:campfire'})
and string.find(minetest.get_node(pointed_thing.under).name, 'more_fire:kindling_contained')
then
minetest.env:swap_node(pointed_thing.under, {name = 'more_fire:contained_fire'})
else --do nothing
end
end
never mind I figured it out with help from the flint and steel part of homedecor.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
function burn(pointed_thing) --kindling doesn't always start from the first spark
ignite_chance = math.random(10)
if ignite_chance == 1
and string.find(minetest.get_node(pointed_thing.under).name, 'more_fire:kindling_contained')
then
minetest.env:swap_node(pointed_thing.under, {name = 'more_fire:contained_fire'})
elseif ignite_chance == 1
and string.find(minetest.get_node(pointed_thing.under).name, 'more_fire:kindling')
then
minetest.env:swap_node(pointed_thing.under, {name = 'more_fire:campfire'})
else --do nothing
end
end