Idle when no player has an active compass (#21)
This commit is contained in:
parent
43b803d82d
commit
78d60b3c70
@ -33,6 +33,7 @@ The mod support the next settings:
|
||||
ccompass_allow_damage_target: Disabled by default -> will not teleport player into or over damaging nodes.
|
||||
ccompass_stack_max: 1 by default. Sets maximum stack size, 1 to 65535
|
||||
ccompass_allow_using_stacks: Disabled by default -> calibrating and teleporting only works when single compass in hand. Setting to true, allows callibrating stacks to same location.
|
||||
ccompass_idle_interval: 1 by default. When no players have active compasses, the mod enters an idle state and only checks for compasses at this interval, measured in seconds. This setting is meant to reduce the load on the server.
|
||||
|
||||
## For developers:
|
||||
1. It is possible to change compass settings from other mods by changing values in global table ccompass. So it is possible for example to add a waypoint node to the target-nodes by
|
||||
@ -49,6 +50,7 @@ The mod support the next settings:
|
||||
ccompass.allow_damaging_target = true
|
||||
ccompass.allow_using_stacks = true
|
||||
ccompass.stack_max = 42
|
||||
ccompass.idle_interval = 0
|
||||
```
|
||||
Also you can override ccompass.is_safe_target(target, nodename) for more granular checks.
|
||||
By default first nodes_over_target_allow is checked, then nodes_over_target_deny
|
||||
|
12
init.lua
12
init.lua
@ -70,6 +70,8 @@ end
|
||||
ccompass.stack_max = tonumber(minetest.settings:get("ccompass_stack_max") or 1) or 1
|
||||
ccompass.allow_using_stacks = minetest.settings:get_bool("ccompass_allow_using_stacks")
|
||||
|
||||
ccompass.idle_interval = tonumber(minetest.settings:get("ccompass_idle_interval") or 1) or 1
|
||||
|
||||
if minetest.settings:get_bool("ccompass_aliasses") then
|
||||
minetest.register_alias("compass:0", "ccompass:0")
|
||||
minetest.register_alias("compass:1", "ccompass:1")
|
||||
@ -344,7 +346,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
end)
|
||||
|
||||
-- update inventory
|
||||
minetest.register_globalstep(function(dtime)
|
||||
local function do_update_loop()
|
||||
local found_compasses = false
|
||||
for i,player in ipairs(minetest.get_connected_players()) do
|
||||
if player:get_inventory() then
|
||||
for i,stack in ipairs(player:get_inventory():get_list("main")) do
|
||||
@ -352,12 +355,17 @@ minetest.register_globalstep(function(dtime)
|
||||
break
|
||||
end
|
||||
if string.sub(stack:get_name(), 0, 9) == "ccompass:" then
|
||||
found_compasses = true
|
||||
player:get_inventory():set_stack("main", i, get_compass_stack(player, stack))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
-- if no compasses were found, idle for a time before checking again
|
||||
local interval = found_compasses and 0 or ccompass.idle_interval
|
||||
minetest.after(interval, do_update_loop)
|
||||
end
|
||||
minetest.after(0, do_update_loop)
|
||||
|
||||
-- register items
|
||||
for i = 0, 15 do
|
||||
|
@ -39,3 +39,5 @@ ccompass_stack_max (Sets maximum stack size) int 1 1 65535
|
||||
# Requires stack_max greater than 1. When true, allows a whole stack to be calibrated at the same time.
|
||||
ccompass_allow_using_stacks (Enable to allow callibrating stacks) bool false
|
||||
|
||||
# When no players have active compasses, the mod enters an idle state and only checks for compasses at this interval, measured in seconds. This setting is meant to reduce the load on the server.
|
||||
ccompass_idle_interval (Time between checks when idling) float 1 0 10
|
||||
|
Loading…
x
Reference in New Issue
Block a user