From 4d5efb724dc5fe95591e8671410dbe8b5da929ec Mon Sep 17 00:00:00 2001 From: PilzAdam Date: Sun, 2 Sep 2012 19:15:05 +0200 Subject: [PATCH] Firts commit --- README.txt | 48 +++++++ depends.txt | 2 + init.lua | 211 +++++++++++++++++++++++++++++++ textures/beds_bed_side.png | Bin 0 -> 536 bytes textures/beds_bed_side_top_l.png | Bin 0 -> 500 bytes textures/beds_bed_side_top_r.png | Bin 0 -> 502 bytes textures/beds_bed_top_bottom.png | Bin 0 -> 539 bytes textures/beds_bed_top_top.png | Bin 0 -> 605 bytes 8 files changed, 261 insertions(+) create mode 100644 README.txt create mode 100644 depends.txt create mode 100644 init.lua create mode 100644 textures/beds_bed_side.png create mode 100644 textures/beds_bed_side_top_l.png create mode 100644 textures/beds_bed_side_top_r.png create mode 100644 textures/beds_bed_top_bottom.png create mode 100644 textures/beds_bed_top_top.png diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..0b8f4ac --- /dev/null +++ b/README.txt @@ -0,0 +1,48 @@ +===BEDS MOD for MINETEST-C55=== +by PilzAdam + +Introduction: +This mods brings beds to Minetest. You can use them to sleep at night +to prevent attacks by evil mobs. + +How to install: +Unzip the archive an place it in minetest-base-directory/mods/minetest/ +if you have a windows client or a linux run-in-place client. If you have +a linux system-wide instalation place it in ~/.minetest/mods/minetest/. +If you want to install this mod only in one world create the folder +worldmods/ in your worlddirectory. +For further information or help see: +http://wiki.minetest.com/wiki/Installing_Mods + +How to use the mod: +Craft a bed like this: +red wool blue wool blue wool +stick stick +(Theres no "normal" way to get wool so you can use the commands +"/giveme wool:red" and "/giveme wool:blue 2") +After placing it anywhere you can go to sleep with a leftklick with your +hand on the bed. If it is night a chatmessage wishs you "Good night" and +you sleep until the next morning. To go outside the bed it is recommended +to hit the bed again with a leftklick (it also works if you just go away +but its not so safe). + +License: +Sourcecode: WTFPL (see below) +Graphics: WTFPL (see below) + +See also: +http://minetest.net/ + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..470ec30 --- /dev/null +++ b/depends.txt @@ -0,0 +1,2 @@ +default +wool diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..9daab36 --- /dev/null +++ b/init.lua @@ -0,0 +1,211 @@ +local player_ges = 0 +local player_in_bed = 0 + +minetest.register_node("beds:bed_bottom", { + description = "Bed", + drawtype = "nodebox", + tiles = {"beds_bed_top_bottom.png", "default_wood.png", "beds_bed_side.png", "beds_bed_side.png", "beds_bed_side.png", "beds_bed_side.png"}, + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3}, + sounds = default.node_sound_wood_defaults(), + node_box = { + type = "fixed", + fixed = { + -- bed + {-0.5, 0.0, -0.5, 0.5, 0.3, 0.5}, + + -- stützen + {-0.5, -0.5, -0.5, -0.4, 0.0, -0.4}, + {0.4, 0.0, -0.4, 0.5, -0.5, -0.5}, + } + }, + selection_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.3, 1.5}, + } + }, + + + on_construct = function(pos) + local node = minetest.env:get_node(pos) + local param2 = node.param2 + if param2 == 0 then + node.name = "beds:bed_top" + pos.z = pos.z+1 + minetest.env:set_node(pos, node) + elseif param2 == 1 then + node.name = "beds:bed_top" + pos.x = pos.x+1 + minetest.env:set_node(pos, node) + elseif param2 == 2 then + node.name = "beds:bed_top" + pos.z = pos.z-1 + minetest.env:set_node(pos, node) + elseif param2 == 3 then + node.name = "beds:bed_top" + pos.x = pos.x-1 + minetest.env:set_node(pos, node) + end + end, + + on_destruct = function(pos) + local node = minetest.env:get_node(pos) + local param2 = node.param2 + if param2 == 0 then + pos.z = pos.z+1 + minetest.env:remove_node(pos) + elseif param2 == 1 then + pos.x = pos.x+1 + minetest.env:remove_node(pos) + elseif param2 == 2 then + pos.z = pos.z-1 + minetest.env:remove_node(pos) + elseif param2 == 3 then + pos.x = pos.x-1 + minetest.env:remove_node(pos) + end + end, + + on_punch = function(pos, node, puncher) + if not puncher:is_player() then + return + end + if puncher:get_wielded_item():get_name() == "" then + local meta = minetest.env:get_meta(pos) + local param2 = node.param2 + if param2 == 0 then + pos.z = pos.z+1 + elseif param2 == 1 then + pos.x = pos.x+1 + elseif param2 == 2 then + pos.z = pos.z-1 + elseif param2 == 3 then + pos.x = pos.x-1 + end + if puncher:get_player_name() == meta:get_string("player") then + if param2 == 0 then + pos.x = pos.x-1 + elseif param2 == 1 then + pos.z = pos.z+1 + elseif param2 == 2 then + pos.x = pos.x+1 + elseif param2 == 3 then + pos.z = pos.z-1 + end + pos.y = pos.y-0.5 + puncher:setpos(pos) + meta:set_string("player", "") + player_in_bed = player_in_bed-1 + elseif meta:get_string("player") == "" then + pos.y = pos.y-0.5 + puncher:setpos(pos) + meta:set_string("player", puncher:get_player_name()) + player_in_bed = player_in_bed+1 + end + end + end +}) + +minetest.register_node("beds:bed_top", { + drawtype = "nodebox", + tiles = {"beds_bed_top_top.png", "default_wood.png", "beds_bed_side_top_r.png", "beds_bed_side_top_l.png", "default_wood.png", "beds_bed_side.png"}, + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3}, + sounds = default.node_sound_wood_defaults(), + node_box = { + type = "fixed", + fixed = { + -- bed + {-0.5, 0.0, -0.5, 0.5, 0.3, 0.5}, + + -- stützen + {-0.4, 0.0, 0.4, -0.5, -0.5, 0.5}, + {0.5, -0.5, 0.5, 0.4, 0.0, 0.4}, + } + }, + selection_box = { + type = "fixed", + fixed = { + {0, 0, 0, 0, 0, 0}, + } + }, +}) + +minetest.register_alias("beds:bed", "beds:bed_bottom") + +minetest.register_craft({ + output = "beds:bed", + recipe = { + {"wool:white", "wool:white", "wool:white", }, + {"default:stick", "", "default:stick", } + } +}) + +minetest.register_on_joinplayer(function(pl) + player_ges = player_ges+1 +end) + +minetest.register_on_leaveplayer(function(pl) + player_ges = player_ges-1 +end) + +local timer = 0 +local wait = false +minetest.register_globalstep(function(dtime) + if timer<10 then + timer = timer+dtime + end + timer = 0 + + if player_ges == player_in_bed and player_ges ~= 0 then + if minetest.env:get_timeofday() < 0.2 or minetest.env:get_timeofday() > 0.805 then + if not wait then + minetest.chat_send_all("Good night!!!") + minetest.after(2, function() + minetest.env:set_timeofday(0.23) + wait = false + end) + wait = true + end + end + end +end) + +minetest.register_abm({ + nodenames = {"beds:bed_bottom"}, + interval = 1, + chance = 1, + action = function(pos, node) + local meta = minetest.env:get_meta(pos) + if meta:get_string("player") ~= "" then + local param2 = node.param2 + if param2 == 0 then + pos.z = pos.z+1 + elseif param2 == 1 then + pos.x = pos.x+1 + elseif param2 == 2 then + pos.z = pos.z-1 + elseif param2 == 3 then + pos.x = pos.x-1 + end + local player = minetest.env:get_player_by_name(meta:get_string("player")) + if player == nil then + meta:set_string("player", "") + player_in_bed = player_in_bed-1 + return + end + local player_pos = player:getpos() + player_pos.x = math.floor(0.5+player_pos.x) + player_pos.y = math.floor(0.5+player_pos.y) + player_pos.z = math.floor(0.5+player_pos.z) + if pos.x ~= player_pos.x or pos.y ~= player_pos.y or pos.z ~= player_pos.z then + meta:set_string("player", "") + player_in_bed = player_in_bed-1 + return + end + end + end +}) diff --git a/textures/beds_bed_side.png b/textures/beds_bed_side.png new file mode 100644 index 0000000000000000000000000000000000000000..c9e79e2aba80e916d9acab04fea5b673accedf4f GIT binary patch literal 536 zcmV+z0_XjSP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iylA z4JQIGVXZd+000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-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8|6X4Px#32;bRa{vGf6951U69E94oEQKA00(qQO+^RX2OkXyA4g!w!Tb+daKxMNO1uiMLOF1TqSz9J6h*uKtUr-8jNPSi@LW^R%s%xyc)IWB zy6^AxyPgKu2W-b2zG4Q?(8eTss%H_u(7+oMbTpaAAKb(xtYa2G(NE(7UZ%Ezf0)9w z!g7iSu!&Vnq_Kl;-ap_>hV8^2EGuloIh??Gv~VXMxA7RSa0-twh{!E$DpgYtKeF;X zu108xa}0O0$pnt#GCpcnjnmj$8qd7Vs5;eJH>!Kh3wmC_ZgWXf^^ zRLA*@lQDRIGEQ&3j$Z6q_La=)7igPh4RoG&?BGgB(%Hg3m@ z8QdGgSx{}dH8V{P2Vo5tQ(VK28qV{P{MR#6c!*t@(o4fQ&S?JYnJFBPIU8|!DMEFe d(frr{jsM@4eE>fvV>JK(002ovPDHLkV1n+;>ns2O literal 0 HcmV?d00001 diff --git a/textures/beds_bed_top_top.png b/textures/beds_bed_top_top.png new file mode 100644 index 0000000000000000000000000000000000000000..fc46ee198c1334a71802cb876976f24355a205e5 GIT binary patch literal 605 zcmV-j0;2tiP)Px#32;bRa{vGf6951U69E94oEQKA00(qQO+^RX2OkXyGj+J6ApigX8FWQhbVF}# zZDnqB07G(RVRU6=Aa`kWXdp*PO;A^X4i^9b0m?~4K~y-)mD0g)OkorS@Zb05O|>bi zREdewBB&-d(%9M9iH(h|zr7|+RT4R2$RjZetymR;FW${g;KRl)xSjL!0GnNAO1>8y3iJ|+f}K$& za|*PYEXQ|A)@jQ+ZSNBXT}H8iL4%_syh%s`qdk5H%A5?tcj?ONu4dY>mNQ*)y1@iq z1&W-h!10_cVJl@cBYBfQ+xX_Yy+AcQe_DKU91=9sP3Fis~#sa5%d`xIzaiKbP znswUd=UOHPd`UQ4(hrO!%obz=G*}6A6Rwr4C(NEaTul&#p9!en$TqwCYypV_DRUE>luIEZn) z#;GWL9^Eo^O`S_=<3}XMu^Df16@%#b7&p*WefB*rz%4` r>A&}!#HZ>5xE?3G5)=3q4Jz&rGK{nD#xDFT00000NkvXXu0mjfqc#b` literal 0 HcmV?d00001