-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconvert.lua
More file actions
67 lines (64 loc) · 2.55 KB
/
convert.lua
File metadata and controls
67 lines (64 loc) · 2.55 KB
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
core.register_abm({
nodenames = {"cannons:cannon","cannons:bronze_canon","cannons:mithril_cannon"},
--neighbors = {"cannons:stand","cannons.stand_wood"},
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local stand_pos = {x= pos.x,y= pos.y-1,z=pos.z}
local stand = core.get_node(stand_pos)
if stand.name == "cannons:stand" or stand.name == "cannons:stand_wood" then -- cannon stand with cannon
if stand.name == "cannons:stand" then
core.set_node(stand_pos, {name = "default:cobble"})--replace stand with cobblestone
else
core.set_node(stand_pos, {name = "default:wood"})--replace stand with cobblestone
end
if node.name == "cannons:cannon" then
node.name = "cannons:wood_stand_with_cannon_steel"
elseif node.name == "cannons:bronze_canon" then
node.name = "cannons:wood_stand_with_cannon_bronze"
elseif node.name == "cannons:mithril_cannon" then
node.name = "cannons:wood_stand_with_cannon_mithril"
--else if node.name == "cannons:bronze_canon" then
-- node.name = "cannons:wood_stand_with_bronze_cannon"
else --dont know what else can happen, but "Der Teufel ist ein Eichh�rnchen"
node.name = "air"
end
core.swap_node(pos, node)
else --else its a single or disabled cannon
print("zweite if")
if node.name == "cannons:cannon" then
node.name = "cannons:cannon_steel"
elseif node.name == "cannons:canon_bronze" then
node.name = "cannons:bronze_cannon"
elseif node.name == "cannons:cannon_mithril" then
node.name = "cannons:cannon_mithril"
--else if node.name == "cannons:placeholder" then
-- node.name = "cannons:wood_stand_with_placeholder_cannon"
else --dont know what else can happen, but "Der Teufel ist ein Eichh�rnchen"
node.name = "air"
end
core.swap_node(pos, node)
end
end,
})
--abm to convert single cannonstands
core.register_abm({
nodenames = {"cannons:stand","cannons:stand_wood"},
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local above_pos = {x= pos.x,y= pos.y+1,z=pos.z}
local above = core.get_node(above_pos)
--if above the stand a cannon...
if above.name == "air" then
core.set_node(above_pos, {name = "cannons:wood_stand"})
else
--replace single stands with a full block, and place the stand above it
if node.name == "cannons:stand" then
core.set_node(pos, {name = "default:cobble"})--replace stand with cobblestone
else
core.set_node(pos, {name = "default:wood"})--replace stand with cobblestone
end
end
end,
})