Major settings cleanup
- Run all settings through a common API. - Use modname prefix consistently for setting keys instead of "nodecore". - Add automatic dumping of settingtypes.txt metadata for maintenance. - Include initial settingtypes.txt for game for main menu use. - Remove per-recipe tuning for pummel recipes, as there were way too many of those to be possibly useful and it was clogging up the settings menu. Use tool rate adjustments to control it instead. - Remove vestigial enable_damage setting.
This commit is contained in:
parent
61a7414f4b
commit
8a8bed8e5d
@ -87,6 +87,7 @@ include("compat_issue10127")
|
||||
include("compat_legacyent")
|
||||
include("compat_nodealpha")
|
||||
|
||||
include("util_settings")
|
||||
include("util_misc")
|
||||
include("util_hookmeta")
|
||||
include("util_falling")
|
||||
|
@ -1,8 +1,8 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local ItemStack, PcgRandom, ipairs, math, minetest, nodecore, pairs,
|
||||
string, tonumber, tostring, type, unpack, vector
|
||||
string, tostring, type, unpack, vector
|
||||
= ItemStack, PcgRandom, ipairs, math, minetest, nodecore, pairs,
|
||||
string, tonumber, tostring, type, unpack, vector
|
||||
string, tostring, type, unpack, vector
|
||||
local math_abs, math_cos, math_floor, math_log, math_pi, math_pow,
|
||||
math_random, math_sin, math_sqrt, string_format, string_gsub,
|
||||
string_lower
|
||||
@ -11,6 +11,8 @@ local math_abs, math_cos, math_floor, math_log, math_pi, math_pow,
|
||||
string.lower
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
for k, v in pairs(minetest) do
|
||||
if type(v) == "function" then
|
||||
-- Late-bind in case minetest methods overridden.
|
||||
@ -284,21 +286,20 @@ end
|
||||
|
||||
function nodecore.rate_adjustment(...)
|
||||
local rate = 1
|
||||
local key = scrubkey(nodecore.product)
|
||||
local key = modname .. "_rate"
|
||||
local name = ""
|
||||
for _, k in ipairs({...}) do
|
||||
if not k then break end
|
||||
key = key .. "_" .. scrubkey(k)
|
||||
local adj = tonumber(minetest.settings:get(key))
|
||||
name = name .. " > " .. k
|
||||
local adj = nodecore.setting_float(key, 1, "Speed adjust" .. name,
|
||||
[[Speed adjustment ratio, multiplied by all parent ratios.
|
||||
Intended for custom servers and special sub-game types only.]])
|
||||
if adj then rate = rate * adj end
|
||||
end
|
||||
return rate
|
||||
end
|
||||
|
||||
local infodump_key = scrubkey(nodecore.product) .. "_infodump"
|
||||
function nodecore.infodump()
|
||||
return minetest.settings:get_bool(infodump_key)
|
||||
end
|
||||
|
||||
function nodecore.obstructed(minpos, maxpos)
|
||||
if not maxpos then
|
||||
maxpos = {x = minpos.x + 0.5, y = minpos.y + 0.5, z = minpos.z + 0.5}
|
||||
@ -320,8 +321,13 @@ function nodecore.obstructed(minpos, maxpos)
|
||||
end
|
||||
end
|
||||
|
||||
local gravity = tonumber(minetest.settings:get("movement_gravity")) or 9.81
|
||||
local friction = tonumber(minetest.settings:get("nodecore_air_friction")) or 0.0004
|
||||
local gravity = nodecore.setting_float("movement_gravity", 9.81)
|
||||
local friction = nodecore.setting_float(modname .. "_air_friction", 0.0004,
|
||||
"Air friction", [[Air friction coefficient for velocity-squared
|
||||
term. Used to adjust air resistance for player and moving entities,
|
||||
especially tuning terminal velocity. Lower terminal velocity may
|
||||
reduce players stopping on onloaded chunks while falling on a
|
||||
busy/slow server.]])
|
||||
|
||||
local function air_accel_factor(v)
|
||||
local q = (friction * v * v) * 2 - 1
|
||||
|
95
mods/nc_api/util_settings.lua
Normal file
95
mods/nc_api/util_settings.lua
Normal file
@ -0,0 +1,95 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local ipairs, minetest, nodecore, pairs, string, table, tonumber,
|
||||
tostring
|
||||
= ipairs, minetest, nodecore, pairs, string, table, tonumber,
|
||||
tostring
|
||||
local string_format, string_gmatch, string_match, string_sub,
|
||||
table_sort
|
||||
= string.format, string.gmatch, string.match, string.sub,
|
||||
table.sort
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local known_settings = {}
|
||||
local known_dirty
|
||||
|
||||
local prefix = "nc_"
|
||||
local function setting_learn(key, title, comment, typename, typedata)
|
||||
if string_sub(key, 1, #prefix) ~= prefix then return end
|
||||
if known_settings[key] then return end
|
||||
known_settings[key] = {
|
||||
title = title,
|
||||
comment = comment,
|
||||
typename = typename,
|
||||
typedata = typedata
|
||||
}
|
||||
known_dirty = true
|
||||
end
|
||||
|
||||
function nodecore.setting_string(key, default, title, comment)
|
||||
setting_learn(key, title, comment, "string",
|
||||
default and string_format("%q", default))
|
||||
local s = minetest.settings:get(key)
|
||||
return s == "" and default or s
|
||||
end
|
||||
|
||||
function nodecore.setting_float(key, default, title, comment)
|
||||
setting_learn(key, title, comment, "float",
|
||||
default and tostring(default) or "")
|
||||
return tonumber(minetest.settings:get(key)) or default
|
||||
end
|
||||
|
||||
function nodecore.setting_bool(key, default, title, comment)
|
||||
setting_learn(key, title, comment, "bool",
|
||||
default ~= nil and (default and "true" or "false") or "")
|
||||
return minetest.settings:get_bool(key, default)
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
function nodecore.infodump()
|
||||
return nodecore.setting_bool(
|
||||
minetest.get_current_modname() .. "_infodump",
|
||||
false,
|
||||
"Write info dumps to world path",
|
||||
[[Write out after startup (and possibly maintain while running)
|
||||
text files to the world path containing template metadata for
|
||||
development use.]]
|
||||
)
|
||||
end
|
||||
|
||||
if nodecore.infodump() then
|
||||
minetest.register_globalstep(function()
|
||||
if not known_dirty then return end
|
||||
known_dirty = nil
|
||||
|
||||
local keys = {}
|
||||
for k in pairs(known_settings) do keys[#keys + 1] = k end
|
||||
table_sort(keys)
|
||||
|
||||
local dump = "# ===== Automatically generated by " .. modname .. "\n"
|
||||
for _, k in ipairs(keys) do
|
||||
dump = dump .. "\n"
|
||||
local data = known_settings[k]
|
||||
if data.comment and string_match(data.comment, "%S") then
|
||||
local txt = ""
|
||||
for w in string_gmatch(data.comment, "(%S+)") do
|
||||
if #txt + #w + 1 > 71 then
|
||||
dump = dump .. "#" .. txt .. "\n"
|
||||
txt = ""
|
||||
end
|
||||
txt = txt .. " " .. w
|
||||
end
|
||||
if txt ~= "" then
|
||||
dump = dump .. "#" .. txt .. "\n"
|
||||
end
|
||||
end
|
||||
dump = dump .. string_format("%s (%s) %s %s\n", k,
|
||||
data.title or k, data.typename, data.typedata or "")
|
||||
end
|
||||
|
||||
local p = minetest.get_worldpath() .. "/settingtypes.txt"
|
||||
return minetest.safe_file_write(p, dump)
|
||||
end)
|
||||
end
|
@ -16,8 +16,7 @@ local witnessable = {
|
||||
}
|
||||
|
||||
local rate_adj_actions = {
|
||||
cook = true,
|
||||
pummel = true
|
||||
cook = true
|
||||
}
|
||||
|
||||
function nodecore.register_craft(recipe)
|
||||
|
@ -1,11 +1,13 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, nodecore, string
|
||||
= minetest, nodecore, string
|
||||
local string_lower
|
||||
= string.lower
|
||||
local minetest, nodecore
|
||||
= minetest, nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
function nodecore.hints_disabled()
|
||||
return minetest.settings:get_bool(
|
||||
string_lower(nodecore.product) .. "_disable_hints")
|
||||
return not nodecore.setting_bool(modname .. "_enable", true, "Enable hints",
|
||||
[[Enable/show the hint system and all related interfaces. Disabling
|
||||
this may be useful on multiplayer servers if the players are all
|
||||
experienced and the hints are obtrusive or distracting.]])
|
||||
end
|
||||
|
@ -1,22 +1,34 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local math, minetest, nodecore, pairs, string, tonumber, type, vector
|
||||
= math, minetest, nodecore, pairs, string, tonumber, type, vector
|
||||
local math, minetest, nodecore, pairs, string, type, vector
|
||||
= math, minetest, nodecore, pairs, string, type, vector
|
||||
local math_floor, math_random, string_format
|
||||
= math.floor, math.random, string.format
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local function config(n)
|
||||
return minetest.settings:get(nodecore.product:lower()
|
||||
.. "_optic_" .. n)
|
||||
end
|
||||
local optic_distance = tonumber(config("distance")) or 16
|
||||
local optic_speed = tonumber(config("speed")) or 12
|
||||
local optic_tick_limit = tonumber(config("tick_limit")) or 0.2
|
||||
local optic_interval = tonumber(config("interval")) or 5
|
||||
local optic_passive_max = tonumber(config("passive_max")) or 25
|
||||
local optic_passive_min = tonumber(config("passive_max")) or 5
|
||||
local optic_distance = 16
|
||||
local optic_speed = 12
|
||||
local optic_tick_limit = nodecore.setting_float(modname .. "_tick_limit", 0.2,
|
||||
"Optic tick limit", [[Maxiumum amount of time in seconds that may be
|
||||
spent during a single server step to calculate optic state. Optics
|
||||
will be allowed to slow don to stay within this limit.]])
|
||||
local optic_interval = nodecore.setting_float(modname .. "_interval", 5,
|
||||
"Optic check interval", [[ABM interval for periodically pushing
|
||||
optics into the "passive" queue.
|
||||
Passive checks are used to catch optics in an inconsistent state, e.g.
|
||||
that missed their change event.]])
|
||||
local optic_passive_max = nodecore.setting_float(modname .. "_passive_max", 25,
|
||||
"Optic check passive max", [[The maximum number of optics that can be
|
||||
queued in a single pass for "passive" checks to run (pending passive)
|
||||
checks will be included to fill up remaining spaces up to this total).
|
||||
Passive checks are used to catch optics in an inconsistent state, e.g.
|
||||
that missed their change event.]])
|
||||
local optic_passive_min = nodecore.setting_float(modname .. "_passive_min", 5,
|
||||
"Optic check passive min", [[The minimum number of "passive" optic
|
||||
checks that are run each cycle, overriding the max if needed.
|
||||
Passive checks are used to catch optics in an inconsistent state, e.g.
|
||||
that missed their change event.]])
|
||||
|
||||
local microtime = minetest.get_us_time
|
||||
local hashpos = minetest.hash_node_position
|
||||
@ -29,13 +41,13 @@ local node_optic_sources = {}
|
||||
local node_opaque = {}
|
||||
local node_visinv = {}
|
||||
minetest.after(0, function()
|
||||
for k, v in pairs(minetest.registered_nodes) do
|
||||
node_optic_checks[k] = v.optic_check or nil
|
||||
node_optic_sources[k] = v.optic_source or nil
|
||||
node_opaque[k] = (not v.sunlight_propagates) or nil
|
||||
node_visinv[k] = v.groups and v.groups.visinv or nil
|
||||
end
|
||||
end)
|
||||
for k, v in pairs(minetest.registered_nodes) do
|
||||
node_optic_checks[k] = v.optic_check or nil
|
||||
node_optic_sources[k] = v.optic_source or nil
|
||||
node_opaque[k] = (not v.sunlight_propagates) or nil
|
||||
node_visinv[k] = v.groups and v.groups.visinv or nil
|
||||
end
|
||||
end)
|
||||
|
||||
local optic_queue = {}
|
||||
local passive_queue = {}
|
||||
@ -43,238 +55,238 @@ local dependency_index = {}
|
||||
local dependency_reverse = {}
|
||||
|
||||
local function mapblock(pos)
|
||||
return {
|
||||
x = math_floor((pos.x + 0.5) / 16),
|
||||
y = math_floor((pos.y + 0.5) / 16),
|
||||
z = math_floor((pos.z + 0.5) / 16),
|
||||
}
|
||||
return {
|
||||
x = math_floor((pos.x + 0.5) / 16),
|
||||
y = math_floor((pos.y + 0.5) / 16),
|
||||
z = math_floor((pos.z + 0.5) / 16),
|
||||
}
|
||||
end
|
||||
|
||||
local function scan(pos, dir, max, getnode, cbbs)
|
||||
local p = pos
|
||||
if (not max) or (max > optic_distance) then max = optic_distance end
|
||||
for _ = 1, max do
|
||||
local o = p
|
||||
p = vector.add(p, dir)
|
||||
if cbbs and not vector.equals(mapblock(o), mapblock(p)) then
|
||||
cbbs[#cbbs + 1] = {
|
||||
pos = vector.add(o, vector.multiply(dir, 0.5)),
|
||||
dir = dir,
|
||||
plane = {
|
||||
x = dir.x == 0 and 1 or 0,
|
||||
y = dir.y == 0 and 1 or 0,
|
||||
z = dir.z == 0 and 1 or 0,
|
||||
}
|
||||
local p = pos
|
||||
if (not max) or (max > optic_distance) then max = optic_distance end
|
||||
for _ = 1, max do
|
||||
local o = p
|
||||
p = vector.add(p, dir)
|
||||
if cbbs and not vector.equals(mapblock(o), mapblock(p)) then
|
||||
cbbs[#cbbs + 1] = {
|
||||
pos = vector.add(o, vector.multiply(dir, 0.5)),
|
||||
dir = dir,
|
||||
plane = {
|
||||
x = dir.x == 0 and 1 or 0,
|
||||
y = dir.y == 0 and 1 or 0,
|
||||
z = dir.z == 0 and 1 or 0,
|
||||
}
|
||||
end
|
||||
local node = getnode(p)
|
||||
if (not node) or node.name == "ignore" then return end
|
||||
if node_opaque[node.name] then return p, node end
|
||||
if node_visinv[node.name] then
|
||||
local stack = nodecore.stack_get(p)
|
||||
if node_opaque[stack:get_name()] then
|
||||
return p, node
|
||||
end
|
||||
}
|
||||
end
|
||||
local node = getnode(p)
|
||||
if (not node) or node.name == "ignore" then return end
|
||||
if node_opaque[node.name] then return p, node end
|
||||
if node_visinv[node.name] then
|
||||
local stack = nodecore.stack_get(p)
|
||||
if node_opaque[stack:get_name()] then
|
||||
return p, node
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
nodecore.optic_scan = scan
|
||||
|
||||
local function scan_recv(pos, dir, max, getnode)
|
||||
local hit, node = scan(pos, dir, max, getnode)
|
||||
if not node then return end
|
||||
local src = node_optic_sources[node.name]
|
||||
src = src and src(hit, node)
|
||||
if not src then return end
|
||||
local rev = vector.multiply(dir, -1)
|
||||
for _, v in pairs(src) do
|
||||
if vector.equals(v, rev) then
|
||||
return hit, node
|
||||
end
|
||||
local hit, node = scan(pos, dir, max, getnode)
|
||||
if not node then return end
|
||||
local src = node_optic_sources[node.name]
|
||||
src = src and src(hit, node)
|
||||
if not src then return end
|
||||
local rev = vector.multiply(dir, -1)
|
||||
for _, v in pairs(src) do
|
||||
if vector.equals(v, rev) then
|
||||
return hit, node
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function optic_check(pos)
|
||||
optic_queue[hashpos(pos)] = pos
|
||||
optic_queue[hashpos(pos)] = pos
|
||||
end
|
||||
nodecore.optic_check = optic_check
|
||||
|
||||
local function optic_trigger(start, dir, max)
|
||||
local pos, node = scan(start, dir, max, get_node)
|
||||
if node and node_optic_checks[node.name] then
|
||||
return optic_check(pos)
|
||||
end
|
||||
local pos, node = scan(start, dir, max, get_node)
|
||||
if node and node_optic_checks[node.name] then
|
||||
return optic_check(pos)
|
||||
end
|
||||
end
|
||||
|
||||
local function optic_process(trans, pos)
|
||||
local node = get_node(pos)
|
||||
if node.name == "ignore" then return end
|
||||
local node = get_node(pos)
|
||||
if node.name == "ignore" then return end
|
||||
|
||||
local check = node_optic_checks[node.name]
|
||||
if check then
|
||||
local ignored
|
||||
local deps = {}
|
||||
local getnode = function(p)
|
||||
local gn = get_node(p)
|
||||
deps[hashpos(p)] = true
|
||||
ignored = ignored or gn.name == "ignore"
|
||||
return gn
|
||||
end
|
||||
local recv = function(dir, max)
|
||||
return scan_recv(pos, dir, max, getnode)
|
||||
end
|
||||
local nn = check(pos, node, recv, getnode)
|
||||
if (not ignored) and nn then
|
||||
trans[hashpos(pos)] = {
|
||||
pos = pos,
|
||||
nn = nn,
|
||||
deps = deps
|
||||
}
|
||||
end
|
||||
local check = node_optic_checks[node.name]
|
||||
if check then
|
||||
local ignored
|
||||
local deps = {}
|
||||
local getnode = function(p)
|
||||
local gn = get_node(p)
|
||||
deps[hashpos(p)] = true
|
||||
ignored = ignored or gn.name == "ignore"
|
||||
return gn
|
||||
end
|
||||
local recv = function(dir, max)
|
||||
return scan_recv(pos, dir, max, getnode)
|
||||
end
|
||||
local nn = check(pos, node, recv, getnode)
|
||||
if (not ignored) and nn then
|
||||
trans[hashpos(pos)] = {
|
||||
pos = pos,
|
||||
nn = nn,
|
||||
deps = deps
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function optic_commit(v)
|
||||
local node = get_node(v.pos)
|
||||
local node = get_node(v.pos)
|
||||
|
||||
local oldidx = {}
|
||||
local oldsrc = node_optic_sources[node.name]
|
||||
oldsrc = oldsrc and oldsrc(v.pos, node)
|
||||
if oldsrc then
|
||||
for _, dir in pairs(oldsrc) do
|
||||
oldidx[hashpos(dir)] = dir
|
||||
end
|
||||
local oldidx = {}
|
||||
local oldsrc = node_optic_sources[node.name]
|
||||
oldsrc = oldsrc and oldsrc(v.pos, node)
|
||||
if oldsrc then
|
||||
for _, dir in pairs(oldsrc) do
|
||||
oldidx[hashpos(dir)] = dir
|
||||
end
|
||||
end
|
||||
|
||||
local nn = v.nn
|
||||
if type(nn) == "string" then nn = {name = nn} end
|
||||
nn.param = nn.param or node.param
|
||||
nn.param2 = nn.param2 or node.param2
|
||||
local vhash = hashpos(v.pos)
|
||||
if node.name ~= nn.name or node.param ~= nn.param or nn.param2 ~= nn.param2 then
|
||||
set_node(v.pos, nn)
|
||||
local src = node_optic_sources[nn.name]
|
||||
src = src and src(v.pos, nn)
|
||||
local newidx = {}
|
||||
if src then
|
||||
for _, dir in pairs(src) do
|
||||
local hash = hashpos(dir)
|
||||
if not oldidx[hash] then
|
||||
optic_trigger(v.pos, dir)
|
||||
end
|
||||
newidx[hash] = dir
|
||||
local nn = v.nn
|
||||
if type(nn) == "string" then nn = {name = nn} end
|
||||
nn.param = nn.param or node.param
|
||||
nn.param2 = nn.param2 or node.param2
|
||||
local vhash = hashpos(v.pos)
|
||||
if node.name ~= nn.name or node.param ~= nn.param or nn.param2 ~= nn.param2 then
|
||||
set_node(v.pos, nn)
|
||||
local src = node_optic_sources[nn.name]
|
||||
src = src and src(v.pos, nn)
|
||||
local newidx = {}
|
||||
if src then
|
||||
for _, dir in pairs(src) do
|
||||
local hash = hashpos(dir)
|
||||
if not oldidx[hash] then
|
||||
optic_trigger(v.pos, dir)
|
||||
end
|
||||
end
|
||||
for hash, dir in pairs(oldidx) do
|
||||
if not newidx[hash] then optic_trigger(v.pos, dir) end
|
||||
newidx[hash] = dir
|
||||
end
|
||||
end
|
||||
for hash, dir in pairs(oldidx) do
|
||||
if not newidx[hash] then optic_trigger(v.pos, dir) end
|
||||
end
|
||||
end
|
||||
|
||||
local olddep = dependency_reverse[vhash]
|
||||
if olddep then
|
||||
for k in pairs(olddep) do
|
||||
local t = dependency_index[k]
|
||||
if t then t[vhash] = nil end
|
||||
end
|
||||
end
|
||||
for k in pairs(v.deps) do
|
||||
local olddep = dependency_reverse[vhash]
|
||||
if olddep then
|
||||
for k in pairs(olddep) do
|
||||
local t = dependency_index[k]
|
||||
if not t then
|
||||
t = {}
|
||||
dependency_index[k] = t
|
||||
end
|
||||
t[vhash] = true
|
||||
if t then t[vhash] = nil end
|
||||
end
|
||||
end
|
||||
for k in pairs(v.deps) do
|
||||
local t = dependency_index[k]
|
||||
if not t then
|
||||
t = {}
|
||||
dependency_index[k] = t
|
||||
end
|
||||
t[vhash] = true
|
||||
end
|
||||
end
|
||||
|
||||
nodecore.register_limited_abm({
|
||||
label = "optic check",
|
||||
interval = optic_interval,
|
||||
chance = 1,
|
||||
nodenames = {"group:optic_check"},
|
||||
action = function(pos)
|
||||
passive_queue[#passive_queue + 1] = pos
|
||||
end
|
||||
})
|
||||
label = "optic check",
|
||||
interval = optic_interval,
|
||||
chance = 1,
|
||||
nodenames = {"group:optic_check"},
|
||||
action = function(pos)
|
||||
passive_queue[#passive_queue + 1] = pos
|
||||
end
|
||||
})
|
||||
nodecore.register_lbm({
|
||||
name = modname .. ":check",
|
||||
run_at_every_load = true,
|
||||
nodenames = {"group:optic_check"},
|
||||
action = optic_check
|
||||
})
|
||||
name = modname .. ":check",
|
||||
run_at_every_load = true,
|
||||
nodenames = {"group:optic_check"},
|
||||
action = optic_check
|
||||
})
|
||||
|
||||
local optic_check_pump
|
||||
do
|
||||
local passive_batch = {}
|
||||
optic_check_pump = function()
|
||||
local batch = optic_queue
|
||||
optic_queue = {}
|
||||
local passive_batch = {}
|
||||
optic_check_pump = function()
|
||||
local batch = optic_queue
|
||||
optic_queue = {}
|
||||
|
||||
if nodecore.stasis then
|
||||
passive_queue = {}
|
||||
return
|
||||
end
|
||||
if nodecore.stasis then
|
||||
passive_queue = {}
|
||||
return
|
||||
end
|
||||
|
||||
if #passive_queue > 0 then
|
||||
passive_batch = passive_queue
|
||||
passive_queue = {}
|
||||
for i = 1, #passive_batch do
|
||||
local j = math_random(1, #passive_batch)
|
||||
local t = passive_batch[i]
|
||||
passive_batch[i] = passive_batch[j]
|
||||
passive_batch[j] = t
|
||||
end
|
||||
end
|
||||
local max = optic_passive_max - #batch
|
||||
if max < optic_passive_min then max = optic_passive_min end
|
||||
if max > #passive_batch then max = #passive_batch end
|
||||
for _ = 1, max do
|
||||
local pos = passive_batch[#passive_batch]
|
||||
passive_batch[#passive_batch] = nil
|
||||
batch[hashpos(pos)] = pos
|
||||
end
|
||||
|
||||
local trans = {}
|
||||
for _, pos in pairs(batch) do
|
||||
optic_process(trans, pos)
|
||||
end
|
||||
|
||||
for _, v in pairs(trans) do
|
||||
optic_commit(v)
|
||||
if #passive_queue > 0 then
|
||||
passive_batch = passive_queue
|
||||
passive_queue = {}
|
||||
for i = 1, #passive_batch do
|
||||
local j = math_random(1, #passive_batch)
|
||||
local t = passive_batch[i]
|
||||
passive_batch[i] = passive_batch[j]
|
||||
passive_batch[j] = t
|
||||
end
|
||||
end
|
||||
local max = optic_passive_max - #batch
|
||||
if max < optic_passive_min then max = optic_passive_min end
|
||||
if max > #passive_batch then max = #passive_batch end
|
||||
for _ = 1, max do
|
||||
local pos = passive_batch[#passive_batch]
|
||||
passive_batch[#passive_batch] = nil
|
||||
batch[hashpos(pos)] = pos
|
||||
end
|
||||
|
||||
local trans = {}
|
||||
for _, pos in pairs(batch) do
|
||||
optic_process(trans, pos)
|
||||
end
|
||||
|
||||
for _, v in pairs(trans) do
|
||||
optic_commit(v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local tick = 1 / optic_speed
|
||||
local total = 0
|
||||
nodecore.register_globalstep("optic tick", function(dtime)
|
||||
total = total + dtime / tick
|
||||
local starttime = microtime()
|
||||
local exp = starttime + optic_tick_limit * 1000000
|
||||
local starttotal = total
|
||||
while total > 1 do
|
||||
optic_check_pump()
|
||||
if microtime() >= exp then
|
||||
nodecore.log("warning", string_format("optics stopped"
|
||||
.. " after running %d cycles in %0.3fs"
|
||||
.. ", behind %0.2f",
|
||||
starttotal - total,
|
||||
(microtime() - starttime) / 1000000,
|
||||
total))
|
||||
total = 0
|
||||
else
|
||||
total = total - 1
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
nodecore.register_on_nodeupdate(function(pos)
|
||||
local t = dependency_index[hashpos(pos)]
|
||||
if t then
|
||||
for k in pairs(t) do
|
||||
optic_check(unhash(k))
|
||||
local tick = 1 / optic_speed
|
||||
local total = 0
|
||||
nodecore.register_globalstep("optic tick", function(dtime)
|
||||
total = total + dtime / tick
|
||||
local starttime = microtime()
|
||||
local exp = starttime + optic_tick_limit * 1000000
|
||||
local starttotal = total
|
||||
while total > 1 do
|
||||
optic_check_pump()
|
||||
if microtime() >= exp then
|
||||
nodecore.log("warning", string_format("optics stopped"
|
||||
.. " after running %d cycles in %0.3fs"
|
||||
.. ", behind %0.2f",
|
||||
starttotal - total,
|
||||
(microtime() - starttime) / 1000000,
|
||||
total))
|
||||
total = 0
|
||||
else
|
||||
total = total - 1
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
nodecore.register_on_nodeupdate(function(pos)
|
||||
local t = dependency_index[hashpos(pos)]
|
||||
if t then
|
||||
for k in pairs(t) do
|
||||
optic_check(unhash(k))
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
@ -16,8 +16,7 @@ minetest.register_privilege("ncdqd", {
|
||||
})
|
||||
|
||||
function nodecore.player_can_take_damage(player)
|
||||
return minetest.settings:get_bool("enable_damage")
|
||||
and not player:get_armor_groups().immortal
|
||||
return not player:get_armor_groups().immortal
|
||||
and not minetest.check_player_privs(player, "ncdqd")
|
||||
end
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local math, minetest, nodecore, pairs, tonumber
|
||||
= math, minetest, nodecore, pairs, tonumber
|
||||
local math, minetest, nodecore, pairs
|
||||
= math, minetest, nodecore, pairs
|
||||
local math_sqrt
|
||||
= math.sqrt
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
@ -10,7 +10,10 @@ nodecore.amcoremod()
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
-- Maximum distance at which custom nametags are visible.
|
||||
local distance = tonumber(minetest.settings:get(modname .. "_distance")) or 16
|
||||
local distance = nodecore.setting_float(modname .. "_distance", 16,
|
||||
"Max player nametag distance", [[The maximum distance in nodes
|
||||
that other players' nametags will be visible under optimum
|
||||
conditions.]])
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- PLAYER JOIN/LEAVE
|
||||
|
@ -1,12 +1,17 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local math, minetest, nodecore, pairs, string, tonumber, type, vector
|
||||
= math, minetest, nodecore, pairs, string, tonumber, type, vector
|
||||
local math, minetest, nodecore, pairs, string, type, vector
|
||||
= math, minetest, nodecore, pairs, string, type, vector
|
||||
local math_random, string_format
|
||||
= math.random, string.format
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local mintime = tonumber(minetest.settings:get(nodecore.product:lower() .. "_pushout_time")) or 2
|
||||
local stepdist = tonumber(minetest.settings:get(nodecore.product:lower() .. "_pushout_stepdist")) or 5
|
||||
local modname = minetest.get_current_modname()
|
||||
local mintime = nodecore.setting_float(modname .. "_time", 2,
|
||||
"Push out of solid time", [[The amount of time a player
|
||||
needs to be trapped in a solid node before being pushed out.]])
|
||||
local stepdist = nodecore.setting_float(modname .. "_stepdist", 5,
|
||||
"Push out of solid distance", [[The maximum distance in
|
||||
nodes that a player will be pushed out of solids.]])
|
||||
|
||||
local function normalbox(box)
|
||||
if not box then return true end
|
||||
|
235
settingtypes.txt
Normal file
235
settingtypes.txt
Normal file
@ -0,0 +1,235 @@
|
||||
# ===== Automatically generated by nc_api
|
||||
|
||||
# Air friction coefficient for velocity-squared term. Used to adjust air
|
||||
# resistance for player and moving entities, especially tuning terminal
|
||||
# velocity. Lower terminal velocity may reduce players stopping on
|
||||
# onloaded chunks while falling on a busy/slow server.
|
||||
nc_api_air_friction (Air friction) float 0.0004
|
||||
|
||||
# Enable/show the hint system and all related interfaces. Disabling this
|
||||
# may be useful on multiplayer servers if the players are all
|
||||
# experienced and the hints are obtrusive or distracting.
|
||||
nc_api_hints_enable (Enable hints) bool true
|
||||
|
||||
# Write out after startup (and possibly maintain while running) text
|
||||
# files to the world path containing template metadata for development
|
||||
# use.
|
||||
nc_api_infodump (Write info dumps to world path) bool false
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_autorun (Speed adjust > autorun) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_autorun_acceltime (Speed adjust > autorun > acceltime) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_autorun_ratio (Speed adjust > autorun > ratio) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_autorun_walkspeed (Speed adjust > autorun > walkspeed) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_autorun_walktime (Speed adjust > autorun > walktime) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed (Speed adjust > speed) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_cook (Speed adjust > speed > cook) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_cook_cool_clear_glass (Speed adjust > speed > cook > cool clear glass) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_cook_cool_float_glass (Speed adjust > speed > cook > cool float glass) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_cook_heat_lode_cobble (Speed adjust > speed > cook > heat lode cobble) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_cook_lode_ore_cooling (Speed adjust > speed > cook > lode ore cooling) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_cook_lode_ore_quenching (Speed adjust > speed > cook > lode ore quenching) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_cook_lode_stack_annealing (Speed adjust > speed > cook > lode stack annealing) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_cook_lode_stack_heating (Speed adjust > speed > cook > lode stack heating) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_cook_lode_stack_quenching (Speed adjust > speed > cook > lode stack quenching) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_cook_melt_sand_to_glass (Speed adjust > speed > cook > melt sand to glass) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_cook_quench_crude_glass (Speed adjust > speed > cook > quench crude glass) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_cook_quench_opaque_glass (Speed adjust > speed > cook > quench opaque glass) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_pummel (Speed adjust > speed > pummel) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_pummel_charcoal_writing (Speed adjust > speed > pummel > charcoal writing) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_pummel_rake_gravel (Speed adjust > speed > pummel > rake gravel) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_pummel_rake_sand (Speed adjust > speed > pummel > rake sand) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_pummel_stick_fire_starting (Speed adjust > speed > pummel > stick fire starting) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_soaking (Speed adjust > speed > soaking) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_soaking_eggcorn_sprout (Speed adjust > speed > soaking > eggcorn sprout) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_soaking_loose_self_repack (Speed adjust > speed > soaking > loose self-repack) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_soaking_lux_infuse (Speed adjust > speed > soaking > lux infuse) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_soaking_lux_renew (Speed adjust > speed > soaking > lux renew) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_soaking_nc_terrain_dirt_leaching_to_nc_terrain_sand_loose (Speed adjust > speed > soaking > nc_terrain:dirt leaching to nc_terrain:sand_loose) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_soaking_nc_tree_humus_leaching_to_nc_terrain_dirt_loose (Speed adjust > speed > soaking > nc_tree:humus leaching to nc_terrain:dirt_loose) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_soaking_peat_compost (Speed adjust > speed > soaking > peat compost) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_soaking_pliable_concrete_cure (Speed adjust > speed > soaking > pliable concrete cure) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_soaking_tree_leaves_grow (Speed adjust > speed > soaking > tree leaves grow) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_soaking_tree_trunk_grow (Speed adjust > speed > soaking > tree trunk grow) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_soaking_wet_concrete_cure (Speed adjust > speed > soaking > wet concrete cure) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_tool (Speed adjust > speed > tool) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_tool_choppy (Speed adjust > speed > tool > choppy) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_tool_cracky (Speed adjust > speed > tool > cracky) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_tool_crumbly (Speed adjust > speed > tool > crumbly) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_tool_scratchy (Speed adjust > speed > tool > scratchy) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_tool_snappy (Speed adjust > speed > tool > snappy) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_speed_tool_thumpy (Speed adjust > speed > tool > thumpy) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_zoom (Speed adjust > zoom) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_zoom_base (Speed adjust > zoom > base) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_zoom_ratio (Speed adjust > zoom > ratio) float 1
|
||||
|
||||
# Speed adjustment ratio, multiplied by all parent ratios. Intended for
|
||||
# custom servers and special sub-game types only.
|
||||
nc_api_rate_zoom_time (Speed adjust > zoom > time) float 1
|
||||
|
||||
# ABM interval for periodically pushing optics into the "passive" queue.
|
||||
# Passive checks are used to catch optics in an inconsistent state, e.g.
|
||||
# that missed their change event.
|
||||
nc_optics_interval (Optic check interval) float 5
|
||||
|
||||
# The maximum number of optics that can be queued in a single pass for
|
||||
# "passive" checks to run (pending passive) checks will be included to
|
||||
# fill up remaining spaces up to this total). Passive checks are used to
|
||||
# catch optics in an inconsistent state, e.g. that missed their change
|
||||
# event.
|
||||
nc_optics_passive_max (Optic check passive max) float 25
|
||||
|
||||
# The minimum number of "passive" optic checks that are run each cycle,
|
||||
# overriding the max if needed. Passive checks are used to catch optics
|
||||
# in an inconsistent state, e.g. that missed their change event.
|
||||
nc_optics_passive_min (Optic check passive min) float 5
|
||||
|
||||
# Maxiumum amount of time in seconds that may be spent during a single
|
||||
# server step to calculate optic state. Optics will be allowed to slow
|
||||
# don to stay within this limit.
|
||||
nc_optics_tick_limit (Optic tick limit) float 0.2
|
||||
|
||||
# The maximum distance in nodes that other players' nametags will be
|
||||
# visible under optimum conditions.
|
||||
nc_player_names_distance (Max player nametag distance) float 16
|
||||
|
||||
# The maximum distance in nodes that a player will be pushed out of
|
||||
# solids.
|
||||
nc_player_setup_stepdist (Push out of solid distance) float 5
|
||||
|
||||
# The amount of time a player needs to be trapped in a solid node before
|
||||
# being pushed out.
|
||||
nc_player_setup_time (Push out of solid time) float 2
|
Loading…
x
Reference in New Issue
Block a user