Beds: Fix code style issues

This commit is contained in:
paramat 2016-03-08 03:14:29 +00:00
parent aa676ab878
commit 45bc0b245f
5 changed files with 86 additions and 83 deletions

View File

@ -19,6 +19,7 @@ function beds.register_bed(name, def)
type = "fixed", type = "fixed",
fixed = def.selectionbox, fixed = def.selectionbox,
}, },
after_place_node = function(pos, placer, itemstack) after_place_node = function(pos, placer, itemstack)
local n = minetest.get_node_or_nil(pos) local n = minetest.get_node_or_nil(pos)
if not n or not n.param2 then if not n or not n.param2 then
@ -36,6 +37,7 @@ function beds.register_bed(name, def)
minetest.set_node(p, {name = n.name:gsub("%_bottom", "_top"), param2 = n.param2}) minetest.set_node(p, {name = n.name:gsub("%_bottom", "_top"), param2 = n.param2})
return false return false
end, end,
on_destruct = function(pos) on_destruct = function(pos)
local n = minetest.get_node_or_nil(pos) local n = minetest.get_node_or_nil(pos)
if not n then return end if not n then return end
@ -46,9 +48,11 @@ function beds.register_bed(name, def)
minetest.remove_node(p) minetest.remove_node(p)
end end
end, end,
on_rightclick = function(pos, node, clicker) on_rightclick = function(pos, node, clicker)
beds.on_rightclick(pos, clicker) beds.on_rightclick(pos, clicker)
end, end,
on_rotate = function(pos, node, user, mode, new_param2) on_rotate = function(pos, node, user, mode, new_param2)
local dir = minetest.facedir_to_dir(node.param2) local dir = minetest.facedir_to_dir(node.param2)
local p = vector.add(pos, dir) local p = vector.add(pos, dir)
@ -99,7 +103,6 @@ function beds.register_bed(name, def)
minetest.register_alias(name, name .. "_bottom") minetest.register_alias(name, name .. "_bottom")
-- register recipe
minetest.register_craft({ minetest.register_craft({
output = name, output = name,
recipe = def.recipe recipe = def.recipe

View File

@ -1,4 +1,5 @@
-- fancy shaped bed -- Fancy shaped bed
beds.register_bed("beds:fancy_bed", { beds.register_bed("beds:fancy_bed", {
description = "Fancy Bed", description = "Fancy Bed",
inventory_image = "beds_bed_fancy.png", inventory_image = "beds_bed_fancy.png",
@ -48,7 +49,8 @@ beds.register_bed("beds:fancy_bed", {
}, },
}) })
-- simple shaped bed -- Simple shaped bed
beds.register_bed("beds:bed", { beds.register_bed("beds:bed", {
description = "Simple Bed", description = "Simple Bed",
inventory_image = "beds_bed.png", inventory_image = "beds_bed.png",
@ -80,9 +82,9 @@ beds.register_bed("beds:bed", {
{"wool:red", "wool:red", "wool:white"}, {"wool:red", "wool:red", "wool:white"},
{"group:wood", "group:wood", "group:wood"} {"group:wood", "group:wood", "group:wood"}
}, },
}) })
-- aliases for PA's beds mod -- Aliases for PilzAdam's beds mod
minetest.register_alias("beds:bed_bottom_red", "beds:bed_bottom") minetest.register_alias("beds:bed_bottom_red", "beds:bed_bottom")
minetest.register_alias("beds:bed_top_red", "beds:bed_top") minetest.register_alias("beds:bed_top_red", "beds:bed_top")

View File

@ -6,8 +6,7 @@ if enable_respawn == nil then
enable_respawn = true enable_respawn = true
end end
-- Helper functions
-- helper functions
local function get_look_yaw(pos) local function get_look_yaw(pos)
local n = minetest.get_node(pos) local n = minetest.get_node(pos)
@ -105,14 +104,12 @@ local function update_formspecs(finished)
local is_majority = (ges / 2) < player_in_bed local is_majority = (ges / 2) < player_in_bed
if finished then if finished then
form_n = beds.formspec .. form_n = beds.formspec .. "label[2.7,11; Good morning.]"
"label[2.7,11; Good morning.]"
else else
form_n = beds.formspec .. form_n = beds.formspec .. "label[2.2,11;" .. tostring(player_in_bed) ..
"label[2.2,11;"..tostring(player_in_bed).." of "..tostring(ges).." players are in bed]" " of " .. tostring(ges) .. " players are in bed]"
if is_majority and is_night_skip_enabled() then if is_majority and is_night_skip_enabled() then
form_n = form_n .. form_n = form_n .. "button_exit[2,8;4,0.75;force;Force night skip]"
"button_exit[2,8;4,0.75;force;Force night skip]"
end end
end end
@ -122,7 +119,7 @@ local function update_formspecs(finished)
end end
-- public functions -- Public functions
function beds.kick_players() function beds.kick_players()
for name, _ in pairs(beds.player) do for name, _ in pairs(beds.player) do
@ -175,7 +172,7 @@ function beds.on_rightclick(pos, player)
end end
-- callbacks -- Callbacks
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
beds.read_spawns() beds.read_spawns()

View File

@ -9,7 +9,8 @@ beds.formspec = "size[8,15;true]"..
local modpath = minetest.get_modpath("beds") local modpath = minetest.get_modpath("beds")
-- load files -- Load files
dofile(modpath .. "/functions.lua") dofile(modpath .. "/functions.lua")
dofile(modpath .. "/api.lua") dofile(modpath .. "/api.lua")
dofile(modpath .. "/beds.lua") dofile(modpath .. "/beds.lua")