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 


Nesting Ifs Within a Checkbox Timer

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Reclaimer Shawn
Advanced Cheater
Reputation: 0

Joined: 09 Jun 2015
Posts: 77

PostPosted: Wed Aug 24, 2016 9:10 pm    Post subject: Nesting Ifs Within a Checkbox Timer Reply with quote

All of my other Cheat Engine statements just involve infinite writes seem to work. This code randomly generates values within a certain range and writes them to the game. When this code is ran, my trainer immediately closes. It also seems to close when using multiple timers as well.

Code:



Last edited by Reclaimer Shawn on Sat Aug 27, 2016 12:36 pm; edited 1 time in total
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Wed Aug 24, 2016 9:26 pm    Post subject: Reply with quote

Instead of continuing to add complexity to your script, why don't you fix whatever has been causing it to crash first.
Anyway, your IFs are wrong. Each IF requires an END. Don't just toss a bunch together until it stops giving you errors.
Back to top
View user's profile Send private message
Reclaimer Shawn
Advanced Cheater
Reputation: 0

Joined: 09 Jun 2015
Posts: 77

PostPosted: Wed Aug 24, 2016 10:15 pm    Post subject: Reply with quote

Zanzer wrote:
Instead of continuing to add complexity to your script, why don't you fix whatever has been causing it to crash first.
Anyway, your IFs are wrong. Each IF requires an END. Don't just toss a bunch together until it stops giving you errors.


My trainer still crashes. Here is all of the code so far:

Code:



In case you're wondering what I mean by "crash", my UDF1 form opens and then immediately closes. Works fine if I don,the include this or use it without ifs. It must be a scripting fault on my end somehow... To ask, if this code is right, then could it be a Form issue?


Last edited by Reclaimer Shawn on Sat Aug 27, 2016 12:36 pm; edited 1 time in total
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Thu Aug 25, 2016 1:52 am    Post subject: Reply with quote

first of all I'd recommend using lua tables (arrays) to avoid many copy-paste and many other simple typos, since you have many if and else's.
Now the checkbox function is less likely to be cause of the crash unless you call the checkbox function as soon as you start up, so if you try to define the checkbox function and it does not crashes then everything is fine, it's not that function that causing the trouble.

You will need to debug and see at which part it crashes.
About the script I wouldn't recommend is defining function inside of a function, as code function is being defined only as soon as you tick the checkbox, that means if you somehow try to call it earlier (e.g timer or start up script) it might crash or throw errors.

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
Reclaimer Shawn
Advanced Cheater
Reputation: 0

Joined: 09 Jun 2015
Posts: 77

PostPosted: Fri Aug 26, 2016 7:45 pm    Post subject: Reply with quote

DaSpamer wrote:
first of all I'd recommend using lua tables (arrays) to avoid many copy-paste and many other simple typos, since you have many if and else's.
Now the checkbox function is less likely to be cause of the crash unless you call the checkbox function as soon as you start up, so if you try to define the checkbox function and it does not crashes then everything is fine, it's not that function that causing the trouble.

You will need to debug and see at which part it crashes.
About the script I wouldn't recommend is defining function inside of a function, as code function is being defined only as soon as you tick the checkbox, that means if you somehow try to call it earlier (e.g timer or start up script) it might crash or throw errors.


Figured out my problem... I was using an extra parenthesis in the if statements... That was IT. I feel a bit dumb now.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Fri Aug 26, 2016 7:58 pm    Post subject: Reply with quote

Yea... that was not the problem.

As long as there's both an opening and closing, it doesn't matter how many parenthesis you throw in there.
Code:
myvar = true
if ((myvar) == true) then
  print("1")
end
if (((((((myvar)))) == ((true))))) then
  print("2")
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