forked from mtcontrib/factions
Merge branch 'master' into nalc-1.2
This commit is contained in:
commit
b2c32cc84f
@ -109,7 +109,7 @@ factions.register_command = function(cmd_name, cmd, ignore_param_count, or_perm,
|
||||
end
|
||||
|
||||
-- get some more data
|
||||
local pos = minetest.get_player_by_name(player):getpos()
|
||||
local pos = minetest.get_player_by_name(player):get_pos()
|
||||
local parcelpos = factions.get_parcel_pos(pos)
|
||||
return self.on_success(player, player_faction, pos, parcelpos, args)
|
||||
end,
|
||||
@ -942,19 +942,9 @@ factions.register_command("who", {
|
||||
|
||||
if str then
|
||||
local f = factions.get_faction(str)
|
||||
|
||||
if not f and not f.players then
|
||||
f = factions.get_player_faction(player)
|
||||
if not f or not f.players then
|
||||
minetest.chat_send_player(player, "Your not in a faction.")
|
||||
return
|
||||
else
|
||||
minetest.chat_send_player(player, "Players in faction " .. f.name .. ": ")
|
||||
for p, rank in pairs(f.players) do
|
||||
minetest.chat_send_player(player, p .." (" .. rank .. ")")
|
||||
end
|
||||
return true
|
||||
end
|
||||
if not f or not f.players then
|
||||
minetest.chat_send_player(player, "Faction " .. str .. " does not exist.")
|
||||
return
|
||||
else
|
||||
minetest.chat_send_player(player, "Players in faction " .. f.name .. ": ")
|
||||
for p, rank in pairs(f.players) do
|
||||
|
32
config.lua
32
config.lua
@ -1,8 +1,5 @@
|
||||
factions_config = {}
|
||||
-- If you want to hardcode the config settings just delete settingstypes.txt, and the line up to END. And then uncomment the hardcoded settings below and change it to whatever you want.
|
||||
-- settingstypes
|
||||
local flip = tonumber(minetest.settings:get("protection_max_depth")) or 512
|
||||
factions_config.protection_max_depth = -flip
|
||||
factions_config.protection_max_depth = tonumber(minetest.settings:get("protection_max_depth")) or -512
|
||||
factions_config.protection_max_height = tonumber(minetest.settings:get("protection_max_height")) or 10000
|
||||
factions_config.power_per_parcel = tonumber(minetest.settings:get("power_per_parcel")) or 1
|
||||
factions_config.power_per_death = tonumber(minetest.settings:get("power_per_death")) or 1
|
||||
@ -25,30 +22,3 @@ factions_config.faction_diplomacy = minetest.settings:get_bool("faction_diplomac
|
||||
factions_config.spawn_teleport = minetest.settings:get_bool("spawn_teleport") or false
|
||||
factions_config.protection_style = minetest.settings:get("protection_style") or "2d"
|
||||
factions_config.faction_user_priv = minetest.settings:get("faction_user_priv") or false
|
||||
-- END
|
||||
--[[
|
||||
-- hardcoded config settings
|
||||
factions_config.protection_max_depth = -512
|
||||
factions_config.protection_max_height = 10000
|
||||
factions_config.power_per_parcel = 1
|
||||
factions_config.power_per_death = 1
|
||||
factions_config.power_per_tick = 2
|
||||
factions_config.tick_time = 60
|
||||
factions_config.power_per_attack = 10
|
||||
factions_config.faction_name_max_length = 50
|
||||
factions_config.rank_name_max_length = 25
|
||||
factions_config.maximum_faction_inactivity = 604800
|
||||
factions_config.maximum_parcelless_faction_time = 10800
|
||||
factions_config.power = 12
|
||||
factions_config.maxpower = 0
|
||||
factions_config.power_per_player = 1
|
||||
factions_config.powermax_per_player = 12
|
||||
factions_config.parcel_size = 16
|
||||
factions_config.protection_depth_height_limit = true
|
||||
factions_config.enable_power_per_player = true
|
||||
factions_config.attack_parcel = false
|
||||
factions_config.faction_diplomacy = true
|
||||
factions_config.spawn_teleport = false
|
||||
factions_config.protection_style = "2d"
|
||||
factions_config.faction_user_priv = false
|
||||
--]]
|
@ -1,5 +0,0 @@
|
||||
default?
|
||||
doors?
|
||||
xdecor?
|
||||
colddb
|
||||
ts_doors?
|
@ -1 +0,0 @@
|
||||
Mod for handling in game factions and reputation.
|
@ -466,10 +466,10 @@ function factions.is_online(name)
|
||||
end
|
||||
|
||||
function factions.get_parcel_pos(pos)
|
||||
if factions_config.protection_style == "2d" then
|
||||
return math.floor(pos.x / parcel_size) * parcel_size .. "," .. math.floor(pos.z / parcel_size) * parcel_size
|
||||
elseif factions_config.protection_style == "3d" then
|
||||
if factions_config.protection_style == "3d" then
|
||||
return math.floor(pos.x / parcel_size) * parcel_size .. "," .. math.floor(pos.y / parcel_size) * parcel_size .. "," .. math.floor(pos.z / parcel_size) * parcel_size
|
||||
else
|
||||
return math.floor(pos.x / parcel_size) * parcel_size .. "," .. math.floor(pos.z / parcel_size) * parcel_size
|
||||
end
|
||||
end
|
||||
|
||||
@ -489,7 +489,7 @@ end
|
||||
function factions.get_faction_at(pos)
|
||||
local y = pos.y
|
||||
if factions_config.protection_depth_height_limit and (pos.y < factions_config.protection_max_depth or pos.y > factions_config.protection_max_height) then
|
||||
return nil
|
||||
return nil
|
||||
end
|
||||
local parcelpos = factions.get_parcel_pos(pos)
|
||||
return factions.get_parcel_faction(parcelpos)
|
||||
|
4
hud.lua
4
hud.lua
@ -112,7 +112,7 @@ function hudUpdateClaimInfo()
|
||||
for i in pairs(playerslist) do
|
||||
local player = playerslist[i]
|
||||
local name = player:get_player_name()
|
||||
local faction, facname = factions.get_faction_at(player:getpos())
|
||||
local faction, facname = factions.get_faction_at(player:get_pos())
|
||||
local id_name = name .. "factionLand"
|
||||
|
||||
if hud_ids[id_name] then
|
||||
@ -124,4 +124,4 @@ function hudUpdateClaimInfo()
|
||||
end
|
||||
end
|
||||
minetest.after(3, hudUpdateClaimInfo)
|
||||
end
|
||||
end
|
||||
|
3
mod.conf
3
mod.conf
@ -1 +1,4 @@
|
||||
name = factions
|
||||
description = Mod for handling in game factions and reputation.
|
||||
depends = colddb
|
||||
optional_depends = default, doors, xdecor, ts_doors
|
||||
|
69
nodes.lua
69
nodes.lua
@ -30,6 +30,7 @@ if minetest.registered_nodes["default:chest"] then
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
local dc = minetest.registered_nodes["default:chest"]
|
||||
local def_on_rightclick = dc.on_rightclick
|
||||
|
||||
@ -43,37 +44,77 @@ if minetest.registered_nodes["default:chest"] then
|
||||
name .. ")")
|
||||
end
|
||||
end
|
||||
|
||||
local can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main") and
|
||||
factions.can_use_node(pos, player:get_player_name(), "container")
|
||||
end
|
||||
local allow_metadata_inventory_move = function(pos, from_list, from_index,
|
||||
to_list, to_index, count, player)
|
||||
if not factions.can_use_node(pos, player:get_player_name(), "container") then
|
||||
return 0
|
||||
|
||||
local allow_metadata_inventory_move
|
||||
local def_allow_metadata_inventory_move = dc.allow_metadata_inventory_move
|
||||
if def_allow_metadata_inventory_move then
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index,
|
||||
to_list, to_index, count, player)
|
||||
if not factions.can_use_node(pos, player:get_player_name(), "container") then
|
||||
return 0
|
||||
end
|
||||
return def_allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
end
|
||||
return count
|
||||
end
|
||||
local allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if not factions.can_use_node(pos, player:get_player_name(), "container") then
|
||||
return 0
|
||||
else
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index,
|
||||
to_list, to_index, count, player)
|
||||
if not factions.can_use_node(pos, player:get_player_name(), "container") then
|
||||
return 0
|
||||
end
|
||||
return count
|
||||
end
|
||||
return stack:get_count()
|
||||
end
|
||||
local allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
if not factions.can_use_node(pos, player:get_player_name(), "container") then
|
||||
return 0
|
||||
|
||||
local allow_metadata_inventory_put
|
||||
local def_allow_metadata_inventory_put = dc.allow_metadata_inventory_put
|
||||
if def_allow_metadata_inventory_put then
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if not factions.can_use_node(pos, player:get_player_name(), "container") then
|
||||
return 0
|
||||
end
|
||||
return def_allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
end
|
||||
else
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if not factions.can_use_node(pos, player:get_player_name(), "container") then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
local allow_metadata_inventory_take
|
||||
local def_allow_metadata_inventory_take = dc.allow_metadata_inventory_take
|
||||
if def_allow_metadata_inventory_take then
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
if not factions.can_use_node(pos, player:get_player_name(), "container") then
|
||||
return 0
|
||||
end
|
||||
return def_allow_metadata_inventory_take(pos, listname, index, stack, player)
|
||||
end
|
||||
else
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
if not factions.can_use_node(pos, player:get_player_name(), "container") then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end
|
||||
end
|
||||
|
||||
local on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
if not factions.can_use_node(pos, clicker:get_player_name(), "container") then
|
||||
return itemstack
|
||||
end
|
||||
return def_on_rightclick(pos, node, clicker, itemstack, pointed_thing)
|
||||
end
|
||||
|
||||
minetest.override_item("default:chest", {after_place_node = after_place_node,
|
||||
can_dig = can_dig,
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
|
@ -37,8 +37,8 @@ parcel_size (parcel-size) float 16
|
||||
|
||||
# Enable or disabled power-per-player.
|
||||
power_per_playerb (Enable power-per-player) bool true
|
||||
# Enable or disabled factions_config.attack_parcel function.
|
||||
factions_config.attack_parcel (Enable attack parcel) bool false
|
||||
# Enable or disabled attack_parcel function.
|
||||
attack_parcel (Enable attack parcel) bool false
|
||||
# Enable or disabled faction diplomacy.
|
||||
faction_diplomacy (Enable faction diplomacy) bool true
|
||||
# Enable or disabled the max depth and height limit for a parcel
|
||||
|
Loading…
Reference in New Issue
Block a user