From a65f5b1564f8ed363e32393a289bd3a38f3d7dc8 Mon Sep 17 00:00:00 2001 From: PilzAdam Date: Sat, 18 May 2013 16:06:57 +0200 Subject: [PATCH] Add bones mod --- mods/bones/README.txt | 17 ++++ mods/bones/depends.txt | 1 + mods/bones/init.lua | 130 +++++++++++++++++++++++++++ mods/bones/textures/bones_bottom.png | Bin 0 -> 382 bytes mods/bones/textures/bones_front.png | Bin 0 -> 441 bytes mods/bones/textures/bones_rear.png | Bin 0 -> 437 bytes mods/bones/textures/bones_side.png | Bin 0 -> 412 bytes mods/bones/textures/bones_top.png | Bin 0 -> 410 bytes 8 files changed, 148 insertions(+) create mode 100644 mods/bones/README.txt create mode 100644 mods/bones/depends.txt create mode 100644 mods/bones/init.lua create mode 100644 mods/bones/textures/bones_bottom.png create mode 100644 mods/bones/textures/bones_front.png create mode 100644 mods/bones/textures/bones_rear.png create mode 100644 mods/bones/textures/bones_side.png create mode 100644 mods/bones/textures/bones_top.png diff --git a/mods/bones/README.txt b/mods/bones/README.txt new file mode 100644 index 00000000..b0ebed8f --- /dev/null +++ b/mods/bones/README.txt @@ -0,0 +1,17 @@ +Minetest 0.4 mod: bones +======================= + +License of source code: +----------------------- +Copyright (C) 2012 PilzAdam + +WTFPL + +License of media (textures and sounds) +-------------------------------------- +Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) +http://creativecommons.org/licenses/by-sa/3.0/ + +Authors of media files +---------------------- +Bad_Command_ diff --git a/mods/bones/depends.txt b/mods/bones/depends.txt new file mode 100644 index 00000000..4ad96d51 --- /dev/null +++ b/mods/bones/depends.txt @@ -0,0 +1 @@ +default diff --git a/mods/bones/init.lua b/mods/bones/init.lua new file mode 100644 index 00000000..3da5f147 --- /dev/null +++ b/mods/bones/init.lua @@ -0,0 +1,130 @@ +-- Minetest 0.4 mod: bones +-- See README.txt for licensing and other information. + +local function is_owner(pos, name) + local owner = minetest.env:get_meta(pos):get_string("owner") + if owner == "" or owner == name then + return true + end + return false +end + +minetest.register_node("bones:bones", { + description = "Bones", + tiles = { + "bones_top.png", + "bones_bottom.png", + "bones_side.png", + "bones_side.png", + "bones_rear.png", + "bones_front.png" + }, + paramtype2 = "facedir", + groups = {dig_immediate=2}, + sounds = default.node_sound_dirt_defaults({ + footstep = {name="default_gravel_footstep", gain=0.45}, + }), + + can_dig = function(pos, player) + local inv = minetest.env:get_meta(pos):get_inventory() + return is_owner(pos, player:get_player_name()) and inv:is_empty("main") + end, + + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + if is_owner(pos, player:get_player_name()) then + return count + end + return 0 + end, + + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + return 0 + end, + + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + if is_owner(pos, player:get_player_name()) then + return stack:get_count() + end + return 0 + end, + + on_metadata_inventory_take = function(pos, listname, index, stack, player) + local meta = minetest.env:get_meta(pos) + if meta:get_string("owner") ~= "" and meta:get_inventory():is_empty("main") then + meta:set_string("infotext", meta:get_string("owner").."'s old bones") + meta:set_string("formspec", "") + meta:set_string("owner", "") + end + end, + + on_timer = function(pos, elapsed) + local meta = minetest.env:get_meta(pos) + local time = meta:get_int("time")+elapsed + local publish = 1200 + if tonumber(minetest.setting_get("share_bones_time")) then + publish = tonumber(minetest.setting_get("share_bones_time")) + end + if publish == 0 then + return + end + if time >= publish then + meta:set_string("infotext", meta:get_string("owner").."'s old bones") + meta:set_string("owner", "") + else + return true + end + end, +}) + +minetest.register_on_dieplayer(function(player) + if minetest.setting_getbool("creative_mode") then + return + end + + local pos = player:getpos() + pos.x = math.floor(pos.x+0.5) + pos.y = math.floor(pos.y+0.5) + pos.z = math.floor(pos.z+0.5) + local param2 = minetest.dir_to_facedir(player:get_look_dir()) + + local nn = minetest.env:get_node(pos).name + if minetest.registered_nodes[nn].can_dig and + not minetest.registered_nodes[nn].can_dig(pos, player) then + local player_inv = player:get_inventory() + + for i=1,player_inv:get_size("main") do + player_inv:set_stack("main", i, nil) + end + for i=1,player_inv:get_size("craft") do + player_inv:set_stack("craft", i, nil) + end + return + end + + minetest.env:dig_node(pos) + minetest.env:add_node(pos, {name="bones:bones", param2=param2}) + + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + local player_inv = player:get_inventory() + inv:set_size("main", 8*4) + + local empty_list = inv:get_list("main") + inv:set_list("main", player_inv:get_list("main")) + player_inv:set_list("main", empty_list) + + for i=1,player_inv:get_size("craft") do + inv:add_item("main", player_inv:get_stack("craft", i)) + player_inv:set_stack("craft", i, nil) + end + + meta:set_string("formspec", "size[8,9;]".. + "list[current_name;main;0,0;8,4;]".. + "list[current_player;main;0,5;8,4;]") + meta:set_string("infotext", player:get_player_name().."'s fresh bones") + meta:set_string("owner", player:get_player_name()) + meta:set_int("time", 0) + + local timer = minetest.env:get_node_timer(pos) + timer:start(10) +end) diff --git a/mods/bones/textures/bones_bottom.png b/mods/bones/textures/bones_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..5ed45d6415bb3be2fd2d9646a1ff29fd5f1d43d8 GIT binary patch literal 382 zcmV-^0fGLBP)Px#32;bRa{vGi!~g&e!~vBn4jTXf00(qQO+^RX1{@X+IpvBGHvj+u5J^NqR4C7l zQn8VQFbrJiLo*KC0-*xRaOl(pP=pI`N~kgjXoJ8rZsddYX_yc0UjYaqtyU{RL;wIV zGgTFl=XuP`BdTg;1 z#@>63QB}tnAp}(|rFb`p2&+khjOp{&FM12%TWbJ%@3mF{+qRL_925XhN=Yd#q{NKx z7GpHCNr@_vq0{5gZy5nBd|lV|XNP^?r^gO1xev{tFF{1iY*E$T`+qv*oTt9d)%X9F z*jX@V@$d6Ize_YFaUHymqsqtpF3oJ^rp#=N!R`3;A%qY@tu>_tAcW9bn<9`s&)C8I c_}=6F0CUB*)31>O1^@s607*qoM6N<$f_T50EdT%j literal 0 HcmV?d00001 diff --git a/mods/bones/textures/bones_front.png b/mods/bones/textures/bones_front.png new file mode 100644 index 0000000000000000000000000000000000000000..60f6dd9242c148ade9c341ad337bba238b32a9b5 GIT binary patch literal 441 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|*pj^6U4S$Y z{B+)352QE?JR*x382FBWFymBhK53vJdx@v7EBhTb88HquyBoWKIv6cIT^vI+&bJ0> zPdaSC6T0cCZR0Vfr>?C`wrz+)dF8&i z^@=UmUmrd5{Bz~)ZKbi!91Q$ta?&iHUyFKQ8#yiN_1m)IUzxLlyeyydJGeZnR9lo9 zDPWtBwbsz>hr03N|2ogttkPU6@%Y7sYqP@NytEZf)>+zf=FR7WdecuIe7W~=p5ZaZ z=fV@GTx$H`(0FR&cRi&SFQ!zl-ulnOEhTMB`1JbR_2S0Lt+NhRcY0*M{aN$RvVYaK zYc44cBKbe6&-|@p7jH>=Hktc*ZH(G{-K8y$XWis@=%u+swx|OLW=MWenpFHRr%g%c fdAHoY4Xf&yZJuq^sO&vC7Zm88u6{1-oD!M9RZ=oWPX+H zHng1UC#bl}Dr>(E_tV9FD(8MEc^$biS7$NjoJ#hFtPK;il{BuK_`bVW{rrj3rvLAy zpP%7-qiMNrRo}#?g3DJKiP=Sb-RpL@yyVo~%-~yZ-le6beYUx*Z@hZzzI$GK-5$@V cuSsOsZ(Z>6<&K}L?}Gx|)78&qol`;+03Fe|y#N3J literal 0 HcmV?d00001 diff --git a/mods/bones/textures/bones_side.png b/mods/bones/textures/bones_side.png new file mode 100644 index 0000000000000000000000000000000000000000..57dd18fb59db55427824c024896e59297dafb4a3 GIT binary patch literal 412 zcmV;N0b~A&P)Px#32;bRa{vGi!~g&e!~vBn4jTXf00(qQO+^RX1{@X*9&4@lp8x;>E=fc|R4C77 zQX!JVFbv%G-l4HTcwS)8XB39!0Ree}9}sHjhZqKy3V0^0uph{QP1Rgaz+*`(d9^Y` z1OR|iN{mrNVvMB}kI*G7#)udrZyw@>rskD>@B8cZ3L(t%{CqxZt$p8z5FU?* znE@DvVO`e{0*PGtG=OQEYOMfTYdL2}0~p5q?B;puDs1f^WB|U{9)|P&WLl(g+5MpyWLc^wWg}%rm8vTuIohPBbmL;*W?WS zUzSp?DJ7yg-@2|ofU2r$N{M=?>ar}yWd1jOajwDFU;YJjfaa9v#m#8|0000Px#32;bRa{vGi!~g&e!~vBn4jTXf00(qQO+^RX1{@X+GIChRzW@LMEJ;K`R4C7l zQoE6ZKn#8O3UCD)6p%Y2R6rSoPAP!EB~SpVLxq$;ux)I>3>hH}aKXcx8{f?N6zoSU zy{CN=L<9f;cQ-Q;F*A1$53dX}Gng4q;Sv!M$vNX?%xCh~aUA=;mu2~QJhp91Dcx?j zX_^2`({#OF_kG{Ctt?9>Ujm@-`;-!ZWm)*PuB)n=S=V*JR)~nIrj&lx@Y|}YIui&# zjw7*$VE|Cqbp-K~0J^Sg+qPgyjQHECs&aQw$54rD&N=5yx!zd2YFe{rMq9) zDR*DjmEDPoRaI4oVQAYHfU1t;c#6R4ImQ7-__ta92JQ*1=PPv5T>t<807*qoM6N<$ Ef`#3yU;qFB literal 0 HcmV?d00001 -- 2.25.1