2020-01-21 20:41:20 -05:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
2022-01-06 07:27:32 -05:00
|
|
|
local ipairs, math, minetest, nodecore, pairs, table
|
|
|
|
= ipairs, math, minetest, nodecore, pairs, table
|
|
|
|
local math_random, table_concat, table_sort
|
|
|
|
= math.random, table.concat, table.sort
|
2020-01-21 20:41:20 -05:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local donecache = {}
|
2020-03-25 08:49:55 -04:00
|
|
|
local msgcache = {}
|
2020-01-21 20:41:20 -05:00
|
|
|
|
Re-rename hints/challenges to discovery
NodeCore is supposed to be a "player vs self" mental
challenge, neither tourism/spectacle, nor a "player vs
environment" conquest. Players are supposed to find
their own goals, as well as applying the effort to
achieve them, and the nature of the goals is
purposefully as open-ended as possible, ideally with
no bias toward any kind of "completionism."
The name "Hints" implied some kind of assistance, and
thus was inappropriate. The name "Challenges"
similarly implies an extrinsic source of motivation,
which the system is only marginally designed to
provide; especially, it helps new player gain some
momentum, but players are supposed to find their own
motivation eventually instead of chasing after
hint completion as a goal, especially since they will
miss the most compelling aspects of the game.
Somewhat experimentally, rename these once again
to "discovery"/"discoveries" and remove language that
suggests progress toward completion. Add stronger
language suggesting that there is much more to
discover outside of this, hinting at emergent systems
as an example
2021-12-12 14:17:29 -05:00
|
|
|
local msg = "discovered - @1"
|
2020-01-21 20:41:20 -05:00
|
|
|
nodecore.translate_inform(msg)
|
|
|
|
|
2021-08-19 21:35:46 -04:00
|
|
|
local function hintinit(player)
|
|
|
|
local pname = player:get_player_name()
|
|
|
|
local _, done = nodecore.hint_state(pname)
|
|
|
|
local t = {}
|
|
|
|
for _, v in pairs(done) do t[v.text] = true end
|
|
|
|
donecache[pname] = t
|
|
|
|
msgcache[pname] = {}
|
|
|
|
end
|
|
|
|
nodecore.register_on_joinplayer("join hint setup", hintinit)
|
2020-01-21 20:41:20 -05:00
|
|
|
|
2022-01-06 07:27:32 -05:00
|
|
|
local function alertcheck(pname)
|
|
|
|
local dc = donecache[pname]
|
|
|
|
if not dc then return end
|
|
|
|
local mc = msgcache[pname]
|
|
|
|
if not mc then return end
|
|
|
|
|
|
|
|
local _, done = nodecore.hint_state(pname)
|
|
|
|
for _, v in pairs(done) do
|
|
|
|
if not dc[v.text] then
|
|
|
|
dc[v.text] = true
|
|
|
|
mc[v.text] = nodecore.gametime + 10
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-09-05 16:08:17 -04:00
|
|
|
nodecore.register_on_discover(function(_, key, pname)
|
|
|
|
if not key then donecache[pname] = {} end
|
2022-01-06 07:27:32 -05:00
|
|
|
return alertcheck(pname)
|
|
|
|
end)
|
2020-03-25 08:49:55 -04:00
|
|
|
|
2022-01-06 07:27:32 -05:00
|
|
|
do
|
|
|
|
local queue = {}
|
|
|
|
local function scan()
|
|
|
|
if #queue > 0 then
|
|
|
|
local pname = queue[#queue]
|
|
|
|
queue[#queue] = nil
|
|
|
|
local player = minetest.get_player_by_name(pname)
|
|
|
|
if player then alertcheck(pname) end
|
|
|
|
return minetest.after(0, scan)
|
|
|
|
else
|
|
|
|
return minetest.after(2 + math_random() * 3, function()
|
|
|
|
queue = {}
|
|
|
|
for _, p in ipairs(minetest.get_connected_players()) do
|
|
|
|
queue[#queue + 1] = p:get_player_name()
|
|
|
|
end
|
|
|
|
return minetest.after(0, scan)
|
|
|
|
end)
|
2020-03-25 08:49:55 -04:00
|
|
|
end
|
2022-01-06 07:27:32 -05:00
|
|
|
end
|
|
|
|
minetest.after(0, scan)
|
|
|
|
end
|
2020-03-25 08:49:55 -04:00
|
|
|
|
2020-06-22 22:46:48 -04:00
|
|
|
nodecore.register_playerstep({
|
|
|
|
label = "hint alerts",
|
2021-03-01 18:58:34 -05:00
|
|
|
action = function(player, data)
|
2020-06-25 07:07:51 -04:00
|
|
|
if nodecore.hints_disabled() then return end
|
|
|
|
|
2021-08-19 21:35:46 -04:00
|
|
|
if not nodecore.interact(player) then
|
|
|
|
data.hints_nointeract = true
|
|
|
|
elseif data.hints_nointeract then
|
|
|
|
data.hints_nointeract = nil
|
|
|
|
hintinit(player)
|
|
|
|
end
|
|
|
|
|
2021-03-01 18:58:34 -05:00
|
|
|
local mc = msgcache[data.pname] or {}
|
2020-06-22 22:46:48 -04:00
|
|
|
local t = {}
|
2021-08-14 08:37:06 -04:00
|
|
|
local o = {}
|
2020-06-22 22:46:48 -04:00
|
|
|
for k, v in pairs(mc) do
|
|
|
|
if v < nodecore.gametime then
|
|
|
|
mc[k] = nil
|
|
|
|
else
|
|
|
|
t[#t + 1] = nodecore.translate(msg, k)
|
2021-08-14 08:37:06 -04:00
|
|
|
o[t[#t]] = v
|
2020-06-22 22:46:48 -04:00
|
|
|
end
|
2020-01-21 20:41:20 -05:00
|
|
|
end
|
2021-08-14 08:37:06 -04:00
|
|
|
table_sort(t, function(a, b)
|
|
|
|
return o[a] < o[b] or o[a] == o[b] and a < b
|
|
|
|
end)
|
2020-06-22 22:46:48 -04:00
|
|
|
nodecore.hud_set_multiline(player, {
|
|
|
|
label = "hintcomplete",
|
|
|
|
hud_elem_type = "text",
|
|
|
|
position = {x = 0.5, y = 0.25},
|
|
|
|
text = table_concat(t, "\n"),
|
|
|
|
number = 0xE0FF80,
|
|
|
|
alignment = {x = 0, y = 0},
|
|
|
|
offset = {x = 0, y = 0}
|
|
|
|
}, nodecore.translate)
|
2020-01-21 20:41:20 -05:00
|
|
|
end
|
2020-06-22 22:46:48 -04:00
|
|
|
})
|