summaryrefslogtreecommitdiff
path: root/gates.lua
diff options
context:
space:
mode:
authortenplus1 <kinsellaja@yahoo.com>2015-05-29 10:25:35 +0100
committertenplus1 <kinsellaja@yahoo.com>2015-05-29 10:25:35 +0100
commit87316b50837e82d22a7cc21b5e583f47f00b1be5 (patch)
tree4a90b10ca39953ad7d620e4226ba002e9f2d1f42 /gates.lua
parentf438eadeb98c75252fe550ac2366b06db5022406 (diff)
Code Tidy (thanks HybridDog)
Diffstat (limited to 'gates.lua')
-rw-r--r--gates.lua27
1 files changed, 13 insertions, 14 deletions
diff --git a/gates.lua b/gates.lua
index 1a20ae5..0020ef9 100644
--- a/gates.lua
+++ b/gates.lua
@@ -15,18 +15,20 @@ local nb_pil = {
-- Open/Close Gates
function gate_rightclick(pos, node)
- local data = nil
- data = string.split(node.name, "_", 2)
- local gate = data[1].."_"
- local open = data[2]
-
+ local gate, open = unpack(string.split(node.name, "_", 2))
+ local gate = gate.."_"
+
+ local sound, name
if open == "open" then
- minetest.sound_play("doors_door_close", {pos=pos, gain = 0.3, max_hear_distance = 10})
- minetest.set_node(pos, {name=gate.."closed", param2=node.param2})
+ sound = "close"
+ name = "closed"
else
- minetest.sound_play("doors_door_open", {pos=pos, gain = 0.3, max_hear_distance = 10})
- minetest.set_node(pos, {name=gate.."open", param2=node.param2})
+ sound = "open"
+ name = "open"
end
+ node.name = gate..name
+ minetest.set_node(pos, node)
+ minetest.sound_play("doors_door_"..sound, {pos=pos, gain = 0.3, max_hear_distance = 10})
end
local gate = {}
@@ -46,11 +48,8 @@ gate.type = {
{"pine", "Pine Wood", "default_pinewood.png", "default:pinewood"},
}
-for _, row in ipairs(gate.type) do
- local name = row[1]
- local desc = row[2]
- local texture = row[3]
- local nod = row[4]
+for _, row in pairs(gate.type) do
+ local name, desc, texture, nod = unpack(row)
minetest.register_node("ethereal:"..name.."gate_open", {
tiles = {texture},