-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshort2.lua
More file actions
182 lines (171 loc) · 4.48 KB
/
short2.lua
File metadata and controls
182 lines (171 loc) · 4.48 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
local node_short2 = {
description = "Short 2 Fence",
drawtype = "mesh",
mesh = "myfences_short2.obj",
tiles = {
"myfences_wood.png",
},
paramtype = "light",
paramtype2 = "facedir",
sunlight_propogates = true,
selection_box = {
type = "fixed",
fixed = {
{-0.5,-0.5,0.25,0.5,0.5,0.5},
}
},
collision_box = {
type = "fixed",
fixed = {
{-0.5,-0.5,0.25,0.5,0.5,0.5},
}
},
groups = {choppy = 2, flammable = 1},
sounds = default.node_sound_stone_defaults(),
}
core.register_node("myfences:short2", node_short2)
local node_short2_corner = {
description = "Short 2 Fence Corner",
drawtype = "mesh",
mesh = "myfences_short2_corner.obj",
tiles = {
"myfences_wood.png",
},
paramtype = "light",
paramtype2 = "facedir",
sunlight_propogates = true,
selection_box = {
type = "fixed",
fixed = {
{-0.5,-0.5,0.25,0.5,0.5,0.5},
{0.25,-0.5,-0.5,0.5,0.5,0.5},
}
},
collision_box = {
type = "fixed",
fixed = {
{-0.5,-0.5,0.25,0.5,0.5,0.5},
{0.25,-0.5,-0.5,0.5,0.5,0.5},
}
},
groups = {choppy = 2, flammable = 1},
sounds = default.node_sound_stone_defaults(),
}
core.register_node("myfences:short2_corner", node_short2_corner)
for _, entry in ipairs(myfences.colors) do
local color = entry[1]
local desc = entry[2]
local stain = "^(myfences_color.png^[colorize:#"..entry[3]..":175)"
local tiles = {
"myfences_wood.png"..stain,
}
local node_short2_gate = {
description = "Short 2 Gate",
tiles = {
"myfences_wood.png",
},
drawtype = "mesh",
mesh = "myfences_short2.obj",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky=2},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, 0.5, 0.5, 0.5, 0.325},
}
},
collision_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, 0.5, 0.5, 0.5, 0.325},
}
},
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local p2 = node.param2
local dir = core.facedir_to_dir(p2)
if node.name == "myfences:short2_gate_"..color then
core.set_node(pos, {name="myfences:short2_gate_open_"..color, param2=p2})
else
core.set_node(pos, {name="myfences:short2_gate_open", param2=p2})
end
end
}
core.register_node("myfences:short2_gate", node_short2_gate)
local node_short2_gate_open = {
description = "Short 2 Gate Open",
tiles = {
"myfences_wood.png",
},
drawtype = "mesh",
mesh = "myfences_short2_gate_open.obj",
paramtype = "light",
paramtype2 = "facedir",
drops = "myfences_short2_gate",
groups = {cracky=2, not_in_creative_inventory = 1},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, -0.325, 0.5, 0.5},
}
},
collision_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, -0.325, 0.5, 0.5},
}
},
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local p2 = node.param2
local dir = core.facedir_to_dir(p2)
if node.name == "myfences:short2_gate_open_"..color then
core.set_node(pos, {name="myfences:short2_gate_"..color, param2=p2})
else
core.set_node(pos, {name="myfences:short2_gate", param2=p2})
end
end
}
core.register_node("myfences:short2_gate_open", node_short2_gate_open)
local node = table.copy(node_short2)
node.description = desc.." Short 2 Fence"
node.tiles = tiles
node.drop = "myfences:short2"
node.groups.not_in_creative_inventory = 1
core.register_node("myfences:short2_"..color, node)
node = table.copy(node_short2_corner)
node.description = desc.." Short 2 Fence Corner"
node.tiles = tiles
node.drop = "myfences:short2_corner"
node.groups.not_in_creative_inventory = 1
core.register_node("myfences:short2_corner_"..color, node)
local node = table.copy(node_short2_gate)
node.description = desc.." Short 2 Gate"
node.tiles = tiles
node.drop = "myfences:short2_gate"
node.groups.not_in_creative_inventory = 1
core.register_node("myfences:short2_gate_"..color, node)
local node = table.copy(node_short2_gate_open)
node.description = desc.." Short 2 Gate Open"
node.tiles = tiles
node.drop = "myfences:short2_gate"
node.groups.not_in_creative_inventory = 1
core.register_node("myfences:short2_gate_open_"..color, node)
end
core.register_craft({
output = "myfences:short2",
recipe = {
{"","",""},
{"myfences:board","myfences:board","myfences:board"},
{"default:wood","myfences:board","default:wood"},
}
})
core.register_craft({
type = "shapeless",
output = "myfences:short2_corner",
recipe = {"myfences:short2","myfences:short2"},
})
core.register_craft({
type = "shapeless",
output = "myfences:short2_gate",
recipe = {"myfences:short2","default:steel_ingot"},
})