2 local function is_pane(pos
)
3 return minetest
.get_item_group(minetest
.get_node(pos
).name
, "pane") > 0
6 local function connects_dir(pos
, name
, dir
)
7 local aside
= vector
.add(pos
, minetest
.facedir_to_dir(dir
))
12 local connects_to
= minetest
.registered_nodes
[name
].connects_to
13 if not connects_to
then
16 local list
= minetest
.find_nodes_in_area(aside
, aside
, connects_to
)
25 local function swap(pos
, node
, name
, param2
)
26 if node
.name
== name
and node
.param2
== param2
then
30 minetest
.set_node(pos
, {name
= name
, param2
= param2
})
33 local function update_pane(pos
)
34 if not is_pane(pos
) then
37 local node
= minetest
.get_node(pos
)
38 local name
= node
.name
39 if name
:sub(-5) == "_flat" then
40 name
= name
:sub(1, -6)
43 local any
= node
.param2
47 c
[dir
] = connects_dir(pos
, name
, dir
)
55 swap(pos
, node
, name
.. "_flat", any
)
56 elseif count
== 1 then
57 swap(pos
, node
, name
.. "_flat", (any
+ 1) % 4)
58 elseif count
== 2 then
59 if (c
[0] and c
[2]) or (c
[1] and c
[3]) then
60 swap(pos
, node
, name
.. "_flat", (any
+ 1) % 4)
62 swap(pos
, node
, name
, 0)
65 swap(pos
, node
, name
, 0)
69 minetest
.register_on_placenode(function(pos
, node
)
70 if minetest
.get_item_group(node
, "pane") then
74 local dir
= minetest
.facedir_to_dir(i
)
75 update_pane(vector
.add(pos
, dir
))
79 minetest
.register_on_dignode(function(pos
)
81 local dir
= minetest
.facedir_to_dir(i
)
82 update_pane(vector
.add(pos
, dir
))
87 function xpanes
.register_pane(name
, def
)
89 minetest
.register_alias("xpanes:" .. name
.. "_" .. i
, "xpanes:" .. name
.. "_flat")
92 local flatgroups
= table.copy(def
.groups
)
95 drop
= "xpanes:" .. name
.. "_flat"
98 flatgroups
.deco_block
= 1
99 minetest
.register_node(":xpanes:" .. name
.. "_flat", {
100 description
= def
.description
,
101 _doc_items_create_entry
= def
._doc_items_create_entry
,
102 _doc_items_entry_name
= def
._doc_items_entry_name
,
103 _doc_items_longdesc
= def
._doc_items_longdesc
,
104 _doc_items_usagehelp
= def
._doc_items_usagehelp
,
105 drawtype
= "nodebox",
107 is_ground_content
= false,
108 sunlight_propagates
= true,
109 inventory_image
= def
.inventory_image
,
110 wield_image
= def
.wield_image
,
111 paramtype2
= "facedir",
112 tiles
= {def
.textures
[3], def
.textures
[2], def
.textures
[1]},
113 use_texture_alpha
= def
.use_texture_alpha
,
119 fixed
= {{-1/2, -1/2, -1/32, 1/2, 1/2, 1/32}},
123 fixed
= {{-1/2, -1/2, -1/32, 1/2, 1/2, 1/32}},
125 connect_sides
= { "left", "right" },
126 _mcl_blast_resistance
= def
._mcl_blast_resistance
,
127 _mcl_hardness
= def
._mcl_hardness
,
130 local groups
= table.copy(def
.groups
)
132 groups
.not_in_creative_inventory
= 1
133 minetest
.register_node(":xpanes:" .. name
, {
134 drawtype
= "nodebox",
136 is_ground_content
= false,
137 sunlight_propagates
= true,
138 description
= def
.description
,
139 _doc_items_create_entry
= false,
140 tiles
= {def
.textures
[3], def
.textures
[2], def
.textures
[1]},
141 use_texture_alpha
= def
.use_texture_alpha
,
143 drop
= "xpanes:" .. name
.. "_flat",
147 fixed
= {{-1/32, -1/2, -1/32, 1/32, 1/2, 1/32}},
148 connect_front
= {{-1/32, -1/2, -1/2, 1/32, 1/2, -1/32}},
149 connect_left
= {{-1/2, -1/2, -1/32, -1/32, 1/2, 1/32}},
150 connect_back
= {{-1/32, -1/2, 1/32, 1/32, 1/2, 1/2}},
151 connect_right
= {{1/32, -1/2, -1/32, 1/2, 1/2, 1/32}},
153 connects_to
= {"group:pane", "group:stone", "group:glass", "group:wood", "group:tree"},
155 _mcl_blast_resistance
= def
._mcl_blast_resistance
,
156 _mcl_hardness
= def
._mcl_hardness
,
159 minetest
.register_craft({
160 output
= "xpanes:" .. name
.. "_flat 16",
164 if minetest
.get_modpath("doc") then
165 doc
.add_entry_alias("nodes", "xpanes:" .. name
.. "_flat", "nodes", "xpanes:" .. name
)
169 -- Register glass pane (stained and unstained)
170 local pane
= function(description
, node
, append
)
173 -- Special case: Default (unstained) glass texture
174 if append
== "_natural" then
175 texture1
= "default_glass.png"
177 texture1
= "mcl_core_glass"..append
..".png"
179 xpanes
.register_pane("pane"..append
, {
180 description
= description
,
181 _doc_items_longdesc
= "Glass panes are thin layers of glass which neatly connect to their neighbors as you build them.",
182 textures
= {texture1
, texture1
, "xpanes_top_glass"..append
..".png"},
183 use_texture_alpha
= true,
184 inventory_image
= texture1
,
185 wield_image
= texture1
,
186 sounds
= mcl_sounds
.node_sound_glass_defaults(),
187 groups
= {handy
=1, material_glass
=1},
193 _mcl_blast_resistance
= 1.5,
199 xpanes
.register_pane("bar", {
200 description
= "Iron Bars",
201 _doc_items_longdesc
= "Iron bars neatly connect to their neighbors as you build them.",
202 textures
= {"xpanes_pane_iron.png","xpanes_pane_iron.png","xpanes_top_iron.png"},
203 inventory_image
= "xpanes_pane_iron.png",
204 wield_image
= "xpanes_pane_iron.png",
205 groups
= {pickaxey
=1},
206 sounds
= mcl_sounds
.node_sound_metal_defaults(),
208 {"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"},
209 {"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"},
211 _mcl_blast_resistance
= 30,
216 pane("Glass Pane", "mcl_core:glass", "_natural") -- triggers special case
218 -- Stained Glass Pane
219 pane("Red Stained Glass Pane", "mcl_core:glass_red", "_red")
220 pane("Green Stained Glass Pane", "mcl_core:glass_green", "_green")
221 pane("Blue Stained Glass Pane", "mcl_core:glass_blue", "_blue")
222 pane("Light Blue Stained Glass Pane", "mcl_core:glass_light_blue", "_light_blue")
223 pane("Black Stained Glass Pane", "mcl_core:glass_black", "_black")
224 pane("White Stained Glass Pane", "mcl_core:glass_white", "_white")
225 pane("Yellow Stained Glass Pane", "mcl_core:glass_yellow", "_yellow")
226 pane("Brown Stained Glass Pane", "mcl_core:glass_brown", "_brown")
227 pane("Orange Stained Glass Pane", "mcl_core:glass_orange", "_orange")
228 pane("Pink Stained Glass Pane", "mcl_core:glass_pink", "_pink")
229 pane("Grey Stained Glass Pane", "mcl_core:glass_gray", "_gray")
230 pane("Lime Stained Glass Pane", "mcl_core:glass_lime", "_lime")
231 pane("Light Grey Stained Glass Pane", "mcl_core:glass_silver", "_silver")
232 pane("Magenta Stained Glass Pane", "mcl_core:glass_magenta", "_magenta")
233 pane("Purple Stained Glass Pane", "mcl_core:glass_purple", "_purple")
234 pane("Cyan Stained Glass Pane", "mcl_core:glass_cyan", "_cyan")