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 


Error when setting interval

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

Joined: 27 Jan 2023
Posts: 2

PostPosted: Tue Feb 14, 2023 11:15 am    Post subject: Error when setting interval Reply with quote

Code:
local function TriggerBot()
     if readInteger("agame.exe+61B82C") == 2 then
          mouse_event(MOUSEEVENTF_LEFTDOWN, nil, nil, nil, nil)
          mouse_event(MOUSEEVENTF_LEFTUP, nil, nil, nil, nil)
     end
end
someTimer = createTimer()
someTimer.Interval = 100
someTimer.OnTimer = timer_tick

the line
Code:
someTimer.Interval = 100

gives me the error
Quote:
Error:[string "local function TriggerBot()..."]:8: attempt to index global 'someTimer' (a nil value)

and i searched for the error and didnt find any solution.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1533

PostPosted: Tue Feb 14, 2023 12:22 pm    Post subject: Reply with quote

I did not receive an error message. Try this.

If a global (local) or "nil" is set within the same CE window, clearing the lua window will not ignore these locales and will still work.

Turn the CE off and then back on to try the code. So the previous assigned locals won't bother you.

Code:
local function TriggerBot()
     if readInteger("agame.exe+61B82C") == 2 then
          mouse_event(MOUSEEVENTF_LEFTDOWN, nil, nil, nil, nil)
          mouse_event(MOUSEEVENTF_LEFTUP, nil, nil, nil, nil)
     end
end

if someTimer then someTimer.Destroy() someTimer=nil end
someTimer = createTimer()
someTimer.Interval = 100
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
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4715

PostPosted: Tue Feb 14, 2023 12:49 pm    Post subject: Reply with quote

Did you overwrite the createTimer function somewhere? Maybe in the autorun directory?

Are you executing that code in a separate thread? (use `print(tostring(inMainThread()))`)

`timer_tick` isn't defined, and `TriggerBot` isn't used. If that isn't the full script, there might be an error elsewhere.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
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