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 


help converting this script to write big endian value
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
SS 4K
Newbie cheater
Reputation: 0

Joined: 21 Feb 2019
Posts: 21

PostPosted: Sun Dec 12, 2021 3:29 pm    Post subject: Reply with quote

Dark Byte wrote:
replace writeFloat AND readFloat with the bigendian versions


i appreciate you being patient with me

i replaced writeFloat AND readFloat with the big endian

now it gives error

Code:

{$lua}
if syntaxcheck then return end
[ENABLE]

function writeBigEndianFloat(address, number)
  local bt=floatToByteTable(number)
  local newbt={}
  for i=1,4 do
    newbt[5-i]=bt[i]
  end
  writeBytes(address,bytetable,true)

end

function readBigEndianFloat(address)
  local bbt=readBytes(address,4)
  local newbt={}
  for i=1,4 do
    newbt[5-i]=bbt[i]
  end
  return byteTableToFloat(newbt)
end

DoneState = false
local addr = 0x2C7F7F244
local val = 1
local function timer_tick(timer)
  writeBigEndianFloat(addr, val + readBigEndianFloat(addr))
  -- writeFloat(addr, val + readFloat(addr))
  if DoneState == true then
    timer.destroy()
  end
end
local someTimer = createTimer(MainForm)
someTimer.Interval = 500
someTimer.OnTimer = timer_tick

[DISABLE]

DoneState = true



C4.png
 Description:
 Filesize:  19.54 KB
 Viewed:  1038 Time(s)

C4.png



C3.png
 Description:
 Filesize:  55.86 KB
 Viewed:  1038 Time(s)

C3.png


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: Sun Dec 12, 2021 3:30 pm    Post subject: Reply with quote

change readBytes(address,4) to readBytes(address,4, true)
_________________
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
SS 4K
Newbie cheater
Reputation: 0

Joined: 21 Feb 2019
Posts: 21

PostPosted: Sun Dec 12, 2021 3:38 pm    Post subject: Reply with quote

Dark Byte wrote:
change readBytes(address,4) to readBytes(address,4, true)


timer works now but the value keeps writing 0

Code:

{$lua}
if syntaxcheck then return end
[ENABLE]

function writeBigEndianFloat(address, number)
  local bt=floatToByteTable(number)
  local newbt={}
  for i=1,4 do
    newbt[5-i]=bt[i]
  end
  writeBytes(address,bytetable,true)

end

function readBigEndianFloat(address)
  local bbt=readBytes(address,4, true)
  local newbt={}
  for i=1,4 do
    newbt[5-i]=bbt[i]
  end
  return byteTableToFloat(newbt)
end

DoneState = false
local addr = 0x2C7F7F244
local val = 4
local function timer_tick(timer)
  writeBigEndianFloat(addr, val + readBigEndianFloat(addr))
  -- writeFloat(addr, val + readFloat(addr))
  if DoneState == true then
    timer.destroy()
  end
end
local someTimer = createTimer(MainForm)
someTimer.Interval = 500
someTimer.OnTimer = timer_tick

[DISABLE]

DoneState = true





AylinCE wrote:
Code:
local addr = 0x2C7F7F244
local val = -1
local function timer_tick(timer)
  local result = writeBigEndianFloat(addr, val + readBigEndianFloat(addr))
--print("res: ".. result)
  -- writeFloat(addr, val + readFloat(addr))
  if DoneState == true then
    timer.destroy()
  end
return result
end
local someTimer = createTimer(MainForm)
someTimer.Interval = 500
someTimer.OnTimer = timer_tick


AylinCE it doesn't write any value with yours script

also i tried to change readBytes(address,4) to readBytes(address,4, true)



Code:

{$lua}
if syntaxcheck then return end
[ENABLE]

function writeBigEndianFloat(address, number, format)
  local bt="" --floatToByteTable(number)

  if format == true then
  bt=floatToByteTable(number)
  end

  if format == false then
  bt={floatToByteTable(number)}
  end

  local newbt={}

  for i=1,4 do
    if format == true then
    newbt[5-i]=bt[i] end

    if format == false then
    newbt[i]=bt[i]
    --print(bt[i])
     end
  end
  return writeBytes(address, newbt)
end

function readBigEndianFloat(address,format)
  local bbt={readBytes(address,4)}
  --for i,k in ipairs(bbt) do
  --print("bbt:"..k) end
  local newbt1={}

  if format == true then
    for i=1,4 do
    newbt1[5-i]=bbt[i]
    end
  end

  if format == false then
    for i=1,4 do
    newbt1[i]=bbt[i]
    end
  end

  return byteTableToFloat(newbt1)
end


print("wf-f: "..writeBigEndianFloat(0x1E2EDFE4C0, 1200, false))

print("rf-f: "..readBigEndianFloat(0x1E2EDFE4C0, false))


print("wf-t: "..writeBigEndianFloat(0x1E2EDFE4C0, 1200, true))

print("rf-t: "..readBigEndianFloat(0x1E2EDFE4C0, true))

DoneState = false
local addr = 0x2C7F7F244
local val = 1
local function timer_tick(timer)
  local result = writeBigEndianFloat(addr, val + readBigEndianFloat(addr))
--print("res: ".. result)
  -- writeFloat(addr, val + readFloat(addr))
  if DoneState == true then
    timer.destroy()
  end
return result
end
local someTimer = createTimer(MainForm)
someTimer.Interval = 500
someTimer.OnTimer = timer_tick

[DISABLE]

DoneState = true
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: Mon Dec 13, 2021 4:59 am    Post subject: Reply with quote

it's writeBytes(address,newbt)
_________________
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
SS 4K
Newbie cheater
Reputation: 0

Joined: 21 Feb 2019
Posts: 21

PostPosted: Mon Dec 13, 2021 11:19 am    Post subject: Reply with quote

Dark Byte wrote:
it's writeBytes(address,newbt)


OMG thank you so much

it works now

Code:
(address,newbt)
give error at the start but i put space before newbt just like @LeFiXER post and it work now
Code:
(address, newbt)


now i just need one last thing to modify from this script is to write 4 Byte Big Endian instead Float Big Endian

what should I change from this 👇

Code:
{$lua}
if syntaxcheck then return end
[ENABLE]

function writeBigEndianFloat(address, number)
  local bt=floatToByteTable(number)
  local newbt={}
  for i=1,4 do
    newbt[5-i]=bt[i]
  end
  writeBytes(address, newbt)

end

function readBigEndianFloat(address)
  local bbt=readBytes(address,4, true)
  local newbt={}
  for i=1,4 do
    newbt[5-i]=bbt[i]
  end
  return byteTableToFloat(newbt)
end

DoneState = false
local addr = 0x2C7F7F244
local val = 1
local function timer_tick(timer)
  writeBigEndianFloat(addr, val + readBigEndianFloat(addr))
  -- writeFloat(addr, val + readFloat(addr))
  if DoneState == true then
    timer.destroy()
  end
end
local someTimer = createTimer(MainForm)
someTimer.Interval = 500
someTimer.OnTimer = timer_tick

[DISABLE]

DoneState = true
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
Goto page Previous  1, 2
Page 2 of 2

 
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