Aaron Suen 4b1488ed3f Hints system overhaul.
- Included new content.
- Partially converted to base on recipes instead of just items.
- Added support for group and toolcap checks.

Fixed a number of small bugs elsewhere in the process.
2019-04-03 07:41:27 -04:00

42 lines
871 B
Lua

-- 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)
for i = 1, #spec do
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 = {
text = text,
goal = conv(goal),
reqs = conv(reqs)
}
hints[#hints + 1] = h
return h
end