From d76ab30892b622409cec75f4561c2ca7b412da5c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 7 May 2017 20:21:37 +0200 Subject: [PATCH] Rename beds mod to mcl_beds --- mods/ITEMS/beds/beds.lua | 34 ------------ mods/ITEMS/{beds => mcl_beds}/README.txt | 0 mods/ITEMS/{beds => mcl_beds}/api.lua | 12 ++-- mods/ITEMS/mcl_beds/beds.lua | 50 +++++++++++++++++ mods/ITEMS/{beds => mcl_beds}/depends.txt | 0 mods/ITEMS/{beds => mcl_beds}/functions.lua | 52 +++++++++--------- mods/ITEMS/{beds => mcl_beds}/init.lua | 12 ++-- mods/ITEMS/{beds => mcl_beds}/license.txt | 0 mods/ITEMS/mcl_beds/mod.conf | 1 + mods/ITEMS/{beds => mcl_beds}/spawns.lua | 24 ++++---- .../textures/mcl_beds_bed_bottom_bottom.png} | Bin .../textures/mcl_beds_bed_bottom_top.png} | Bin .../textures/mcl_beds_bed_red.png} | Bin .../mcl_beds_bed_side_bottom_r_red.png} | Bin .../mcl_beds_bed_side_bottom_red.png} | Bin .../textures/mcl_beds_bed_side_top_r_red.png} | Bin .../textures/mcl_beds_bed_side_top_red.png} | Bin .../textures/mcl_beds_bed_top_bottom_red.png} | Bin .../textures/mcl_beds_bed_top_top_red.png} | Bin 19 files changed, 102 insertions(+), 83 deletions(-) delete mode 100644 mods/ITEMS/beds/beds.lua rename mods/ITEMS/{beds => mcl_beds}/README.txt (100%) rename mods/ITEMS/{beds => mcl_beds}/api.lua (96%) create mode 100644 mods/ITEMS/mcl_beds/beds.lua rename mods/ITEMS/{beds => mcl_beds}/depends.txt (100%) rename mods/ITEMS/{beds => mcl_beds}/functions.lua (82%) rename mods/ITEMS/{beds => mcl_beds}/init.lua (57%) rename mods/ITEMS/{beds => mcl_beds}/license.txt (100%) create mode 100644 mods/ITEMS/mcl_beds/mod.conf rename mods/ITEMS/{beds => mcl_beds}/spawns.lua (75%) rename mods/ITEMS/{beds/textures/beds_bed_bottom_bottom.png => mcl_beds/textures/mcl_beds_bed_bottom_bottom.png} (100%) rename mods/ITEMS/{beds/textures/beds_bed_bottom_top.png => mcl_beds/textures/mcl_beds_bed_bottom_top.png} (100%) rename mods/ITEMS/{beds/textures/beds_bed.png => mcl_beds/textures/mcl_beds_bed_red.png} (100%) rename mods/ITEMS/{beds/textures/beds_bed_side_bottom_r.png => mcl_beds/textures/mcl_beds_bed_side_bottom_r_red.png} (100%) rename mods/ITEMS/{beds/textures/beds_bed_side_bottom.png => mcl_beds/textures/mcl_beds_bed_side_bottom_red.png} (100%) rename mods/ITEMS/{beds/textures/beds_bed_side_top_r.png => mcl_beds/textures/mcl_beds_bed_side_top_r_red.png} (100%) rename mods/ITEMS/{beds/textures/beds_bed_side_top.png => mcl_beds/textures/mcl_beds_bed_side_top_red.png} (100%) rename mods/ITEMS/{beds/textures/beds_bed_top_bottom.png => mcl_beds/textures/mcl_beds_bed_top_bottom_red.png} (100%) rename mods/ITEMS/{beds/textures/beds_bed_top_top.png => mcl_beds/textures/mcl_beds_bed_top_top_red.png} (100%) diff --git a/mods/ITEMS/beds/beds.lua b/mods/ITEMS/beds/beds.lua deleted file mode 100644 index 08ae84496..000000000 --- a/mods/ITEMS/beds/beds.lua +++ /dev/null @@ -1,34 +0,0 @@ --- Simple shaped bed - -beds.register_bed("beds:bed", { - description = "Bed", - inventory_image = "beds_bed.png", - wield_image = "beds_bed.png", - tiles = { - bottom = { - "beds_bed_top_bottom.png^[transformR90", - "default_wood.png", - "beds_bed_side_bottom_r.png", - "beds_bed_side_bottom_r.png^[transformfx", - "blank.png", - "beds_bed_side_bottom.png" - }, - top = { - "beds_bed_top_top.png^[transformR90", - "default_wood.png", - "beds_bed_side_top_r.png", - "beds_bed_side_top_r.png^[transformfx", - "beds_bed_side_top.png", - "blank.png", - } - }, - nodebox = { - bottom = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5}, - top = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5}, - }, - selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.06, 1.5}, - recipe = { - {"group:wool", "group:wool", "group:wool"}, - {"group:wood", "group:wood", "group:wood"} - }, -}) diff --git a/mods/ITEMS/beds/README.txt b/mods/ITEMS/mcl_beds/README.txt similarity index 100% rename from mods/ITEMS/beds/README.txt rename to mods/ITEMS/mcl_beds/README.txt diff --git a/mods/ITEMS/beds/api.lua b/mods/ITEMS/mcl_beds/api.lua similarity index 96% rename from mods/ITEMS/beds/api.lua rename to mods/ITEMS/mcl_beds/api.lua index 765f2fca3..d5235674a 100644 --- a/mods/ITEMS/beds/api.lua +++ b/mods/ITEMS/mcl_beds/api.lua @@ -35,7 +35,7 @@ else beddesc = beddesc .. "Going into bed seems to make time pass faster: The night will be skipped when you go sleep and you're alone in this world. If you're not alone, the night is skipped when all players in this world went to sleep." end -function beds.register_bed(name, def) +function mcl_beds.register_bed(name, def) minetest.register_node(name .. "_bottom", { description = def.description, _doc_items_longdesc = def._doc_items_longdesc or beddesc, @@ -59,9 +59,8 @@ function beds.register_bed(name, def) }, selection_box = { type = "fixed", - fixed = def.selectionbox, + fixed = def.selectionbox.bottom, }, - on_place = function(itemstack, placer, pointed_thing) local under = pointed_thing.under @@ -119,7 +118,7 @@ function beds.register_bed(name, def) end, on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) - beds.on_rightclick(pos, clicker) + mcl_beds.on_rightclick(pos, clicker) return itemstack end, @@ -164,7 +163,6 @@ function beds.register_bed(name, def) paramtype2 = "facedir", sunlight_propagates = true, is_ground_content = false, - pointable = false, groups = {handy = 1, flammable = 3, bed = 2, dig_by_piston=1, fall_damage_add_percent=-50}, _mcl_hardness = 0.2, _mcl_blast_resistance = 1, @@ -174,6 +172,10 @@ function beds.register_bed(name, def) type = "fixed", fixed = def.nodebox.top, }, + selection_box = { + type = "fixed", + fixed = def.selectionbox.top, + }, on_destruct = function(pos) destruct_bed(pos, 2) end, diff --git a/mods/ITEMS/mcl_beds/beds.lua b/mods/ITEMS/mcl_beds/beds.lua new file mode 100644 index 000000000..53ccc3ef1 --- /dev/null +++ b/mods/ITEMS/mcl_beds/beds.lua @@ -0,0 +1,50 @@ +-- 3D bed + +local nodebox = { + bottom = { + {-0.5, -5/16, -0.5, 0.5, 0.06, 0.5}, + {-0.5, -0.5, -0.5, -5/16, -5/16, -5/16}, + {0.5, -0.5, -0.5, 5/16, -5/16, -5/16}, + }, + top = { + {-0.5, -5/16, -0.5, 0.5, 0.06, 0.5}, + {-0.5, -0.5, 0.5, -5/16, -5/16, 5/16}, + {0.5, -0.5, 0.5, 5/16, -5/16, 5/16}, + }, +} + +mcl_beds.register_bed("mcl_beds:bed_red", { + description = "Bed", + inventory_image = "mcl_beds_bed_red.png", + wield_image = "mcl_beds_bed_red.png", + tiles = { + bottom = { + "mcl_beds_bed_top_bottom_red.png", + "mcl_beds_bed_bottom_bottom.png", + "mcl_beds_bed_side_bottom_r_red.png", + "mcl_beds_bed_side_bottom_r_red.png^[transformfx", + "mcl_beds_bed_side_top_red.png", + "mcl_beds_bed_side_bottom_red.png" + }, + top = { + "mcl_beds_bed_top_top_red.png", + "mcl_beds_bed_bottom_top.png", + "mcl_beds_bed_side_top_r_red.png", + "mcl_beds_bed_side_top_r_red.png^[transformfx", + "mcl_beds_bed_side_top_red.png", + "mcl_beds_bed_side_bottom_red.png" + } + }, + nodebox = nodebox, + selectionbox = { + bottom = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5}, + top = {-0.5, -0.5, -0.5, 0.5, 0.06, 0.5}, + }, + recipe = { + {"group:wool", "group:wool", "group:wool"}, + {"group:wood", "group:wood", "group:wood"} + }, +}) + +minetest.register_alias("beds:bed_bottom", "mcl_beds:bed_red_bottom") +minetest.register_alias("beds:bed_top", "mcl_beds:bed_red_top") diff --git a/mods/ITEMS/beds/depends.txt b/mods/ITEMS/mcl_beds/depends.txt similarity index 100% rename from mods/ITEMS/beds/depends.txt rename to mods/ITEMS/mcl_beds/depends.txt diff --git a/mods/ITEMS/beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua similarity index 82% rename from mods/ITEMS/beds/functions.lua rename to mods/ITEMS/mcl_beds/functions.lua index ff315ff7b..db1ece7da 100644 --- a/mods/ITEMS/beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -30,7 +30,7 @@ local function is_night_skip_enabled() end local function check_in_beds(players) - local in_bed = beds.player + local in_bed = mcl_beds.player if not players then players = minetest.get_connected_players() end @@ -55,9 +55,9 @@ local function lay_down(player, pos, bed_pos, state, skip) -- stand up if state ~= nil and not state then - local p = beds.pos[name] or nil - if beds.player[name] ~= nil then - beds.player[name] = nil + local p = mcl_beds.pos[name] or nil + if mcl_beds.player[name] ~= nil then + mcl_beds.player[name] = nil player_in_bed = player_in_bed - 1 end -- skip here to prevent sending player specific changes (used for leaving players) @@ -78,8 +78,8 @@ local function lay_down(player, pos, bed_pos, state, skip) -- lay down else - beds.player[name] = 1 - beds.pos[name] = pos + mcl_beds.player[name] = 1 + mcl_beds.pos[name] = pos player_in_bed = player_in_bed + 1 -- physics, eye_offset, etc @@ -104,42 +104,42 @@ local function update_formspecs(finished) local all_in_bed = ges == player_in_bed if finished then - form_n = beds.formspec .. "label[2.7,11; Good morning.]" + form_n = mcl_beds.formspec .. "label[2.7,11; Good morning.]" else - form_n = beds.formspec .. "label[2.2,11;" .. tostring(player_in_bed) .. + form_n = mcl_beds.formspec .. "label[2.2,11;" .. tostring(player_in_bed) .. " of " .. tostring(ges) .. " players are in bed]" if all_in_bed and is_night_skip_enabled() then form_n = form_n .. "button_exit[2,8;4,0.75;force;Force night skip]" end end - for name,_ in pairs(beds.player) do - minetest.show_formspec(name, "beds_form", form_n) + for name,_ in pairs(mcl_beds.player) do + minetest.show_formspec(name, "mcl_beds_form", form_n) end end -- Public functions -function beds.kick_players() - for name, _ in pairs(beds.player) do +function mcl_beds.kick_players() + for name, _ in pairs(mcl_beds.player) do local player = minetest.get_player_by_name(name) lay_down(player, nil, nil, false) end end -function beds.skip_night() +function mcl_beds.skip_night() minetest.set_timeofday(0.25) -- tod = 6000 end -function beds.on_rightclick(pos, player) +function mcl_beds.on_rightclick(pos, player) local name = player:get_player_name() local ppos = player:getpos() local tod = minetest.get_timeofday() * 24000 -- Values taken from Minecraft Wiki with offset of +6000 if tod < 18541 and tod > 5458 then - if beds.player[name] then + if mcl_beds.player[name] then lay_down(player, nil, nil, false) end minetest.chat_send_player(name, "You can only sleep at night.") @@ -147,9 +147,9 @@ function beds.on_rightclick(pos, player) end -- move to bed - if not beds.player[name] then + if not mcl_beds.player[name] then lay_down(player, ppos, pos) - beds.set_spawns() -- save respawn positions when entering bed + mcl_beds.set_spawns() -- save respawn positions when entering bed else lay_down(player, nil, nil, false) end @@ -165,8 +165,8 @@ function beds.on_rightclick(pos, player) update_formspecs(is_night_skip_enabled()) end if is_night_skip_enabled() then - beds.skip_night() - beds.kick_players() + mcl_beds.skip_night() + mcl_beds.kick_players() end end) end @@ -179,7 +179,7 @@ if enable_respawn then -- respawn player at bed if enabled and valid position is found minetest.register_on_respawnplayer(function(player) local name = player:get_player_name() - local pos = beds.spawn[name] + local pos = mcl_beds.spawn[name] if pos then player:setpos(pos) return true @@ -190,20 +190,20 @@ end minetest.register_on_leaveplayer(function(player) local name = player:get_player_name() lay_down(player, nil, nil, false, true) - beds.player[name] = nil + mcl_beds.player[name] = nil if check_in_beds() then minetest.after(2, function() update_formspecs(is_night_skip_enabled()) if is_night_skip_enabled() then - beds.skip_night() - beds.kick_players() + mcl_beds.skip_night() + mcl_beds.kick_players() end end) end end) minetest.register_on_player_receive_fields(function(player, formname, fields) - if formname ~= "beds_form" then + if formname ~= "mcl_beds_form" then return end if fields.quit or fields.leave then @@ -214,8 +214,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if fields.force then update_formspecs(is_night_skip_enabled()) if is_night_skip_enabled() then - beds.skip_night() - beds.kick_players() + mcl_beds.skip_night() + mcl_beds.kick_players() end end end) diff --git a/mods/ITEMS/beds/init.lua b/mods/ITEMS/mcl_beds/init.lua similarity index 57% rename from mods/ITEMS/beds/init.lua rename to mods/ITEMS/mcl_beds/init.lua index 8b2589017..40b646522 100644 --- a/mods/ITEMS/beds/init.lua +++ b/mods/ITEMS/mcl_beds/init.lua @@ -1,13 +1,13 @@ -beds = {} -beds.player = {} -beds.pos = {} -beds.spawn = {} +mcl_beds = {} +mcl_beds.player = {} +mcl_beds.pos = {} +mcl_beds.spawn = {} -beds.formspec = "size[8,15;true]" .. +mcl_beds.formspec = "size[8,15;true]" .. "bgcolor[#080808BB; true]" .. "button_exit[2,12;4,0.75;leave;Leave Bed]" -local modpath = minetest.get_modpath("beds") +local modpath = minetest.get_modpath("mcl_beds") -- Load files diff --git a/mods/ITEMS/beds/license.txt b/mods/ITEMS/mcl_beds/license.txt similarity index 100% rename from mods/ITEMS/beds/license.txt rename to mods/ITEMS/mcl_beds/license.txt diff --git a/mods/ITEMS/mcl_beds/mod.conf b/mods/ITEMS/mcl_beds/mod.conf new file mode 100644 index 000000000..62645f3b4 --- /dev/null +++ b/mods/ITEMS/mcl_beds/mod.conf @@ -0,0 +1 @@ +name = mcl_beds diff --git a/mods/ITEMS/beds/spawns.lua b/mods/ITEMS/mcl_beds/spawns.lua similarity index 75% rename from mods/ITEMS/beds/spawns.lua rename to mods/ITEMS/mcl_beds/spawns.lua index 70bfb38bb..11b09b12e 100644 --- a/mods/ITEMS/beds/spawns.lua +++ b/mods/ITEMS/mcl_beds/spawns.lua @@ -11,21 +11,21 @@ if cf ~= nil then bkwd = true end -function beds.save_spawns() - if not beds.spawn then +function mcl_beds.save_spawns() + if not mcl_beds.spawn then return end local data = {} local output = io.open(org_file, "w") - for k, v in pairs(beds.spawn) do + for k, v in pairs(mcl_beds.spawn) do table.insert(data, string.format("%.1f %.1f %.1f %s\n", v.x, v.y, v.z, k)) end output:write(table.concat(data)) io.close(output) end -function beds.read_spawns() - local spawns = beds.spawn +function mcl_beds.read_spawns() + local spawns = mcl_beds.spawn local input = io.open(file, "r") if input and not bkwd then repeat @@ -40,24 +40,24 @@ function beds.read_spawns() until input:read(0) == nil io.close(input) elseif input and bkwd then - beds.spawn = minetest.deserialize(input:read("*all")) + mcl_beds.spawn = minetest.deserialize(input:read("*all")) input:close() - beds.save_spawns() + mcl_beds.save_spawns() os.rename(file, file .. ".backup") file = org_file end end -beds.read_spawns() +mcl_beds.read_spawns() -function beds.set_spawns() - for name,_ in pairs(beds.player) do +function mcl_beds.set_spawns() + for name,_ in pairs(mcl_beds.player) do local player = minetest.get_player_by_name(name) local p = player:getpos() -- but don't change spawn location if borrowing a bed if not minetest.is_protected(p, name) then - beds.spawn[name] = p + mcl_beds.spawn[name] = p end end - beds.save_spawns() + mcl_beds.save_spawns() end diff --git a/mods/ITEMS/beds/textures/beds_bed_bottom_bottom.png b/mods/ITEMS/mcl_beds/textures/mcl_beds_bed_bottom_bottom.png similarity index 100% rename from mods/ITEMS/beds/textures/beds_bed_bottom_bottom.png rename to mods/ITEMS/mcl_beds/textures/mcl_beds_bed_bottom_bottom.png diff --git a/mods/ITEMS/beds/textures/beds_bed_bottom_top.png b/mods/ITEMS/mcl_beds/textures/mcl_beds_bed_bottom_top.png similarity index 100% rename from mods/ITEMS/beds/textures/beds_bed_bottom_top.png rename to mods/ITEMS/mcl_beds/textures/mcl_beds_bed_bottom_top.png diff --git a/mods/ITEMS/beds/textures/beds_bed.png b/mods/ITEMS/mcl_beds/textures/mcl_beds_bed_red.png similarity index 100% rename from mods/ITEMS/beds/textures/beds_bed.png rename to mods/ITEMS/mcl_beds/textures/mcl_beds_bed_red.png diff --git a/mods/ITEMS/beds/textures/beds_bed_side_bottom_r.png b/mods/ITEMS/mcl_beds/textures/mcl_beds_bed_side_bottom_r_red.png similarity index 100% rename from mods/ITEMS/beds/textures/beds_bed_side_bottom_r.png rename to mods/ITEMS/mcl_beds/textures/mcl_beds_bed_side_bottom_r_red.png diff --git a/mods/ITEMS/beds/textures/beds_bed_side_bottom.png b/mods/ITEMS/mcl_beds/textures/mcl_beds_bed_side_bottom_red.png similarity index 100% rename from mods/ITEMS/beds/textures/beds_bed_side_bottom.png rename to mods/ITEMS/mcl_beds/textures/mcl_beds_bed_side_bottom_red.png diff --git a/mods/ITEMS/beds/textures/beds_bed_side_top_r.png b/mods/ITEMS/mcl_beds/textures/mcl_beds_bed_side_top_r_red.png similarity index 100% rename from mods/ITEMS/beds/textures/beds_bed_side_top_r.png rename to mods/ITEMS/mcl_beds/textures/mcl_beds_bed_side_top_r_red.png diff --git a/mods/ITEMS/beds/textures/beds_bed_side_top.png b/mods/ITEMS/mcl_beds/textures/mcl_beds_bed_side_top_red.png similarity index 100% rename from mods/ITEMS/beds/textures/beds_bed_side_top.png rename to mods/ITEMS/mcl_beds/textures/mcl_beds_bed_side_top_red.png diff --git a/mods/ITEMS/beds/textures/beds_bed_top_bottom.png b/mods/ITEMS/mcl_beds/textures/mcl_beds_bed_top_bottom_red.png similarity index 100% rename from mods/ITEMS/beds/textures/beds_bed_top_bottom.png rename to mods/ITEMS/mcl_beds/textures/mcl_beds_bed_top_bottom_red.png diff --git a/mods/ITEMS/beds/textures/beds_bed_top_top.png b/mods/ITEMS/mcl_beds/textures/mcl_beds_bed_top_top_red.png similarity index 100% rename from mods/ITEMS/beds/textures/beds_bed_top_top.png rename to mods/ITEMS/mcl_beds/textures/mcl_beds_bed_top_top_red.png