pryans / kcd-cheat

KCD Cheat Mod
https://www.nexusmods.com/kingdomcomedeliverance/mods/106
20 stars 13 forks source link

Suggestion: cheat_eval can't do numerical for loops, so here's a range iterator #31

Closed AndreLouisIssa closed 2 years ago

AndreLouisIssa commented 2 years ago

wrote this and I put it in my autocheat.lua

function range(lo,hi,st)
    if hi == nil then
        hi = lo
        lo = 1
    end
    st = st or 1
    return function(_,i)
        i = i and i + st or lo
        if i > hi then return nil end
        return i
    end, nil, nil
end

so I can type the command cheat_eval for i in range(500) do <something> end

since cheat_eval for i = 1, 500, 1 do <something> end fails as it tries to read the =

the suggestion is to find a natural place to put this in cheat's script files, or fix cheat_eval somehow to support the numerical for loop syntax

AndreLouisIssa commented 2 years ago

will follow this up with an expanded issue

AndreLouisIssa commented 2 years ago

revised/expanded as https://github.com/pryans/kcd-cheat/issues/32