Improve debugging for unlock conditions

This commit is contained in:
Emik 2026-07-05 14:02:50 +02:00
parent 1f1914e5de
commit fdd4bb8e16
Signed by: emik
GPG key ID: 6B0CD72A5E503BDF
2 changed files with 35 additions and 11 deletions

View file

@ -3,7 +3,7 @@
"id": "Roland",
"name": "Roland",
"prefix": "Roland",
"version": "2.9.33",
"version": "2.9.34",
"badge_colour": "8BE9FD",
"display_name": "Roland",
"main_file": "src/main.lua",

View file

@ -332,24 +332,48 @@ if cry_prob then
end
end
function SMODS.current_mod:calculate(context)
local _ = type(G.calccontext) == "function" and G.calccontext(context)
local function call(key, value)
local obj = G[key .. "obj"]
local _ = type(obj) == "function" and obj(value)
if type(G.calc) == "function" then
G.calc = {G.calc}
if not G[key] or value == "Bakery_nothing" then
return
end
if type(G[key]) == "function" then
G[key] = {G[key]}
end
if type(G[key]) ~= "table" then
return
end
if type(G.calc) == "table" then
local str
f(context):keys():map(f.index_into(G.calc)):where(type, "function"):each(function(v)
str = str or f(context):keys():string()
local _ = f(type(value) == "table" and value or {[value] = true})
:keys()
:map(f.index_into(G[key]))
:where(type, "function")
:each(function(v)
str = str or type(value) == "table" and f(value):keys():string() or value
v(str)
end)
local _ = not str and type(G.calc[1]) == "function" and G.calc[1](f(context):keys():string())
local _ = not str and
type(G[key][1]) == "function" and
G[key][1](type(value) == "table" and f(value):keys():string() or value)
end
local orig_check_for_unlock = check_for_unlock
function check_for_unlock(args, ...)
call("lock", type(args) == "table" and args.type or args)
return orig_check_for_unlock(args, ...)
end
function SMODS.current_mod:calculate(context)
call("calc", context)
local _ = context.before and
f {"v_Roland_ceres", "v_Roland_neptune"}
:where(f.index_into(G.GAME.used_vouchers))