Error referencing variable in Disable section

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Post Reply
User avatar
nihilism
Cheater
Cheater
Posts: 34
Joined: Thu Mar 29, 2018 1:28 am
Reputation: 3

Error referencing variable in Disable section

Post by nihilism » Mon Mar 16, 2020 8:50 pm

I'm getting an error when trying to destroy timer when script is disabled. What am I missing here?
Function works fine, variables read and write normally. Tested with print() and in game.
t_maxStack.destroy() line placed anywhere above '[DISABLE]' will allow script to save with no error.

Tried moving lua tag after enable and the asm tag just before disable with a separate lua tag in the disable followed by destroy line and get same error.

Image

Code provided below. playerBase is a registered symbol set by another script.

Code: Select all


{$STRICT}
{$lua}
[ENABLE]
 if syntaxcheck then return end
-- Function --
 setItemMax = function()
 local addrItem1 = '[[[["playerBase"+18]+30]+8]+8]+B8'
 local addrItem1Max = '[[[[[["playerBase"+18]+30]+8]+8]+B0]+8]+80'
 local numItem1 = readPointer(addrItem1)
 local numItem1Max = readInteger(addrItem1Max)
 if numItem1 == 0 then return else writeInteger(addrItem1,numItem1Max) end
 end

-- Timer --
 t_maxStack = createTimer()
 t_maxStack.Interval(100)
 t_maxStack.OnTimer = setItemMax()

[DISABLE]

 t_maxStack.destroy()


User avatar
GreenHouse
GreenHouse!
GreenHouse!
Posts: 417
Joined: Fri Oct 12, 2018 10:25 pm
Reputation: 348

Re: Error referencing variable in Disable section

Post by GreenHouse » Mon Mar 16, 2020 8:57 pm

Place {$lua} after [ENABLE], {$asm} before [DISABLE] and then {$lua} after [DISABLE].

Code: Select all

[ENABLE]
{$lua}
.
.
.
{$asm}
[DISABLE]
{$lua}
Image
You don't like feeling like you're staring at the sun when using the FearlessRevolution forum? Use my dark theme for Stylish/Stylus. Guaranteed satisfaction.
https://userstyles.org/styles/171116/fe ... ution-dark

User avatar
nihilism
Cheater
Cheater
Posts: 34
Joined: Thu Mar 29, 2018 1:28 am
Reputation: 3

Re: Error referencing variable in Disable section

Post by nihilism » Mon Mar 16, 2020 9:02 pm

nihilism wrote:
Mon Mar 16, 2020 8:50 pm
Tried moving lua tag after enable and the asm tag just before disable with a separate lua tag in the disable followed by destroy line and get same error.[/qoute]

User avatar
nihilism
Cheater
Cheater
Posts: 34
Joined: Thu Mar 29, 2018 1:28 am
Reputation: 3

Re: Error referencing variable in Disable section

Post by nihilism » Mon Mar 16, 2020 9:19 pm

Resolved.

It needed if syntaxcheck then return end again after disable section.

User avatar
GreenHouse
GreenHouse!
GreenHouse!
Posts: 417
Joined: Fri Oct 12, 2018 10:25 pm
Reputation: 348

Re: Error referencing variable in Disable section

Post by GreenHouse » Mon Mar 16, 2020 9:29 pm

Great :P
Image
You don't like feeling like you're staring at the sun when using the FearlessRevolution forum? Use my dark theme for Stylish/Stylus. Guaranteed satisfaction.
https://userstyles.org/styles/171116/fe ... ution-dark

Post Reply

Who is online

Users browsing this forum: No registered users