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 


How to use writeString with a memory record script?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
usernotfound
Expert Cheater
Reputation: 0

Joined: 21 Feb 2016
Posts: 115

PostPosted: Wed Dec 28, 2016 5:06 pm    Post subject: How to use writeString with a memory record script? Reply with quote

I'm not familiar using memory records with Lua so not sure what function to look for, I want to change a string defined in an AA script with the editbox object like so

Code:
define(Example,StringToChange)


Normally I'd just use string.format with a variable for the editbox value (or using writeString in the editbox function) but how would I write to that value without it being in the Lua script?
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 62

Joined: 01 Oct 2008
Posts: 958

PostPosted: Wed Dec 28, 2016 6:59 pm    Post subject: Reply with quote

Since you mention EditBox, Lua script seems necessary if I'm not misunderstood.

In UI/Trainer Lua code, should run before AA script below
Code:

...
local symbol, maxLength = "MyString", 0x200
local isUnicode = false
-- ^ setup the String symbol

s2bt = isUnicode and wideStringToByteTable or stringToByteTable
if isUnicode then maxLength = maxLength * 2 end
MYScript = string.format("globalalloc(%s,%d)",symbol,maxLength)

function CEEdit1Change(sender)
  local str = sender.Text
  if MYScript and not readInteger(symbol) then
    autoAssemble(MYScript)
  end
  if readInteger(symbol) then
    str = str:sub(1,maxLength-1)..string.char(0) -- zero terminated

    GetMainForm().Caption = str  -- just for test, should remove

    writeBytes(symbol,s2bt(str))
  end
end
...



In AA script
Code:

...
{$lua}
if MYScript then return MYScript end  -- will not execute if MYScript not yet defined
{$asm}
...
mov  esi,MyString //  set your EditBox connected String Pointer
mov  edi,[ebx+120]

@@:  // sample copy code, not tested
mov  al,[esi]   // use ax and edi+2 -> edi for unicode
mov  [edi],al
inc  edi
inc  esi
test al,al           
jne  @b
...

_________________
- Retarded.
Back to top
View user's profile Send private message
usernotfound
Expert Cheater
Reputation: 0

Joined: 21 Feb 2016
Posts: 115

PostPosted: Thu Dec 29, 2016 1:52 am    Post subject: Reply with quote

Thanks panraven, I think I will just stick to using the autoAssemble function in Lua for now. Memory records are a bit complicated for me at the moment
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