feat: Add YHV1 cooldowns and enable features allowed with new YLAPI by How-Bout-No · Pull Request #107 · YimMenu-Lua/Samurais-Scripts
The toggle issue happens because the widget reads a boolean, flips it, and returns the new value. Since Lua passes booleans (and pretty much everything else except tables) by value, we cannot mutate it in place, we have to reassign it every frame and it must be the same boolean, not a copy of it:
someBoolKey, _ = GUI:CustomToggle(label, someBoolKey, ...)
If Lua supported passing booleans by reference, this wouldn't be necessary we could just pass it directly and let the widget modify it. Technically we can simulate that by storing the value inside a table like we do with GVars but I kept GUI:Checkbox and GUI:CustomToggle aligned with the default ImGui.Checkbox behavior to avoid adding extra abstraction.
GridRenderer works differently because it reads from GVars, assigns the value, then writes it back after rendering. That makes sense when drawing structured grids of toggles but it's unnecessary here and adds setup overhead. We can remove that and simplify the logic. Let's try this approach and see if toggles start behaving:
-- the for loop local key = heist.stat.cooldown_gvar GVars.features.yim_heists[key], _ = GUI:CustomToggle(_T("CP_HEIST_COOLDOWN_DISABLE"), -- I think you already call PushID in the loop but if not, we need to make sure these toggles have unique ID otherwise clicking one toggle changes all of them GVars.features.yim_heists[key], { onClick = function(_) -- this gives us a boolean representing the current checkbox/toggle state at the exact frame of clicking the item but we don't need it here YRV3:SetCooldownStateDirty(key, true) end })
And the one outside the loop:
GVars.features.yim_heists.cayo_cd, _ = GUI:CustomToggle(_T("CP_HEIST_COOLDOWN_DISABLE"), GVars.features.yim_heists.cayo_cd, { onClick = function(_) YRV3:SetCooldownStateDirty("cayo_cd", true) end })
As for the top bar scaling, yeah that's a problem. It needs a proper refactor so the entire layout scales consistently with resolution. For now though, your workaround is fine.
EDIT: I typed a long ass comment and didn't see your reply. Both approaches are fine but directly indexing GVars would be slightly cleaner.