| View previous topic :: View next topic |
| Author |
Message |
Zephiles Advanced Cheater
Reputation: 0
Joined: 04 Feb 2016 Posts: 56
|
Posted: Fri Aug 05, 2016 7:31 am Post subject: Need Lua Script Help |
|
|
I'm trying to modify a Lua script that Zanzer made, but I'm having some issues.
| Code: | if timer1 then timer1.destroy() end
timer1 = createTimer()
timer1.Interval = 5
timer1.OnTimer = function(timer)
local b = errorOnLookupFailure(false)
local address = 86016
local start = readInteger("7fff0000+418970")
if start then
local DynamicAddress = readInteger("start-ffd8")
if DynamicAddress then
if readInteger("DynamicAddress") == 0 then
DynamicAddress = readInteger("start-ffc8")
end
address = DynamicAddress
end
end
if address and (address > 86016) then
if address ~= old_address then
old_address = address
address = string.format("%X", address)
local reverse = ""
for byte in string.gmatch(address, "..") do
reverse = byte .. reverse
end
unregisterSymbol("Enemy1HPInScript")
registerSymbol("Enemy1HPInScript", tonumber(reverse, 16))
end
else
unregisterSymbol("Enemy1HPInScript")
registerSymbol("Enemy1HPInScript", tonumber(86016))
end
errorOnLookupFailure(b)
end |
What is supposed to happen is: (I also need to point out that these addresses are in Big Endian format)
The value at address 7fff0000+418970 is put into start. If the value stored there is not nil, then the value of the address start-ffd8 is put into DynamicAddress. If the value stored at DynamicAddress is not nil, then the value at DynamicAddress should be checked to see if it's 0 or not. If it's 0, then the value of address start-ffc8 (Which is also DynamicAddress-10) is put into DynamicAddress. Once this is done, address is assigned the value of DynamicAddress. Everything after "if address and (address > 86016) then" should work correctly, so the parts above it are the issue. Whenever I execute this script, the outputted value is always 86016, regardless of the other values.
I'll also provide an example of what is happening in the game:
The value at 7fff0000+418970 is 80CD9180, and is assigned to start. Next, the value at address 80CD9180-ffd8 is checked, which has a value of 0, and is assigned to DynamicAddress. Since the value is not nil but it is 0, the value at start-ffc8 is checked, which has a value of 810351C0, and is assigned to DynamicAddress.
I believe that since the addresses are in Big Endian format, then I need to make use of the code that reverses the byte order, but I'm not sure if I know how to properly implement this. So could anyone help me with this? And if that's not what needs to be done, can someone help me with what the real problem is?
|
|
| Back to top |
|
 |
cooleko Grandmaster Cheater
Reputation: 11
Joined: 04 May 2016 Posts: 717
|
Posted: Fri Aug 05, 2016 3:03 pm Post subject: |
|
|
LUA
| Code: | v=1008414272
print(string.format("%X",v))
print(string.format("%X",((v & 0xff) << 24) | ((v & 0xff00) << 8) | ((v & 0xff0000) >> 8 ) | (v >> 24))) |
| Code: | function SwapE(v)
return(((v & 0xff) << 24) | ((v & 0xff00) << 8) | ((v & 0xff0000) >> 8 ) | (v >> 24))
end |
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Fri Aug 05, 2016 5:55 pm Post subject: |
|
|
| Code: | | readInteger(start - 0xffd8) |
|
|
| Back to top |
|
 |
Zephiles Advanced Cheater
Reputation: 0
Joined: 04 Feb 2016 Posts: 56
|
Posted: Fri Aug 05, 2016 6:40 pm Post subject: |
|
|
So this is what I currently have:
| Code: | function SwapE(v)
return(((v & 0xff) << 24) | ((v & 0xff00) << 8) | ((v & 0xff0000) >> 8 ) | (v >> 24))
end
if timer1 then timer1.destroy() end
timer1 = createTimer()
timer1.Interval = 5
timer1.OnTimer = function(timer)
local z = errorOnLookupFailure(false)
local address = 86016
local start = readInteger("7fff0000+418970")
if start then
start = SwapE(start)
local DynamicAddress = readInteger(start-0xffd8)
if DynamicAddress then
if readInteger("DynamicAddress") == 0 then
DynamicAddress = readInteger(start-0xffc8)
end
address = DynamicAddress
end
end
if address and (address > 86016) then
if address ~= old_address then
old_address = address
address = string.format("%X", address)
local reverse = ""
for byte in string.gmatch(address, "..") do
reverse = byte .. reverse
end
unregisterSymbol("Enemy1HPInScript")
registerSymbol("Enemy1HPInScript", tonumber(reverse, 16))
end
else
unregisterSymbol("Enemy1HPInScript")
registerSymbol("Enemy1HPInScript", tonumber(86016))
end
errorOnLookupFailure(z)
end |
As of right now, this does not work correctly. Whenever I execute it, the value that is outputted is always 86016, regardless of what values are at the addresses above.
Can someone actually tell me how to fix this, instead of just putting blocks of code?
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Fri Aug 05, 2016 7:04 pm Post subject: |
|
|
| Code: | | readInteger(DynamicAddress) |
|
|
| Back to top |
|
 |
Zephiles Advanced Cheater
Reputation: 0
Joined: 04 Feb 2016 Posts: 56
|
Posted: Fri Aug 05, 2016 7:09 pm Post subject: |
|
|
| Changing that made it work until the first DynamicPointer changed to 0. After that it stayed at 86016 again.
|
|
| Back to top |
|
 |
cooleko Grandmaster Cheater
Reputation: 11
Joined: 04 May 2016 Posts: 717
|
Posted: Fri Aug 05, 2016 7:39 pm Post subject: |
|
|
Judiciously implement print() in your script. Debug line by line for what you expect to happen vs what does happen until you find your error. We cannot replicate your script without installing your game and trying ourselves.
print(string.format("%X",ADDRESS)) will print the hex version of address, use for any variables you want to see the hex of.
|
|
| Back to top |
|
 |
Zephiles Advanced Cheater
Reputation: 0
Joined: 04 Feb 2016 Posts: 56
|
Posted: Fri Aug 05, 2016 8:05 pm Post subject: |
|
|
OK I finally figured out the problem. The issue was this line:
| Code: | | if readInteger("DynamicAddress") == 0 then |
Changing it to the following made the script work:
| Code: | | if DynamicAddress == 0 then |
|
|
| Back to top |
|
 |
|