|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
jgoemat Master Cheater Reputation: 22
Joined: 25 Sep 2011 Posts: 252
|
Posted: Sun Feb 16, 2020 8:06 pm Post subject: REQUEST: LUA - Create form from string |
|
|
I would like to embed forms in my lua library to make it easier to use. The CE designer is great and has some things that are hard or impossible to do with pure LUA commands. The helpers I I found to convert to LUA didn't work. I would love it if I could do something like:
1. (optional) From form designer, click 'Copy To Clipboard', which will copy something like the xml for a FRM file
2. Method createFormFromString(str) which would work like createFormFromFile(fileName) and take either the file contents straight from FRM, or just the binary part.
Right now I'm creating the file first and calling createFormFromFile()...
Code: |
local formStringClass = '<?xml version="1.0" encoding="utf-8"?><FormData><formMonoClass Class="TCEForm" Encoding="Ascii85">...
local formStringImage = '<?xml version="1.0" encoding="utf-8"?><FormData><formMonoImage Class="TCEForm" Encoding="Ascii85">...
local formStringSearch = '<?xml version="1.0" encoding="utf-8"?><FormData><formMonoSearch Class="TCEForm" Encoding="Ascii85">...
function saveForm(name, text)
local path = getCheatEngineDir()..[[\autorun\forms\]]..name
local f, err = io.open(path, "w")
if f == nil then return nil, err end
f:write(text)
f:close()
return true
end
saveForm('formMonoClass.frm', formStringClass)
saveForm('formMonoImage.frm', formStringImage)
saveForm('formMonoSearch.frm', formStringSearch)
formMonoClass = createFormFromFile(getCheatEngineDir()..[[\autorun\forms\formMonoClass.frm]])
formMonoImage = createFormFromFile(getCheatEngineDir()..[[\autorun\forms\formMonoImage.frm]])
formMonoSearch = createFormFromFile(getCheatEngineDir()..[[\autorun\forms\formMonoSearch.frm]])
|
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Mon Feb 17, 2020 12:54 am Post subject: |
|
|
i'll look into it, but why not just create a package with relative paths?
i'm sure your library exists out of more than one lua file, so you can just as easily include the .frm files in the package as well.
example:
https://github.com/cheat-engine/cheat-engine/tree/master/Cheat%20Engine/bin/autorun/ceshare
maintenance of the frm files is a lot easier than editing the text in a lua file
(in the formdesigner you can click file-load and save, it doesn't have to be in a table)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Mon Feb 17, 2020 4:37 am Post subject: |
|
|
My attempt.
Code: |
-- sample directory for *.frm in development
local root = [[C:\Users\username\frmpath]]
-- utilities
local psep = package.config:sub(1,1)
local cat = table.concat
local function catPath(...)
return (cat({...},psep):gsub("[/\\]+",psep))
end
FRM_IO = {
quoteFRM = function(fn)
local f = io.open(fn,'rb')
local s = f and f:read"a",f and f:close()
return s and "'"..s:gsub("['\\\0-\31\128-\255]",function(c)
return string.format([[\x%02X]],c:byte())
end).."'", s and s:len()
end,
fromString = function(s, loader)
local tmpdir = os.getenv"TEMP" or os.getenv"TMP" or "."
local tmpfn = cat{'_',math.random(100000,999999),os.time()}
tmpfn = catPath(tmpdir, tmpfn)
local f = io.open(tmpfn,'wb')
local ok = f and f:write(s) and true,f and f:close()
return ok and (loader or createFormFromFile)(tmpfn), os.remove(tmpfn)
end
}
-- make quoted string of the *.FRM file
local quoteStr,len = FRM_IO.quoteFRM(catPath(root,"SavedFormTest.FRM"))
--- print(quoteStr) and c & p quoteStr in source
local frmStr = '<?xml version="1.0" encoding="utf-8"?>\x0D\x0A<FormData>\x0D\x0A <UDF1 Class="TCEForm" Encoding="Ascii85">(6Znl):Zgron(+8wVQx3$[prLz,ghtT0lYw5N*//NV]-@8A9CTuBHu3/0(y;0;KNPgO7v67vdeq(Yh/1Djs-pY#$#V_NPJK]8f_jyVcxK,vZl2c!Qbeo6YLX4t]ISFEZT5cCSyBLrH0q6XiRYePMTLU-::cCOV-uaUr*an}sfL8e5k^KQb.iiA(ebKJqL}*pC8$diKuTt^,%i=Gm373,3NB?9m*hhOmwLWPs-QNXw;2eRb}r$szJ:*NwG-Shy_ZVn,,x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ADDED:
add fromString with an optional loader so it may work for other filetype.
the saveForm function can be do with the designer ui bar menu/save.
oops, sry. I see my script is redundant after seeing the monohelper.lua @ git.
_________________
- Retarded. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|