Bug fixes and support for ts_doors
This commit is contained in:
parent
464d68e6d9
commit
a6318db989
|
@ -64,20 +64,17 @@ factions.register_command = function(cmd_name, cmd, ignore_param_count,or_perm)
|
|||
table.insert(args.factions, fac)
|
||||
end
|
||||
elseif argtype == "player" then
|
||||
local pl = minetest.get_player_by_name(arg)
|
||||
if not pl and not factions.players[arg] then
|
||||
send_error(player, "Player is not online.")
|
||||
return false
|
||||
else
|
||||
table.insert(args.players, pl)
|
||||
end
|
||||
local data = minetest.get_auth_handler().get_auth(arg)
|
||||
if data then
|
||||
table.insert(args.players, arg)
|
||||
else
|
||||
send_error(player, "Player does not exist.")
|
||||
return false
|
||||
end
|
||||
elseif argtype == "string" then
|
||||
table.insert(args.strings, arg)
|
||||
else
|
||||
table.insert(args.unknowns, arg)
|
||||
--minetest.log("error", "Bad format definition for function "..self.name)
|
||||
--send_error(player, "Internal server error")
|
||||
--return false
|
||||
end
|
||||
end
|
||||
for i=2, #argv do
|
||||
|
@ -219,10 +216,10 @@ factions.register_command ("claim", {
|
|||
return true
|
||||
else
|
||||
local parcel_faction = factions.get_parcel_faction(p)
|
||||
if parcel_faction and parcel_name == faction.name then
|
||||
if parcel_faction and parcel_faction.name == faction.name then
|
||||
send_error(player, "This parcel already belongs to your faction")
|
||||
return false
|
||||
elseif parcel_faction and parcel_name ~= faction.name then
|
||||
elseif parcel_faction and parcel_faction.name ~= faction.name then
|
||||
send_error(player, "This parcel belongs to another faction")
|
||||
return false
|
||||
elseif faction.power <= factions_config.power_per_parcel then
|
||||
|
@ -246,7 +243,7 @@ factions.register_command("unclaim", {
|
|||
send_error(player, "This parcel does not exist.")
|
||||
return false
|
||||
end
|
||||
if parcel_name ~= name then
|
||||
if parcel_faction.name ~= faction.name then
|
||||
send_error(player, "This parcel does not belong to you.")
|
||||
return false
|
||||
else
|
||||
|
@ -316,8 +313,7 @@ factions.register_command("kick", {
|
|||
description = "Kick a player from your faction",
|
||||
global_privileges = def_global_privileges,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
local victim = args.players[1]
|
||||
local name = victim:get_player_name()
|
||||
local name = args.players[1]
|
||||
|
||||
local victim_faction, facname = factions.get_player_faction(name)
|
||||
|
||||
|
@ -458,7 +454,11 @@ factions.register_command("invite", {
|
|||
global_privileges = def_global_privileges,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
if args.players and args.players[1] then
|
||||
factions.invite_player(faction.name, args.players[1]:get_player_name())
|
||||
if player == args.players[1] then
|
||||
send_error(player, "You can not invite yourself.")
|
||||
return
|
||||
end
|
||||
factions.invite_player(faction.name, args.players[1])
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
@ -470,7 +470,7 @@ factions.register_command("uninvite", {
|
|||
description = "Revoke a player's invite.",
|
||||
global_privileges = def_global_privileges,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
factions.revoke_invite(faction.name, args.players[1]:get_player_name())
|
||||
factions.revoke_invite(faction.name, args.players[1])
|
||||
return true
|
||||
end
|
||||
},false)
|
||||
|
@ -1126,37 +1126,17 @@ factions.register_command("del_spawn", {
|
|||
},false)
|
||||
|
||||
if factions_config.spawn_teleport == true then
|
||||
|
||||
local tip = {}
|
||||
|
||||
factions.register_command("tp_spawn", {
|
||||
description = "Teleport to the faction's spawn",
|
||||
global_privileges = def_global_privileges,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
if player then
|
||||
if tip[player] then
|
||||
minetest.chat_send_player(player, "Your already being teleported!")
|
||||
return false
|
||||
end
|
||||
minetest.chat_send_player(player, "Teleporting in five seconds.")
|
||||
minetest.after(5,
|
||||
function(faction, player)
|
||||
factions.tp_spawn(faction.name, player)
|
||||
tip[player] = nil
|
||||
end, faction, player)
|
||||
tip[player] = true
|
||||
return true
|
||||
factions.tp_spawn(faction.name, player)
|
||||
end
|
||||
return false
|
||||
end
|
||||
},false)
|
||||
|
||||
minetest.register_on_leaveplayer(
|
||||
function(player)
|
||||
local name = player:get_player_name()
|
||||
tip[name] = nil
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
factions.register_command("where", {
|
||||
|
@ -1204,8 +1184,7 @@ factions.register_command("promote", {
|
|||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
local rank = args.strings[1]
|
||||
if faction.ranks[rank] then
|
||||
local player_to_promote = args.players[1]
|
||||
local name = player_to_promote:get_player_name()
|
||||
local name = args.players[1]
|
||||
|
||||
local player_faction, facname = factions.get_player_faction(name)
|
||||
|
||||
|
@ -1307,7 +1286,7 @@ factions.register_command("set_leader", {
|
|||
global_privileges = {"faction_admin"},
|
||||
format = {"faction", "player"},
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
local playername = args.players[1]:get_player_name()
|
||||
local playername = args.players[1]
|
||||
local playerfaction, facname = factions.get_player_faction(playername)
|
||||
local targetfaction = args.factions[1]
|
||||
if playername ~= targetname then
|
||||
|
@ -1426,10 +1405,10 @@ factions.register_command("stats", {
|
|||
local f = args.factions[1]
|
||||
local pps = 0
|
||||
if factions_config.enable_power_per_player then
|
||||
if factions.onlineplayers[faction.name] == nil then
|
||||
factions.onlineplayers[faction.name] = {}
|
||||
if factions.onlineplayers[f.name] == nil then
|
||||
factions.onlineplayers[f.name] = {}
|
||||
end
|
||||
local t = factions.onlineplayers[faction.name]
|
||||
local t = factions.onlineplayers[f.name]
|
||||
local count = 0
|
||||
for _ in pairs(t) do count = count + 1 end
|
||||
pps = factions_config.power_per_player * count
|
||||
|
@ -1478,7 +1457,7 @@ factions_chat.cmdhandler = function (playername,parameter)
|
|||
if parameter == nil or
|
||||
parameter == "" then
|
||||
if player_faction then
|
||||
minetest.chat_send_player(playername, "You are in faction "..player_name..". Type /f help for a list of commands.")
|
||||
minetest.chat_send_player(playername, "You are in faction " .. player_faction.name .. ". Type /f help for a list of commands.")
|
||||
else
|
||||
minetest.chat_send_player(playername, "You are part of no faction")
|
||||
end
|
||||
|
|
|
@ -2,3 +2,4 @@ default?
|
|||
doors?
|
||||
xdecor?
|
||||
colddb
|
||||
ts_doors?
|
||||
|
|
31
factions.lua
31
factions.lua
|
@ -346,10 +346,12 @@ function factions.add_player(name, player, rank)
|
|||
factions.players.set(player, name)
|
||||
faction.invited_players[player] = nil
|
||||
local pdata = minetest.get_player_by_name(player)
|
||||
local ipc = pdata:is_player_connected(player)
|
||||
if ipc then
|
||||
createHudFactionName(pdata, name)
|
||||
createHudPower(pdata, faction)
|
||||
if pdata then
|
||||
local ipc = pdata:is_player_connected(player)
|
||||
if ipc then
|
||||
createHudFactionName(pdata, name)
|
||||
createHudPower(pdata, faction)
|
||||
end
|
||||
end
|
||||
|
||||
factions.factions.set(name, faction)
|
||||
|
@ -395,11 +397,13 @@ function factions.remove_player(name, player)
|
|||
end
|
||||
|
||||
local pdata = minetest.get_player_by_name(player)
|
||||
local ipc = pdata:is_player_connected(player)
|
||||
|
||||
if ipc then
|
||||
removeHud(pdata,"factionName")
|
||||
removeHud(pdata,"powerWatch")
|
||||
if pdata then
|
||||
local ipc = pdata:is_player_connected(player)
|
||||
|
||||
if ipc then
|
||||
removeHud(pdata,"factionName")
|
||||
removeHud(pdata,"powerWatch")
|
||||
end
|
||||
end
|
||||
|
||||
factions.check_players_in_faction(name)
|
||||
|
@ -718,6 +722,7 @@ function factions.tp_spawn(name, playername)
|
|||
|
||||
if player then
|
||||
player:set_pos(faction.spawn)
|
||||
minetest.sound_play("whoosh", {pos = faction.spawn, gain = 0.5, max_hear_distance = 10})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1205,6 +1210,10 @@ minetest.register_on_leaveplayer(
|
|||
if hud_ids[id_name3] then
|
||||
hud_ids[id_name3] = nil
|
||||
end
|
||||
for k, v in pairs(factions.onlineplayers[facname]) do
|
||||
return
|
||||
end
|
||||
factions.onlineplayers[facname] = nil
|
||||
end
|
||||
end
|
||||
)
|
||||
|
@ -1242,13 +1251,13 @@ minetest.is_protected = function(pos, player)
|
|||
if not parcel_faction then
|
||||
return default_is_protected(pos, player)
|
||||
elseif player_faction then
|
||||
if parcel_name == player_name then
|
||||
if parcel_faction.name == player_faction.name then
|
||||
if factions.has_permission(parcel_fac_name, player, "pain_build") then
|
||||
local p = minetest.get_player_by_name(player)
|
||||
p:set_hp(p:get_hp() - 0.5)
|
||||
end
|
||||
return not (factions.has_permission(parcel_fac_name, player, "build") or factions.has_permission(parcel_fac_name, player, "pain_build"))
|
||||
elseif parcel_allies[player_name] then
|
||||
elseif parcel_faction.allies[player_faction.name] then
|
||||
if factions.has_permission(player_fac_name, player, "pain_build") then
|
||||
local p = minetest.get_player_by_name(player)
|
||||
p:set_hp(p:get_hp() - 0.5)
|
||||
|
|
43
nodes.lua
43
nodes.lua
|
@ -82,11 +82,41 @@ if minetest.registered_nodes["default:chest"] then
|
|||
on_rightclick = on_rightclick})
|
||||
end
|
||||
|
||||
local door_items = {"doors:door_wood", "doors:door_steel", "doors:door_glass", "doors:door_obsidian_glass", "doors:woodglass_door", "doors:slide_door",
|
||||
"doors:screen_door", "doors:rusty_prison_door", "doors:prison_door", "doors:japanese_door", "ts_doors:door_default_aspen_wood", "ts_doors:door_full_default_aspen_wood",
|
||||
"ts_doors:door_default_pine_wood", "ts_doors:door_full_default_pine_wood", "ts_doors:door_default_acacia_wood", "ts_doors:door_full_default_acacia_wood",
|
||||
"ts_doors:door_default_wood", "ts_doors:door_full_default_wood", "ts_doors:door_default_junglewood", "ts_doors:door_full_default_junglewood",
|
||||
"ts_doors:door_default_bronzeblock", "ts_doors:door_full_default_bronzeblock", "ts_doors:door_default_copperblock", "ts_doors:door_full_default_copperblock",
|
||||
"ts_doors:door_default_diamondblock", "ts_doors:door_full_default_diamondblock", "ts_doors:door_full_default_goldblock", "ts_doors:door_default_steelblock", "ts_doors:door_full_default_steelblock"}
|
||||
|
||||
local trapdoor_items = {"doors:trapdoor", "doors:trapdoor_steel", "ts_doors:trapdoor_default_aspen_wood", "ts_doors:trapdoor_full_default_aspen_wood",
|
||||
"ts_doors:trapdoor_default_wood", "ts_doors:trapdoor_full_default_wood", "ts_doors:trapdoor_default_acacia_wood", "ts_doors:trapdoor_full_default_acacia_wood",
|
||||
"ts_doors:trapdoor_default_bronzeblock", "ts_doors:trapdoor_full_default_bronzeblock", "ts_doors:trapdoor_default_copperblock", "ts_doors:trapdoor_full_default_copperblock", "ts_doors:trapdoor_full_default_diamondblock",
|
||||
"ts_doors:door_default_goldblock", "ts_doors:trapdoor_default_steelblock", "ts_doors:trapdoor_full_default_steelblock", "ts_doors:trapdoor_default_pine_wood", "ts_doors:trapdoor_full_default_pine_wood",
|
||||
"ts_doors:trapdoor_full_default_goldblock", "ts_doors:trapdoor_default_junglewood", "ts_doors:trapdoor_full_default_junglewood",
|
||||
"ts_doors:trapdoor_default_diamondblock", "ts_doors:trapdoor_default_goldblock"}
|
||||
|
||||
-- Edit default doors and trapdoors to make them require the door permission.
|
||||
local doors = {"doors:door_wood_a", "doors:door_wood_b", "doors:door_steel_a", "doors:door_steel_b", "doors:door_glass_a", "doors:door_glass_b",
|
||||
"doors:door_obsidian_glass_a", "doors:door_obsidian_glass_b", "doors:trapdoor", "doors:trapdoor_open", "doors:trapdoor_steel", "doors:trapdoor_steel_open",
|
||||
"doors:woodglass_door_a", "doors:woodglass_door_b", "doors:slide_door_a", "doors:slide_door_b", "doors:screen_door_a", "doors:screen_door_b", "doors:rusty_prison_door_a",
|
||||
"doors:rusty_prison_door_b", "doors:prison_door_a", "doors:prison_door_b", "doors:japanese_door_a", "doors:japanese_door_b"}
|
||||
local doors = {}
|
||||
|
||||
local all_items = {}
|
||||
|
||||
local item_count = 1
|
||||
|
||||
for i, l in ipairs(door_items) do
|
||||
doors[item_count] = l .. "_a"
|
||||
doors[item_count + 1] = l .. "_b"
|
||||
all_items[item_count] = l
|
||||
item_count = item_count + 2
|
||||
end
|
||||
|
||||
for i, l in ipairs(trapdoor_items) do
|
||||
doors[item_count] = l
|
||||
doors[item_count + 1] = l .. "_open"
|
||||
all_items[item_count] = l
|
||||
item_count = item_count + 2
|
||||
end
|
||||
|
||||
for i, l in ipairs(doors) do
|
||||
local dw = minetest.registered_nodes[l]
|
||||
if dw then
|
||||
|
@ -122,10 +152,7 @@ for i, l in ipairs(doors) do
|
|||
end
|
||||
end
|
||||
|
||||
local door_items = {"doors:door_wood", "doors:door_steel", "doors:door_glass", "doors:door_obsidian_glass", "doors:trapdoor", "doors:trapdoor_steel", "doors:woodglass_door", "doors:slide_door",
|
||||
"doors:screen_door", "doors:rusty_prison_door", "doors:prison_door", "doors:japanese_door"}
|
||||
|
||||
for i, l in ipairs(door_items) do
|
||||
for i, l in ipairs(all_items) do
|
||||
local it = minetest.registered_items[l]
|
||||
if it then
|
||||
local def_on_place = it.on_place
|
||||
|
|
Loading…
Reference in New Issue
Block a user