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 do I write 2bytes (short integer) ?

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

Joined: 05 Nov 2014
Posts: 130

PostPosted: Sat Nov 19, 2016 4:36 am    Post subject: how do I write 2bytes (short integer) ? Reply with quote

I know the is writeInteger() for 4bytes and writeQword() for 8bytes, but how do I write 2bytes as a short integer without making use of the address list? and while we're at it, how do read 2bytes? (same questions for 1byte)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 342

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

PostPosted: Sat Nov 19, 2016 4:53 am    Post subject: Reply with quote

writeBytes(address, wordToByteTable(value))
byteTableToWord(readBytes(address, 2,true))

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.


Last edited by Dark Byte on Sat Nov 19, 2016 5:04 am; edited 2 times in total
Back to top
View user's profile Send private message MSN Messenger
LastExceed
Expert Cheater
Reputation: 1

Joined: 05 Nov 2014
Posts: 130

PostPosted: Sat Nov 19, 2016 4:54 am    Post subject: Reply with quote

Dark Byte wrote:
writeBytes(wordToByteTable(value))

Where do i specify the address?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 342

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

PostPosted: Sat Nov 19, 2016 5:04 am    Post subject: Reply with quote

fixed it
_________________
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: 4188
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Nov 19, 2016 7:24 am    Post subject: Reply with quote

Code:
function readWord(a)
  local lowerhalf,higherhalf = readBytes(a,2)
  return lowerhalf~=nil and ((higherhalf << 8) + lowerhalf) or nil
end

function writeWord(a,v)
  return writeBytes(a,v & 0xFF,v >> 8 & 0xff) > 0
end





or
Code:
function readWord(a)
  local bt = readBytes(a,2,true)
  return bt~=nil and byteTableToWord(bt) or nil
end

function writeWord(a,v)
  return writeBytes(a,wordToByteTable(v)) > 0
end



Code:
writeWord(address,value)
readWord(address)

_________________
Back to top
View user's profile Send private message MSN Messenger
cancandodo
How do I cheat?
Reputation: 0

Joined: 09 Mar 2012
Posts: 7

PostPosted: Thu Nov 02, 2017 10:01 am    Post subject: Reply with quote

function shuaxinClick(sender)
local bt=readBytes("[PrincessMaker.exe+AE6C8]+1ab",2,true)
control_setCaption(CETrainer.shengao,byteTableToWord(bt))
end

this code work correct!
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