From d1c4a3e40fc0b4d131390760e8d569bc1f13cd71 Mon Sep 17 00:00:00 2001 From: shamoanjac Date: Wed, 24 Aug 2016 15:32:08 +0200 Subject: [PATCH 1/2] Added faction chests --- nodes.lua | 70 ++++++++++++++++++++++++++++-- textures/factions_chest_front.png | Bin 720 -> 719 bytes 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/nodes.lua b/nodes.lua index 6cfa75e..872ae9f 100644 --- a/nodes.lua +++ b/nodes.lua @@ -1,7 +1,71 @@ +function factions.get_chest_formspec(pos) + local spos = pos.x..","..pos.y..","..pos.z + return "size[8,9]" .. + default.gui_bg .. + default.gui_bg_img .. + default.gui_slots .. + "list[nodemeta:"..spos..";main;0,0.3;8,4;]" .. + "list[current_player;main;0,4.85;8,1;]".. + "list[current_player;main;0,6.08;8,3;8]".. + "listring[nodemeta:"..spos..";main]".. + "listring[current_player;main]".. + default.get_hotbar_bg(0, 4.85) +end + +function factions.can_use_chest(pos, player) + if not player then + return false + end + local parcel_faction = factions.get_faction_at(pos) + local player_faction = factions.get_player_faction(player) + if not parcel_faction then + return true + end + return player_faction and (parcel_faction.name == player_faction.name) +end minetest.register_node("factions:chest", { - tiles = {"factions_chest_top", "factions_chest_top", - "factions_chest_side", "factions_chest_side", - "factions_chest_side", "factions_chest_front"}, + tiles = {"factions_chest_top.png", "factions_chest_top.png", + "factions_chest_side.png", "factions_chest_side.png", + "factions_chest_side.png", "factions_chest_front.png"}, + groups = {choppy = 2}, + description = "Faction chest", + paramtype2 = "facedir", + on_construct = function(pos) + minetest.get_meta(pos):get_inventory():set_size("main", 8*4) + end, + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + if factions.can_use_chest(pos, player:get_player_name()) then + return count + else + return 0 + end + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + if factions.can_use_chest(pos, player:get_player_name()) then + return stack:get_count() + else + return 0 + end + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + if factions.can_use_chest(pos, player:get_player_name()) then + return stack:get_count() + else + return 0 + end + end, + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + if factions.can_use_chest(pos, clicker:get_player_name()) then + minetest.show_formspec(clicker:get_player_name(), "factions:chest", factions.get_chest_formspec(pos)) + end + return itemstack + end +}) + +minetest.register_craft({ + output = "factions:chest", + type = "shapeless", + recipe = {"default:chest_locked", "default:steel_ingot"} }) diff --git a/textures/factions_chest_front.png b/textures/factions_chest_front.png index 16557195091a93c041bc7fb617100c4537b63b81..d3fe58c62e52f9057de6f66af1259833c90ad1eb 100644 GIT binary patch delta 611 zcmV-p0-XKO1WhQE>K;u$;B;Kng= z+dwy67qaLp^hNp%-S)Mz?6QkOA*7o^AWa}Ki7#>HCTS#fF%!Fsbkzd~1QNf_|DP{7 zIXUtCM}+`cal>#B@ghrjIZ8-E$?ZeMs#GXr@xJ@RI*)2Cjc&2tGnl^Z1ZLwAt$%e$ z5ddJUXEcZz4Ps&`2!eptIf`0iy{Bvp+B)u@CTMhvYAvNQtV%@|hkX3>nbXr#thG4j z*!=oV5=pW+WRj<(am3vMFUDrMNzn&H8W>2!)Q2Bj3QWI+;2O4YKi z6lG(04AO3b^D2WVgZ*7NRaJ3)eSgj2;UUZAk{^$0cOm-zJH+Q|KA!_{adELd|8ol; z#+r4dDQb;zo>&U3eT|e7r4-(K-tW~!p(F_<)_FFy=Df-}fzEr2aoxHWMZ-i0y!Q-; zLoP2bIa_ZS4Puf=5{Urk0nrOM5ATllxmlImK2$jGx&Qf%PzoyDGL?eyUVp|UPcgP* zp|uWdZ=qI(v#SNxc^YF8K|q#-C}T+@NuI_WALKNqWnI=3swEBuguTF%ZxIRdv>OxH z!d0o3tHmQh5TLEYIY*=2PGGW^vZ*!Rdy*(*JREFOmLi~NGyr)TZ%K_q!Pj{&@cVv) z?E@^8q0udQ+M)b}cWo@jDo{4H=Alv;>tJ-$2^=5f7;6EDr0meGHOrzwh|bo27Gtc( xl@4PawQhGDoLAZNlmvhWs=fh&1V+0je*jCXJlNQ=L8Sly002ovPDHLkV1iyf8Yut( delta 612 zcmV-q0-OEM1<(bMQwS6m7b$81`4f>_D1SIfL_t(I%cYXLP8=~5hCh35JF~k3+Het( zf|L{yWh9EcKprGjy1ZK|`n*9Tgs7lch+u)eu*}W&*iJD6n*ycDkxpgnv(JA%aeRF2 z`Hu<#vf_r}AYv;^cr!{!!hqYyie;%##^QbVhIJm*S{mJAy=Sohz5~3SjA*SRkbeRI zV?Com%xDl32NEF!t#cH$#(GcL7_@cVKmVZ7EvmJY%CIaISse1^>km#&F0t0*yhB}o zCy4^GIAk|ZN#lt7c@Nmi5@wGj%TnRJM+m|B`8`KR6Rv;Ptd<2I_HvZ5tSZg*q96$a z5R(pYR%H-nu)PVVC>_(Q1^fFW7Jm!Jucx#-kbVCh;%jwxH^cjci;D+lvng@>k1c$j zXjYY`s5QoU;y|KJj0{3lQ-e$RG_HxlfFumC&aare#&u6sjc-C4@cTd2Sg=^0fOV z@FG{GTCV0#2qDnc;hdwtv@_nssQnG6RnDF;$eG#Y?BjbBWSL&?us512lz zv3-E0GBmm+Pdk;L^{$P@SW(5g);v}UV;zhRI>6yhj0000 Date: Thu, 25 Aug 2016 18:31:02 +0200 Subject: [PATCH 2/2] Fixed /f invite --- chatcommands.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chatcommands.lua b/chatcommands.lua index d561805..a0406e7 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -63,7 +63,7 @@ factions.register_command = function(cmd_name, cmd) end elseif argtype == "player" then local pl = minetest.get_player_by_name(arg) - if not pl or not factions.players[arg] then + if not pl and not factions.players[arg] then send_error(player, "Player is not online.") return false else