-
Notifications
You must be signed in to change notification settings - Fork 4
/
functions.lua
70 lines (67 loc) · 1.91 KB
/
functions.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function stoneage.strike_fire(user, pointed_thing)
if pointed_thing.type == "node" then
local n_pointed_above = minetest.env:get_node(pointed_thing.above)
local n_pointed_under = minetest.env:get_node(pointed_thing.under)
for _,tinder in ipairs(tinder) do
if user:get_inventory():get_stack("main", user:get_wield_index()+1):get_name() == tinder then
user:get_inventory():remove_item("main", tinder)
if n_pointed_under.name == "stoneage:torch_unlit" then
n_pointed_under.name = "default:torch"
minetest.env:add_node(pointed_thing.under, n_pointed_under)
elseif n_pointed_under.name == "stoneage:bonfire_unlit" then
minetest.env:add_node(pointed_thing.under, {name="stoneage:bonfire"})
elseif n_pointed_above.name == "air" then
minetest.env:add_node(pointed_thing.above, {name="fire:basic_flame"})
end
end
end
else
return
end
end
-- torchdecay
-- burntime equals half a night
if torchdecay then
minetest.register_abm({
nodenames = {"default:torch"},
interval = 9,
chance = 1,
action = function(pos, node)
local meta = minetest.env:get_meta(pos)
local decay = meta:get_int("decay")
if not decay then
meta:set_int("decay", 1)
return
end
if decay >= math.random(36, 44) then
node.name = "stoneage:torch_unlit"
minetest.env:add_node(pos, node)
meta:set_int("decay", 0)
return
end
decay = decay + 1
meta:set_int("decay", decay)
end
})
minetest.register_abm({
nodenames = {"stoneage:bonfire"},
interval = 18,
chance = 1,
action = function(pos, node)
local meta = minetest.env:get_meta(pos)
local decay = meta:get_int("decay")
if not decay then
meta:set_int("decay", 1)
return
end
if decay >= math.random(36, 44) then
node.name = "stoneage:bonfire_unlit"
minetest.env:add_node(pos, node)
meta:set_int("decay", 0)
return
end
decay = decay + 1
meta:set_int("decay", decay)
end
})
end