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 


Is there a global storage where I can save large Strings?

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

Joined: 15 Feb 2022
Posts: 7

PostPosted: Tue Feb 15, 2022 6:04 pm    Post subject: Is there a global storage where I can save large Strings? Reply with quote

I wrote a Lua block in a code injection script which parses a JSON file ( contains some configuration) from Disk and then it does update values, depending on some pointer data and the config.

It's working great but I dislike its loading the file each time the code is triggered. So I wondered if there is a way to store the JSON string somehow and only load the file, if the JSON string is not stored yet.

I noticed there is a method
[code]
writeStringLocal
[/code]

But I didn't quite understand if this is meant for my use case? Can I use this method for storing big strings?

Also I did not understand how this address thing works. Is it safe to write to any address like [code]writeStringLocal("00400500", JsonString)[/code] or could this memory address be in use already?

Sincerely
Pie
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 204

Joined: 25 Jan 2006
Posts: 8581
Location: 127.0.0.1

PostPosted: Tue Feb 15, 2022 8:31 pm    Post subject: This post has 1 review(s) Reply with quote

Just read the file into a local variable and check that variable if it's got any data anytime you need to use the information. If not, then reload, if yes, then use what's already loaded.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
HotPieOnARack
How do I cheat?
Reputation: 0

Joined: 15 Feb 2022
Posts: 7

PostPosted: Wed Feb 16, 2022 11:13 am    Post subject: Reply with quote

atom0s wrote:
Just read the file into a local variable and check that variable if it's got any data anytime you need to use the information. If not, then reload, if yes, then use what's already loaded.


You're right...
I didn't knew non-local variables are surviving when defined in a Lua code block.

I thought they'd reset after the code Injection returned.

Thank you.
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 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