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 1, 2  Next
 
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: Fri Dec 10, 2021 8:14 pm    Post subject: help converting this script to write big endian value Reply with quote

Hey everyone

i use this script to write float value before now im dealing with emulator and idk how modfiy it

i need to write float big endian or 4 byte big endian

Code:

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

DoneState = false
local addr = 0x1b7F5410C
local val = 1
local function timer_tick(timer)
  writeFloat(addr, val + readFloat(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


i really appreciate the help Rolling Eyes
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: Sat Dec 11, 2021 1:34 am    Post subject: Reply with quote

use something like: (untested, on my phone)
Code:

function writeBigEndianFloat(address, number)
  local bt=floatToByteTable(number)
  local newbt={}
  for i=1,4 do
    newbt[5-i]=bt[i]
  end
  writeByteTable(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

_________________
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


Last edited by Dark Byte on Sun Dec 12, 2021 3:30 pm; edited 1 time in total
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: Sat Dec 11, 2021 4:52 am    Post subject: Reply with quote

Dark Byte wrote:
use something like: (untested, on my phone)
Code:

function writeBigEndianFloat(address, number)
  local bt=floatToByteTable(number)
  local newbt={}
  for i=1,4 do
    newbt[5-i]=bt[i]
  end
  writeByteTable(address, newbt)
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


thanks for response

sorry im not knowledge with reading scripts and what they mean

i just put it with my script and it write normal float valve

i know im doing it wrong , please tell me where i put the address 0x2C7F7F244 and the value 1 like my original script




Code:


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

DoneState = false
local addr = 0x2C7F7F244
local val = 1
local function timer_tick(timer)
  writeFloat(addr, val + readFloat(addr))
  -- writeFloat(addr, val + readFloat(addr))
  if DoneState == true then
    timer.destroy()
  end
end


function writeBigEndianFloat(address, number)
  local bt=floatToByteTable(number)
  local newbt={}
  for i=1,4 do
    newbt[5-i]=bt[i]
  end
  writeByteTable(address, newbt)
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
local someTimer = createTimer(MainForm)
someTimer.Interval = 500
someTimer.OnTimer = timer_tick

[DISABLE]

DoneState = true


appreciate your time
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Sat Dec 11, 2021 6:04 am    Post subject: Reply with quote

You will want to use the writeBigEndianFloat function instead of writeFloat, so instead of:
Code:

writeFloat(addr, val + readFloat(addr))

use this:
Code:

writeBigEndianFloat(addr, val + readFloat(addr))
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: Sat Dec 11, 2021 6:13 am    Post subject: Reply with quote

and put the functions before your writeFloat code, not after
_________________
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: Sat Dec 11, 2021 10:45 am    Post subject: Reply with quote

LeFiXER wrote:
You will want to use the writeBigEndianFloat function instead of writeFloat, so instead of:
Code:

writeFloat(addr, val + readFloat(addr))

use this:
Code:

writeBigEndianFloat(addr, val + readFloat(addr))


Dark Byte wrote:
and put the functions before your writeFloat code, not after


ok this how i put it and gave me 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
  writeByteTable(address, newbt)
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 + readFloat(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



C2.png
 Description:
 Filesize:  15.08 KB
 Viewed:  2399 Time(s)

C2.png



C1.png
 Description:
 Filesize:  81.22 KB
 Viewed:  2399 Time(s)

C1.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: Sat Dec 11, 2021 11:24 am    Post subject: Reply with quote

replace writeByteTable with writeBytes(address,bytetable,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
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Sat Dec 11, 2021 11:25 am    Post subject: Reply with quote

I believe line 11 should be:
Code:

writeBytes(address, newbt)
Back to top
View user's profile Send private message
SS 4K
Newbie cheater
Reputation: 0

Joined: 21 Feb 2019
Posts: 21

PostPosted: Sat Dec 11, 2021 2:04 pm    Post subject: Reply with quote

Dark Byte wrote:
replace writeByteTable with writeBytes(address,bytetable,true)


no error this time but now script just keep set in the value to 0 instead of adding 1 overtime

LeFiXER wrote:
I believe line 11 should be:
Code:

writeBytes(address, newbt)


value now not increasing with your code just keeping it 1

my goal is to make the script keep adding 1 value not to set it 1
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Sat Dec 11, 2021 5:03 pm    Post subject: Reply with quote

Another perspective..

Code:
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))

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
SS 4K
Newbie cheater
Reputation: 0

Joined: 21 Feb 2019
Posts: 21

PostPosted: Sat Dec 11, 2021 7:03 pm    Post subject: Reply with quote

AylinCE wrote:
Another perspective..

Code:
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))


i tried it and write normal float just like my original script


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)
  writeFloat(addr, val + readFloat(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
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Sun Dec 12, 2021 2:25 am    Post subject: Reply with quote

you're not using the functions
_________________
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:18 am    Post subject: Reply with quote

Dark Byte wrote:
you're not using the functions


can you please correct it and post the full script , so i don't have to adjust something that I don't know
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 2:22 pm    Post subject: Reply with quote

replace writeFloat AND readFloat with the bigendian versions
_________________
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
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

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

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

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
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 1, 2  Next
Page 1 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