Compare commits

...

5 Commits

Author SHA1 Message Date
Tre 7d4aae67b6 make the chat comands return a message 2017-07-14 07:06:06 -05:00
Tre a937770b46 make sia members much more secure so you can have secret agents 2017-07-13 15:05:30 -05:00
Tre 53a3d24dfb fix bug in the chest textures 2017-07-13 15:00:48 -05:00
Tre 5c2cd8c47d change the textures of the sia chest 2017-07-13 07:58:26 -05:00
Tre 717422eaf8 change the textures of the sia chest 2017-07-13 07:57:18 -05:00
5 changed files with 78 additions and 13 deletions

10
api.lua
View File

@ -52,6 +52,7 @@ sia_chest.formspec = function(pos,page)
.."button[13,6.5;2,0.5;delete;Delete]"
.."list[current_name;"..page..";0,1;15,5;]"
.."list[current_player;main;0,7;8,4;]"
.."listring[]"
end
sia_chest.get_pages = function(meta)
@ -141,6 +142,9 @@ sia_chest.can_dig = function(pos,player)
return false
end
end
if sia.is_member(player:get_player_name())==false then
return false
end
return true
end
@ -179,10 +183,10 @@ end
sia_chest.has_locked_chest_privilege = function(meta, player)
local name = player:get_player_name()
if minetest.check_player_privs(player, "SIA_member") then
return false
if sia.is_member(player:get_player_name()) then
return true
end
return true
return false
end
sia_chest.on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)

View File

@ -1,6 +1,73 @@
local sia = {}
sia = {}
screwdriver = screwdriver or {}
minetest.register_privilege("SIA_admin", {
description = "Is a member of the Server Intelegence Agency",
give_to_singleplayer = false
})
local mod_storage = minetest.get_mod_storage()
function sia.is_member(name)
local str = mod_storage:get_string("SIA_members")
for x in string.gmatch(str, '([^,]+)') do
if x==name then
return true
end
end
return false
end
minetest.register_chatcommand("listmembers", {
description = "Lists the Sia members",
privs = {SIA_admin = true},
func = function(name, param)
local str = mod_storage:get_string("SIA_members")
for x in string.gmatch(str, '([^,]+)') do
minetest.chat_send_player(name,x)
end
end
})
minetest.register_chatcommand("addmember", {
description = "Adds player to the SIA member list",
params = "<player>",
privs = {SIA_admin = true},
func = function(name, param)
if mod_storage:get_string("SIA_members")=="" then
mod_storage:set_string("SIA_members",param)
else
if not sia.is_member(param) then
mod_storage:set_string("SIA_members",mod_storage:get_string("SIA_members")..","..param)
minetest.chat_send_player(name,param.." was added succesefully")
else
minetest.chat_send_player(name,param.." is already a member")
end
end
end
})
minetest.register_chatcommand("removemember", {
description = "Removes player from the SIA member list",
params = "<player>",
privs = {SIA_admin = true},
func = function(name, param)
local str = mod_storage:get_string("SIA_members")
local nstr = ""
for x in string.gmatch(str, '([^,]+)') do
if x==param then
else
if nstr == "" then
nstr = nstr..x
else
nstr = nstr..","..x
end
end
end
mod_storage:set_string("SIA_members",nstr)
minetest.chat_send_player(name,param.." was removed succesefully")
end
})
local cbox = {
type = "fixed",
fixed = { -6/16, -8/16, -8/16, 6/16, 3/16, 8/16 }
@ -8,10 +75,6 @@ local cbox = {
dofile(minetest.get_modpath("sia").."/api.lua")
minetest.register_privilege("SIA_member", {
description = "Is a member of the Server Intelegence Agency",
give_to_singleplayer = false
})
minetest.register_alias("SIA_Mailbox","sia:mailbox")
@ -41,9 +104,7 @@ minetest.register_node("sia:mailbox", {
on_rightclick = function(pos, node, clicker, itemstack)
local meta = minetest.get_meta(pos)
local player = clicker:get_player_name()
if minetest.check_player_privs(player, "SIA_member") or
minetest.check_player_privs(player, "protection_bypass") and
clicker:get_player_control().aux1 then
if sia.is_member(player) then
minetest.show_formspec(
clicker:get_player_name(),
"default:chest_locked",
@ -60,7 +121,7 @@ minetest.register_node("sia:mailbox", {
local meta = minetest.get_meta(pos);
local name = player and player:get_player_name()
local inv = meta:get_inventory()
return minetest.check_player_privs(player, "SIA_member") and inv:is_empty("main")
return sia.is_member(player:get_player_name()) and inv:is_empty("main")
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
@ -89,7 +150,7 @@ minetest.register_node("sia:mailbox", {
minetest.register_node("sia:chest", {
description = "SIA Chest",
tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png", "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"},
tiles = {"sia_chest_top.png", "sia_chest_top.png", "sia_chest_side.png", "sia_chest_side.png", "sia_chest_side.png", "sia_chest_lock.png"},
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
legacy_facedir_simple = true,

BIN
textures/sia_chest_lock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 B

BIN
textures/sia_chest_side.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 559 B

BIN
textures/sia_chest_top.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 695 B