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 read/write signed 1 byte value with edit box?

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

Joined: 17 Jan 2018
Posts: 205

PostPosted: Wed Oct 02, 2019 4:48 am    Post subject: How to read/write signed 1 byte value with edit box? Reply with quote

How to read/write signed 1 and 3 byte value with edit box CEEdit?
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Wed Oct 02, 2019 2:51 pm    Post subject: Reply with quote

The simplest way is to add it to the address list and do
Code:
CEEdit1MR = AddressList.getMemoryRecordByDescription("Name of memory record")
if not CEEdit1MR then print("Failed to find memory record for CEEdit1MR")
else
CEEdit1UpdateTimer = createTimer()
CEEdit1UpdateTimer.Interval = 1000 -- update once a second
CEEdit1UpdateTimer.OnTimer = function(t)
  CETrainer.CEEdit1.Text = CEEdit1MR.Value
end

-- called when the user presses enter
CETrainer.CEEdit1.OnEnter = function(sender)
  CEEdit1MR.Value = CETrainer.CEEditBox1.Text -- or sender.Text
end
end


Those could be set in the gui editor in which case it'd look more like
Code:

function CETrainer_CEEdit1Enter(sender)
  ...
end
just because that's how the event handlers are named by default (form_name_event_without_on) and the gui sets the function based on the name in the trainer rather than assigning the function directly with lua.

there's also readBytes(address,numBytes) and writeBytes(address,numBytes) if you want to do it yourself for whatever reason.

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 205

PostPosted: Thu Oct 03, 2019 11:51 pm    Post subject: Reply with quote

Used the following code to read 1 byte signed value:
Code:
  local val = readBytes(addr)
  if val > 127 then
  UDF1.CEEdit1.Text = val - 256
  else
  UDF1.CEEdit1.Text = val
  end

By default, CEEdit1 can also write the value as signed. So, you do not need to write special code for that.
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