View previous topic :: View next topic |
Author |
Message |
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Wed Nov 09, 2016 4:28 pm Post subject: Simple CT Deploy script for Large Size file |
|
|
CE's Table File has good compression ratio (x2~10+).
It may save some future forum attachment file size limit if the original ct can pack into a table file.
The follow script is an example using phokz and others' DS3 table http://forum.cheatengine.org/viewtopic.php?t=589191 (1.6M to 140k)
Sometime, after add file to table file, the new ct may not able to save, try check and edit the added table file name, it may help.
Code: |
{$lua}
function Deploy(tblFileName, mrdesc_to_active)
if getCEVersion()<6.6 then error"Need CE 6.6+" end
local tblFile = findTableFile(tblFileName)
if not tblFile then
print("Can't find table file:"..tostring(tblFileName)..'.\nTry add it using MENU/Table/Add file')
else
local tm = createTimer()
tm.Interval = 1000;
tm.OnTimer = function(t)
t.Destroy()
local al = GetAddressList()
while al.Count>0 do al[0].Destroy()end
loadTable(tblFile.Stream ,false, false) -- not merge, not ignore lua error
if mrdesc_to_active then
local mr = al.getMemoryRecordByDescription(mrdesc_to_active)
if mr then mr.Active = true end
end
end
end
end
if not syntaxcheck then
-- example, load Ds3 and active the 'Open' memory record
Deploy('DS3.CT','Open')
end
{$asm}
[ENABLE]
[DISABLE]
|
bye~
Description: |
sample, don't use the attach script, but c & p above script |
|
Download |
Filename: |
ds3zip.CT |
Filesize: |
138.62 KB |
Downloaded: |
1973 Time(s) |
_________________
- Retarded.
Last edited by panraven on Thu Nov 10, 2016 9:12 am; edited 5 times in total |
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Wed Nov 09, 2016 7:30 pm Post subject: |
|
|
Looks good
PS: this line:
Code: | for i=al.Count-1,0,-1 do al[i].Destroy()end |
could be faster and simpler:
Code: | while al.Count > 0 do al[0].destroy() end |
PS2: loadTable(stream ,true, true) , don't know if ignoring lua script dialog is a good thing.
_________________
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Wed Nov 09, 2016 7:49 pm Post subject: |
|
|
@mgr.inz.Player
thanks comment.
I remove the mr destroy, seems use not 'merge' better so to assure the mr id is not changed. EDIT: oops, I thought 'not merge' will remove previous mr, but actually not. The destroy is keep. btw, 'for' loop should faster than 'while' loop ? remove from 'head' may need 'realloc' the mr list?
And for the ignore Lua error, the developer should have verify it.
The script only work for ce 6.6, so added a version check, not sure what cause "Error:Unknown extension" ~_~
bye~
_________________
- Retarded. |
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Wed Nov 09, 2016 8:29 pm Post subject: |
|
|
panraven wrote: | btw, 'for' loop should faster than 'while' loop ? remove from 'head' may need 'realloc' the mr list? |
al[0].destroy will destroy (currently first on the list) memrec and all its memrec children.
panraven wrote: | The script only work for ce 6.6, so added a version check, not sure what cause "Error:Unknown extension" |
"loadTable() can now also load from a Stream object" <-- this was added in CE6.6
panraven wrote: | I thought 'not merge' will remove previous mr |
It should. "not merge" doesn't work for stream version of this function. Looks like we missed this bug during alpha/beta tests.
_________________
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Wed Nov 09, 2016 9:38 pm Post subject: |
|
|
I see, learnt, thank you~
Is it possible to make ct file the compression/decompression internal (not via Lua), automatic and transparent from user? I means if it worth to be a CE standard feature.
_________________
- Retarded. |
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Wed Nov 09, 2016 10:09 pm Post subject: |
|
|
I see no reason why Dark Byte couldn't setup CE to read/write the XML table as a compressed stream.
May have some issues with backwards compatibility, unless he adds code to check whether the CT is compressed or not.
Or he could simply write the compressed bytes in ascii85, similar to attaching a table within a table.
Wrap it in an XML element and add special logic to decompress it before reading it as a normal <CheatTable>.
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Thu Nov 10, 2016 4:56 am Post subject: |
|
|
Yes, a choice of wrap table with compressed table, keep ct format, for when developer/user is saving is good.
Or may be yet another alternative format?
The save as exe with tiny for DS3.ct has a size 250k, cetrainer mode without protection has no compression, with protection has compression even down to 110k.
If there is a sub format of cetrainer saving that do compression but keep the memory record ui, may be a choice of the compact view mode, the user can still interact with the table.
_________________
- Retarded. |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Thu Nov 10, 2016 5:31 am Post subject: |
|
|
I prefer cheat tables to be readable by everyone
_________________
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 |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Thu Nov 10, 2016 6:30 am Post subject: |
|
|
@panraven, just curious, why pcall function?
I made tests and this also works as should:
Code: | {$Lua}
if not syntaxcheck then
if getCEVersion()<6.6 then error"Need CE 6.6+" end
local tblFileName='tablename.CT'
if not findTableFile(tblFileName) then
print("Can't find table file:"..tostring(tblFileName)..'.\nTry add it using MENU/Table/Add file')
else
createTimer().OnTimer = function (t)
t.destroy()
local al = getAddressList()
while al.Count>0 do al[0].destroy() end
loadTable(findTableFile(tblFileName).Stream, false, false)
end
end
end
{$Asm}
[ENABLE]
[DISABLE]
|
_________________
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Thu Nov 10, 2016 9:14 am Post subject: |
|
|
@DB
User should be able to 'read' the original ct once deployed.
Anyway. the compression saves transfer and storage, probably not important in most cases nowadays. May be only useful for someone host a collection of ct tables on server/cloud storage, whom may do the compression by their own.
@mgr.inz.Player
yes, it is not need, it is there probably I fear if something go wrong in the timer function, it will continue 'printing'. I make some clean up.
_________________
- Retarded. |
|
Back to top |
|
|
|