Code tweak and tidy

This commit is contained in:
TenPlus1 2016-02-13 16:58:23 +00:00
parent fdfed1680a
commit 09ea90049e
2 changed files with 31 additions and 42 deletions

View File

@ -1,7 +1,7 @@
-- Since the doors mod has changed in the latest daily builds I have taken the -- Since the doors mod has changed in the latest daily builds I have taken the
-- WTFPL licenced code from the old doors mod and included an edited version -- WTFPL licenced code from the old doors mod and included an edited version
-- of it within this mod. -- of it within this mod for local use.
-- Registers a door -- Registers a door
function register_door(name, def) function register_door(name, def)
@ -9,25 +9,12 @@ function register_door(name, def)
local box = {{-0.5, -0.5, -0.5, 0.5, 0.5, -0.5+1.5/16}} local box = {{-0.5, -0.5, -0.5, 0.5, 0.5, -0.5+1.5/16}}
if not def.node_box_bottom then def.node_box_bottom = box
def.node_box_bottom = box def.node_box_top = box
end def.selection_box_bottom = box
if not def.node_box_top then def.selection_box_top = box
def.node_box_top = box def.sound_close_door = "doors_door_close"
end def.sound_open_door = "doors_door_open"
if not def.selection_box_bottom then
def.selection_box_bottom= box
end
if not def.selection_box_top then
def.selection_box_top = box
end
if not def.sound_close_door then
def.sound_close_door = "doors_door_close"
end
if not def.sound_open_door then
def.sound_open_door = "doors_door_open"
end
minetest.register_craftitem(name, { minetest.register_craftitem(name, {
description = def.description, description = def.description,
@ -101,13 +88,6 @@ function register_door(name, def)
end end
end end
local function check_and_blast(pos, name)
local node = minetest.get_node(pos)
if node.name == name then
minetest.remove_node(pos)
end
end
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params) local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
pos.y = pos.y+dir pos.y = pos.y+dir
if minetest.get_node(pos).name ~= check_name then if minetest.get_node(pos).name ~= check_name then
@ -136,9 +116,7 @@ function register_door(name, def)
end end
local function on_rotate(pos, node, dir, user, check_name, mode, new_param2) local function on_rotate(pos, node, dir, user, check_name, mode, new_param2)
if not check_player_priv(pos, user) then
return false
end
if mode ~= screwdriver.ROTATE_FACE then if mode ~= screwdriver.ROTATE_FACE then
return false return false
end end
@ -194,7 +172,6 @@ function register_door(name, def)
return on_rotate(pos, node, 1, user, name.."_t_1", mode) return on_rotate(pos, node, 1, user, name.."_t_1", mode)
end, end,
can_dig = check_player_priv,
sounds = def.sounds, sounds = def.sounds,
sunlight_propagates = def.sunlight, sunlight_propagates = def.sunlight,
on_blast = function() end, on_blast = function() end,
@ -232,7 +209,6 @@ function register_door(name, def)
return on_rotate(pos, node, -1, user, name.."_b_1", mode) return on_rotate(pos, node, -1, user, name.."_b_1", mode)
end, end,
can_dig = check_player_priv,
sounds = def.sounds, sounds = def.sounds,
sunlight_propagates = def.sunlight, sunlight_propagates = def.sunlight,
on_blast = function() end, on_blast = function() end,
@ -270,7 +246,6 @@ function register_door(name, def)
return on_rotate(pos, node, 1, user, name.."_t_2", mode) return on_rotate(pos, node, 1, user, name.."_t_2", mode)
end, end,
can_dig = check_player_priv,
sounds = def.sounds, sounds = def.sounds,
sunlight_propagates = def.sunlight, sunlight_propagates = def.sunlight,
on_blast = function() end, on_blast = function() end,
@ -308,7 +283,6 @@ function register_door(name, def)
return on_rotate(pos, node, -1, user, name.."_b_2", mode) return on_rotate(pos, node, -1, user, name.."_b_2", mode)
end, end,
can_dig = check_player_priv,
sounds = def.sounds, sounds = def.sounds,
sunlight_propagates = def.sunlight, sunlight_propagates = def.sunlight,
on_blast = function() end, on_blast = function() end,
@ -394,8 +368,8 @@ function register_trapdoor(name, def)
end end
local newname = node.name == name_closed and name_opened or name_closed local newname = node.name == name_closed and name_opened or name_closed
local sound = false local sound = false
if node.name == name_closed then sound = def.sound_open end if node.name == name_closed then sound = "doors_door_open" end
if node.name == name_opened then sound = def.sound_close end if node.name == name_opened then sound = "doors_door_close" end
if sound then if sound then
minetest.sound_play(sound, {pos = pos, gain = 0.3, max_hear_distance = 10}) minetest.sound_play(sound, {pos = pos, gain = 0.3, max_hear_distance = 10})
end end
@ -407,7 +381,6 @@ function register_trapdoor(name, def)
def.paramtype = "light" def.paramtype = "light"
def.paramtype2 = "facedir" def.paramtype2 = "facedir"
def.is_ground_content = false def.is_ground_content = false
def.can_dig = check_player_priv
local def_opened = table.copy(def) local def_opened = table.copy(def)
local def_closed = table.copy(def) local def_closed = table.copy(def)
@ -456,8 +429,6 @@ register_trapdoor("protector:trapdoor", {
door = 1, unbreakable = 1 door = 1, unbreakable = 1
}, },
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
sound_open = "doors_door_open",
sound_close = "doors_door_close"
}) })
minetest.register_craft({ minetest.register_craft({
@ -489,8 +460,6 @@ register_trapdoor("protector:trapdoor_steel", {
door = 1, unbreakable = 1 door = 1, unbreakable = 1
}, },
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
sound_open = "doors_door_open",
sound_close = "doors_door_close"
}) })
minetest.register_craft({ minetest.register_craft({

View File

@ -11,4 +11,24 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO. 0. You just DO WHAT THE FUCK YOU WANT TO.
License of textures
--------------------------------------
following Textures created by Fernando Zapata (CC BY-SA 3.0):
door_wood.png
door_wood_a.png
door_wood_a_r.png
door_wood_b.png
door_wood_b_r.png
following Textures created by BlockMen (WTFPL):
door_trapdoor.png
following textures created by sofar (CC-BY-SA-3.0)
doors_trapdoor_steel.png
doors_trapdoor_steel_side.png
door_trapdoor_side.png
All other door textures (created by PilzAdam): WTFPL