forked from minetest/minetest_game
Doors: Code cleanup
Remove spaces inside curly brackets Split lines over 90 columns
This commit is contained in:
parent
60f6564c75
commit
3d44804074
@ -1,4 +1,3 @@
|
||||
|
||||
--[[
|
||||
|
||||
Copyright (C) 2012 PilzAdam
|
||||
@ -166,9 +165,11 @@ function _doors.door_toggle(pos, clicker)
|
||||
|
||||
local dir = minetest.get_node(pos).param2
|
||||
if state % 2 == 0 then
|
||||
minetest.sound_play(def.door.sounds[1], {pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||
minetest.sound_play(def.door.sounds[1],
|
||||
{pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||
else
|
||||
minetest.sound_play(def.door.sounds[2], {pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||
minetest.sound_play(def.door.sounds[2],
|
||||
{pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||
end
|
||||
|
||||
minetest.swap_node(pos, {
|
||||
@ -181,21 +182,25 @@ function _doors.door_toggle(pos, clicker)
|
||||
end
|
||||
|
||||
|
||||
local function on_place_node(place_to, newnode, placer, oldnode, itemstack, pointed_thing)
|
||||
local function on_place_node(place_to, newnode,
|
||||
placer, oldnode, itemstack, pointed_thing)
|
||||
-- Run script hook
|
||||
local _, callback
|
||||
for _, callback in ipairs(core.registered_on_placenodes) do
|
||||
-- Deepcopy pos, node and pointed_thing because callback can modify them
|
||||
local place_to_copy = {x = place_to.x, y = place_to.y, z = place_to.z}
|
||||
local newnode_copy = {name = newnode.name, param1 = newnode.param1, param2 = newnode.param2}
|
||||
local oldnode_copy = {name = oldnode.name, param1 = oldnode.param1, param2 = oldnode.param2}
|
||||
local newnode_copy =
|
||||
{name = newnode.name, param1 = newnode.param1, param2 = newnode.param2}
|
||||
local oldnode_copy =
|
||||
{name = oldnode.name, param1 = oldnode.param1, param2 = oldnode.param2}
|
||||
local pointed_thing_copy = {
|
||||
type = pointed_thing.type,
|
||||
above = vector.new(pointed_thing.above),
|
||||
under = vector.new(pointed_thing.under),
|
||||
ref = pointed_thing.ref,
|
||||
}
|
||||
callback(place_to_copy, newnode_copy, placer, oldnode_copy, itemstack, pointed_thing_copy)
|
||||
callback(place_to_copy, newnode_copy, placer,
|
||||
oldnode_copy, itemstack, pointed_thing_copy)
|
||||
end
|
||||
end
|
||||
|
||||
@ -269,7 +274,8 @@ function doors.register(name, def)
|
||||
end
|
||||
|
||||
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||
if not minetest.registered_nodes[minetest.get_node(above).name].buildable_to then
|
||||
if not minetest.registered_nodes[
|
||||
minetest.get_node(above).name].buildable_to then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
@ -316,7 +322,8 @@ function doors.register(name, def)
|
||||
itemstack:take_item()
|
||||
end
|
||||
|
||||
on_place_node(pos, minetest.get_node(pos), placer, node, itemstack, pointed_thing)
|
||||
on_place_node(pos, minetest.get_node(pos),
|
||||
placer, node, itemstack, pointed_thing)
|
||||
|
||||
return itemstack
|
||||
end
|
||||
@ -514,11 +521,15 @@ function _doors.trapdoor_toggle(pos, clicker)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
|
||||
if string.sub(node.name, -5) == "_open" then
|
||||
minetest.sound_play(def.sound_close, {pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||
minetest.swap_node(pos, {name = string.sub(node.name, 1, string.len(node.name) - 5), param1 = node.param1, param2 = node.param2})
|
||||
minetest.sound_play(def.sound_close,
|
||||
{pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||
minetest.swap_node(pos, {name = string.sub(node.name, 1,
|
||||
string.len(node.name) - 5), param1 = node.param1, param2 = node.param2})
|
||||
else
|
||||
minetest.sound_play(def.sound_open, {pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||
minetest.swap_node(pos, {name = node.name .. "_open", param1 = node.param1, param2 = node.param2})
|
||||
minetest.sound_play(def.sound_open,
|
||||
{pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||
minetest.swap_node(pos, {name = node.name .. "_open",
|
||||
param1 = node.param1, param2 = node.param2})
|
||||
end
|
||||
end
|
||||
|
||||
@ -527,7 +538,8 @@ function doors.register_trapdoor(name, def)
|
||||
local name_opened = name.."_open"
|
||||
|
||||
local function check_player_priv(pos, player)
|
||||
if not def.protected or minetest.check_player_privs(player, "protection_bypass") then
|
||||
if not def.protected or
|
||||
minetest.check_player_privs(player, "protection_bypass") then
|
||||
return true
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
Loading…
Reference in New Issue
Block a user