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 


Small problem with writeRegionToFile() ..

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
The Sage Of Time
How do I cheat?
Reputation: 0

Joined: 30 May 2005
Posts: 6

PostPosted: Tue Jan 13, 2015 9:44 pm    Post subject: Small problem with writeRegionToFile() .. Reply with quote

So I'm attempting to write a memory region to a file like so:

Code:
writeRegionToFile(getCheatEngineDir()..'data\\file.bin','["process.exe"+04D5B7F8]+40',4072)


This works perfectly, except that it only works once. For some reason it appears as though the Cheat Engine process locks the file after it writes it, making it so that the file can neither be overwritten or deleted until the cheat engine process is closed.. This wouldn't be an issue except that I kind of want to be able to overwrite the file at certain times (namely when the memory region has changed and the original contents of the file become obsolete.)

I realize I could write multiple files, but eventually with what I'm doing that would become really cluttered and fill my work directory with a lot of useless and\or redundant data..

So yeah, is there a quick and easy way to force Cheat Engine to release the file so that it can be overwritten?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Wed Jan 14, 2015 4:48 am    Post subject: Reply with quote

no real fix, but you could try readBytes using the table method, then convert it into a string and then use the io library of lua to write that to a disk
_________________
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
View user's profile Send private message MSN Messenger
The Sage Of Time
How do I cheat?
Reputation: 0

Joined: 30 May 2005
Posts: 6

PostPosted: Thu Jan 15, 2015 5:54 am    Post subject: Reply with quote

I feel kind of dumb for asking, but I'm kind of new to Lua. How would one convert a table object into a string?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Jan 15, 2015 6:09 am    Post subject: Reply with quote

you can use byteTableToString
Code:

a={}
a[1]=72
a[2]=101
a[3]=108
a[4]=108
a[5]=111

--or
--a=readBytes(address, 4072, true)

s=byteTableToString(a)

--or if you like to use pure lua:
--s=''
--for i=1,#a do
--  s=s..string.char(a[i])
--end

print(s)

_________________
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
View user's profile Send private message MSN Messenger
The Sage Of Time
How do I cheat?
Reputation: 0

Joined: 30 May 2005
Posts: 6

PostPosted: Thu Jan 15, 2015 6:14 am    Post subject: Reply with quote

Ah, snazzy! That's quite handy!
Yes this suits my needs perfectly then, thank you for your help!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Jan 15, 2015 6:18 am    Post subject: Reply with quote

and to write to disk:

Code:

f=io.open(getCheatEngineDir()..'data\\file.bin',"wb")
f:write(s)
f:close()

_________________
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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting 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