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 


Memory Record Changing To Nil After Restart

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
sugarcool
How do I cheat?
Reputation: 0

Joined: 21 Jun 2021
Posts: 3

PostPosted: Mon Jun 21, 2021 4:02 pm    Post subject: Memory Record Changing To Nil After Restart Reply with quote

Every time I save and close my cheat engine table when I reopen it my custom address seems to be set to nil. It's still recognized as existing however it's nil. The only workaround I found so far was to create new addresses that haven't existed yet. Afterwards, the address is still stored but the value is "???". I've tried a workaround when checking if the value is nil it will rewrite the address to float 1.5, and in the meantime set speed to 15, however, that doesn't work either and the value remains "???" or nil but the address still is continuing to be stored.

Currently, due to this problem, this code gives me an "attempt to perform arithmetic on a nil value" at line 17.

Code:

{$lua}
local al = getAddressList()
local x = al.getMemoryRecordByDescription("LPVelX")
local y = al.getMemoryRecordByDescription("LPVelY")
local z = al.getMemoryRecordByDescription("LPVelZ")

local SpeedAddress = "ElytraSpeed"

[ENABLE]
if not getAddressSafe(SpeedAddress) then
  local addr = allocateMemory(4)
  registerSymbol(SpeedAddress, addr)
  writeFloat(SpeedAddress, 1.5)
end

local speed = readFloat(getAddressSafe(SpeedAddress))

x.Value = x.Value * speed
y.Value = y.Value * speed
z.Value = z.Value * speed
 
[DISABLE]
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: Tue Jun 22, 2021 12:29 am    Post subject: Reply with quote

how do you update/initialize the address of ElytraSpeed ?
_________________
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
sugarcool
How do I cheat?
Reputation: 0

Joined: 21 Jun 2021
Posts: 3

PostPosted: Tue Jun 22, 2021 6:27 am    Post subject: Reply with quote

Dark Byte wrote:
how do you update/initialize the address of ElytraSpeed ?


I don't know what this means but currently, I just put a manual address with the address "ElytraSpeed". It works the first time around but when I save and reopen the cheat table it breaks. Also wouldn't the first part of the code initialize it if it doesn't exist?
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: Tue Jun 22, 2021 8:39 am    Post subject: Reply with quote

ok I see how it gets used

Try keeping track of the processid

e.g
Code:

if myscript==nil then
  myscript={} --not local
end


if myscript.processid~=getOpenedProcessID() then 
  unregisterSymbol(SpeedAddress)
  local addr = allocateMemory(4)
  registerSymbol(SpeedAddress, addr)
  writeFloat(SpeedAddress, 1.5)
  myscript.processid=getOpenedProcessID()
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
Back to top
View user's profile Send private message MSN Messenger
sugarcool
How do I cheat?
Reputation: 0

Joined: 21 Jun 2021
Posts: 3

PostPosted: Tue Jun 22, 2021 2:01 pm    Post subject: Reply with quote

Oh ok. I ended up finding a fix of unRegistering the symbol when it's nil and registering it again. Thank you, I didn't know it would change base on processId or that processId even existed.

Dark Byte wrote:
ok I see how it gets used

Try keeping track of the processid

e.g
Code:

if myscript==nil then
  myscript={} --not local
end


if myscript.processid~=getOpenedProcessID() then 
  unregisterSymbol(SpeedAddress)
  local addr = allocateMemory(4)
  registerSymbol(SpeedAddress, addr)
  writeFloat(SpeedAddress, 1.5)
  myscript.processid=getOpenedProcessID()
end

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