2019-03-05 19:20:38 -05:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
|
|
|
local nodecore, type
|
|
|
|
= nodecore, type
|
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
nodecore.hints = {}
|
|
|
|
|
|
|
|
local function conv(spec)
|
|
|
|
if not spec then
|
|
|
|
return function() return true end
|
|
|
|
end
|
|
|
|
if type(spec) == "function" then return spec end
|
|
|
|
if type(spec) == "table" then
|
|
|
|
local f = spec[1]
|
|
|
|
if f == true then
|
|
|
|
return function(db)
|
|
|
|
for i = 2, #spec do
|
|
|
|
if db[spec[i]] then return true end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return function(db)
|
2019-04-03 07:40:19 -04:00
|
|
|
for i = 1, #spec do
|
2019-03-05 19:20:38 -05:00
|
|
|
if not db[spec[i]] then return end
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return function(db) return db[spec] end
|
|
|
|
end
|
|
|
|
|
|
|
|
function nodecore.addhint(text, goal, reqs)
|
|
|
|
local hints = nodecore.hints
|
|
|
|
local h = {
|
2019-08-26 00:45:09 -04:00
|
|
|
text = nodecore.translate("...have you " .. text .. " yet?"),
|
2019-09-08 09:35:49 -04:00
|
|
|
done = nodecore.translate("...you have " .. text .. "!"),
|
2019-03-05 19:20:38 -05:00
|
|
|
goal = conv(goal),
|
|
|
|
reqs = conv(reqs)
|
|
|
|
}
|
|
|
|
hints[#hints + 1] = h
|
|
|
|
return h
|
|
|
|
end
|