 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Sat Feb 20, 2016 4:27 pm Post subject: How to enable and disable a function in Lua? |
|
|
| I want to enable or disable a function when I need it. Is there a way to do that? Something like call EnableFunction(XXX)? Thanks a lot.
|
|
| Back to top |
|
 |
Daijobu Master Cheater
Reputation: 13
Joined: 05 Feb 2013 Posts: 301 Location: the Netherlands
|
Posted: Sat Feb 20, 2016 5:13 pm Post subject: |
|
|
Create a variable in memory and use a AA script to set that variable and check against it.
AutoAssemble example:
| Code: | [ENABLE]
globalalloc(myAllocatedVariable,1) --you can use this in your table
myAllocatedVariable:
db 1
[DISABLE]
myAllocatedVariable:
db 0
dealloc(myAllocatedVariable) |
Lua Example:
| Code: | local function myTimer(Sender)
while readInteger('myAllocatedVariable') == 1 do
myFunction() --execute function
writeInteger('myAllocatedVariable',0) --disable, optional unless you want to loop it
end
end
t=createTimer(Sender) --create timer 't',owner
timer_setInterval(t, 1000) --timer,milliseconds
timer_onTimer(t,myTimer) --timer,function
timer_setEnabled(t,true) --timer,boolean
--(still copied and pasta'd from Alice0725) |
From main.lua:
| Code: | Timer Class : (Inheritance: Component->object)
createTimer(owner OPT, enabled OPT):
Creates a timer object. If enabled is not given it will be enabled by default (will start as soon as an onTimer event has been assigned)
Owner may be nil, but you will be responsible for destroying it instead of being the responsibility of the owner object)
properties
Interval: integer - The number of milliseconds (1000=1 second) between executions
Enabled: boolean
OnTimer: function - The function to call when the timer triggers
methods
getInterval()
setInterval(interval) : Sets the speed on how often the timer should trigger. In milliseconds (1000=1 second)
getOnTimer()
setOnTimer(function)
getEnabled()
setEnabled()boolean) |
_________________
|
|
| Back to top |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Sat Feb 20, 2016 8:08 pm Post subject: |
|
|
| Daijobu wrote: | Create a variable in memory and use a AA script to set that variable and check against it.
AutoAssemble example:
| Code: | [ENABLE]
globalalloc(myAllocatedVariable,1) --you can use this in your table
myAllocatedVariable:
db 1
[DISABLE]
myAllocatedVariable:
db 0
dealloc(myAllocatedVariable) |
Lua Example:
| Code: | local function myTimer(Sender)
while readInteger('myAllocatedVariable') == 1 do
myFunction() --execute function
writeInteger('myAllocatedVariable',0) --disable, optional unless you want to loop it
end
end
t=createTimer(Sender) --create timer 't',owner
timer_setInterval(t, 1000) --timer,milliseconds
timer_onTimer(t,myTimer) --timer,function
timer_setEnabled(t,true) --timer,boolean
--(still copied and pasta'd from Alice0725) |
From main.lua:
| Code: | Timer Class : (Inheritance: Component->object)
createTimer(owner OPT, enabled OPT):
Creates a timer object. If enabled is not given it will be enabled by default (will start as soon as an onTimer event has been assigned)
Owner may be nil, but you will be responsible for destroying it instead of being the responsibility of the owner object)
properties
Interval: integer - The number of milliseconds (1000=1 second) between executions
Enabled: boolean
OnTimer: function - The function to call when the timer triggers
methods
getInterval()
setInterval(interval) : Sets the speed on how often the timer should trigger. In milliseconds (1000=1 second)
getOnTimer()
setOnTimer(function)
getEnabled()
setEnabled()boolean) |
|
Thanks a lot for the detailed answer.
|
|
| Back to top |
|
 |
|
|
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
|
|