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 


stop lua script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions
View previous topic :: View next topic  
Author Message
Meiyoh
Master Cheater
Reputation: 1

Joined: 14 Mar 2015
Posts: 402

PostPosted: Thu May 19, 2016 3:21 pm    Post subject: stop lua script Reply with quote

Ok so how I stop my script which copies bytes from one address to another?

I can't stop it . closing the script that enables the address causes cheat engine to SAY "Stack overflow" and then It crashes.

Now I have to reset my game to be able to continue

Everything I found for information doesn't stop the script from running.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4700

PostPosted: Thu May 19, 2016 4:29 pm    Post subject: Reply with quote

Code:
timer.Enabled = false

If you want any more help than that, post your script. At the very least tell us if you're using Lua or asm.

_________________
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
Meiyoh
Master Cheater
Reputation: 1

Joined: 14 Mar 2015
Posts: 402

PostPosted: Thu May 19, 2016 11:42 pm    Post subject: Reply with quote

Thank you very much.

t = createTimer()
t.Interval = 1000
t.OnTimer = function(sender)
local v = readBytes("EnemyData", 4, true)
writeBytes("EnemyData2", v)
local v = readBytes("EnemyData3", 4, true)
writeBytes("EnemyData+4", v)
local v = readBytes("EnemyData+8", 4, true)
writeBytes("PCHealth", v)
end

How can I make this script run and stop when those EnemyData address pointers stop working Eg the source address pointer stops working or is closed and displays ?? value to prevent script from crashing cheat engine.
Also I want to make this work on a Kyes press example Shift+4 ON, And Shift+5 Off - manually aside from the function which checks if the addresses have valid pointers (not ?? Value) .
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4700

PostPosted: Thu May 19, 2016 11:50 pm    Post subject: Reply with quote

Use the Enabled property like I showed, except use t for the variable instead of timer.
readBytes won't return anything if it doesn't successfully read from it, so just use an if statement and check if v is defined after each call to readBytes. If it's not defined, then disable the timer and return.
Use the GenericHotkey class to use hotkeys. See main.lua for documentation and use google for examples.

_________________
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
Meiyoh
Master Cheater
Reputation: 1

Joined: 14 Mar 2015
Posts: 402

PostPosted: Fri May 20, 2016 1:50 am    Post subject: Reply with quote

ParkourPenguin wrote:
Use the Enabled property like I showed, except use t for the variable instead of timer.
readBytes won't return anything if it doesn't successfully read from it, so just use an if statement and check if v is defined after each call to readBytes. If it's not defined, then disable the timer and return.
Use the GenericHotkey class to use hotkeys. See main.lua for documentation and use google for examples.


nah... I am stuck here
care to make an example especially the part with the IF V is defined.
Thank you.

Really need to start reading tutorials. I am good at finding stuff not scripting but that must change thanks to people like you.

Appreciate your help a lot.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4700

PostPosted: Fri May 20, 2016 8:47 am    Post subject: Reply with quote

Code:
local v = readBytes("EnemyData", 4, true)
if not v then  -- alternatively: if v == nil then
  sender.Enabled = false
  return
end

PS: you only have to put local on the first declaration of the same variable, not every assignment. AKA, you only need to have "local v = ..." on the first one. Everything else you can have "v = ...".

_________________
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
Meiyoh
Master Cheater
Reputation: 1

Joined: 14 Mar 2015
Posts: 402

PostPosted: Fri May 20, 2016 11:04 am    Post subject: Reply with quote

ParkourPenguin wrote:
Code:
local v = readBytes("EnemyData", 4, true)
if not v then  -- alternatively: if v == nil then
  sender.Enabled = false
  return
end

PS: you only have to put local on the first declaration of the same variable, not every assignment. AKA, you only need to have "local v = ..." on the first one. Everything else you can have "v = ...".


Thank you! Real people here real developers and people who like sharing! Because of people like you I am inspired to continue modding!

Thank you deeply! All the best to you and your family!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions 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