summaryrefslogtreecommitdiff
path: root/gates.lua
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2016-01-09 12:25:33 +0000
committerTenPlus1 <kinsellaja@yahoo.com>2016-01-09 12:25:33 +0000
commitad7b63b86971ccae7b1abc008196c9e9553b54ec (patch)
tree05fe8e2a0ea0e9b8d4939cffaed46e6abb0cf9f4 /gates.lua
parent94873618b17859a6f3cc9c3a02dcc88b511075cf (diff)
Optimize and tidy code.
Diffstat (limited to 'gates.lua')
-rw-r--r--gates.lua32
1 files changed, 18 insertions, 14 deletions
diff --git a/gates.lua b/gates.lua
index 3ffc0d6..f669615 100644
--- a/gates.lua
+++ b/gates.lua
@@ -15,18 +15,19 @@ local nb_pil = {
-- Open/Close Gates
function gate_rightclick(pos, node)
- local gate, open = unpack(string.split(node.name, "_", 2))
- local gate = gate.."_"
- local sound, name
- if open == "open" then
+
+ local split = string.split(node.name, "_")
+ local sound = "open"
+ local name = "open"
+
+ if split[3] == "open" then
sound = "close"
name = "closed"
- else
- sound = "open"
- name = "open"
end
- node.name = gate..name
- minetest.set_node(pos, node)
+
+ node.name = split[1] .. "_" .. split[2] .. "_" .. name
+ minetest.swap_node(pos, node)
+
minetest.sound_play("doors_door_"..sound, {
pos = pos,
gain = 0.3,
@@ -52,7 +53,7 @@ local gates = {
for _, row in pairs(gates) do
-minetest.register_node("ethereal:"..row[1].."gate_open", {
+minetest.register_node("ethereal:fencegate_"..row[1].."_open", {
tiles = {row[3]},
paramtype = "light",
paramtype2 = "facedir",
@@ -60,7 +61,7 @@ minetest.register_node("ethereal:"..row[1].."gate_open", {
is_ground_content = false,
walkable = true,
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, not_in_inventory = 1},
- drop = "ethereal:"..row[1].."gate_closed",
+ drop = "ethereal:fencegate_"..row[1].."_closed",
drawtype = "nodebox",
node_box = {
type = "fixed",
@@ -87,7 +88,9 @@ minetest.register_node("ethereal:"..row[1].."gate_open", {
on_rightclick = gate_rightclick,
})
-minetest.register_node("ethereal:"..row[1].."gate_closed", {
+minetest.register_alias("ethereal:"..row[1].."gate_open", "ethereal:fencegate_"..row[1].."_open")
+
+minetest.register_node("ethereal:fencegate_"..row[1].."_closed", {
description = row[2].." Gate",
tiles = {row[3]},
inventory_image = "default_gate_overlay.png^"..row[3].."^default_gate_overlay.png^[makealpha:255,126,126",
@@ -114,13 +117,14 @@ minetest.register_node("ethereal:"..row[1].."gate_closed", {
},
on_rightclick = gate_rightclick,
})
+minetest.register_alias("ethereal:"..row[1].."gate_closed", "ethereal:fencegate_"..row[1].."_closed")
minetest.register_craft({
- output = "ethereal:"..row[1].."gate_closed",
+ output = "ethereal:fencegate_"..row[1].."_closed",
recipe = {
{"group:stick", row[4], "group:stick"},
{"group:stick", row[4], "group:stick"},
}
})
-end \ No newline at end of file
+end