Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Simple CT Deploy script for Large Size file

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting -> Lua Extensions
View previous topic :: View next topic  
Author Message
panraven
Grandmaster Cheater
Reputation: 26

Joined: 01 Oct 2008
Posts: 652

PostPosted: Wed Nov 09, 2016 4:28 pm    Post subject: Simple CT Deploy script for Large Size file This post has 1 review(s) Reply with quote

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~



ds3zip.CT
 Description:
sample, don't use the attach script, but c & p above script

Download
 Filename:  ds3zip.CT
 Filesize:  138.62 KB
 Downloaded:  534 Time(s)


_________________
- Retarded.
dropbox


Last edited by panraven on Thu Nov 10, 2016 9:12 am; edited 5 times in total
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 148

Joined: 07 Nov 2008
Posts: 4173
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Wed Nov 09, 2016 7:30 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
panraven
Grandmaster Cheater
Reputation: 26

Joined: 01 Oct 2008
Posts: 652

PostPosted: Wed Nov 09, 2016 7:49 pm    Post subject: Reply with quote

@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.
dropbox
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 148

Joined: 07 Nov 2008
Posts: 4173
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Wed Nov 09, 2016 8:29 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
panraven
Grandmaster Cheater
Reputation: 26

Joined: 01 Oct 2008
Posts: 652

PostPosted: Wed Nov 09, 2016 9:38 pm    Post subject: Reply with quote

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.
dropbox
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 119

Joined: 09 Jun 2013
Posts: 3231

PostPosted: Wed Nov 09, 2016 10:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 26

Joined: 01 Oct 2008
Posts: 652

PostPosted: Thu Nov 10, 2016 4:56 am    Post subject: Reply with quote

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.
dropbox
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 338

Joined: 09 May 2003
Posts: 19895
Location: The netherlands

PostPosted: Thu Nov 10, 2016 5:31 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message MSN Messenger
mgr.inz.Player
I post too much
Reputation: 148

Joined: 07 Nov 2008
Posts: 4173
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Thu Nov 10, 2016 6:30 am    Post subject: Reply with quote

@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
View user's profile Send private message MSN Messenger
panraven
Grandmaster Cheater
Reputation: 26

Joined: 01 Oct 2008
Posts: 652

PostPosted: Thu Nov 10, 2016 9:14 am    Post subject: Reply with quote

@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.
dropbox
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting -> Lua Extensions All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites