 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
percypierce How do I cheat?
Reputation: 0
Joined: 15 Jan 2021 Posts: 4
|
Posted: Thu Jan 21, 2021 1:23 pm Post subject: Declaring Local Variables inside a TIMER |
|
|
I'm kind of stuck.
when I used C, I was able to declare a variable without a value inside a function, and if I were to use BYTE before that variable, I would get a 0 value or something. and important thing to note is that when declared AGAIN inside an interval function, it doesn't set that BYTE value to zero at the beginning of the code.
But with Lua, It sets it to nil.
I was wondering if I constantly declare a local variable inside an interval, does it always set it back to nil even after certain conditions give it a value such as true or false?
Also, I've heard of "variable variables" but nowhere have I found proper examples.
here's my code:
| Code: |
p2voidlock=createTimer(nil)
p2voidlock.Interval=1
p2voidlock.OnTimer=function(p2voidlock)
local yourbeingthrown = 'process.exe + 53832D1'; -- this is an address. In the timer, it will ALWAYS give the local variable a value. No need to worry about code not working because the variable doesn't have a value.
local holdit, pattern, timer, alarm; -- these variables are declared without values. In this interval, does it RESET BACK TO NIL....
if (timer > 0)
then
if (holdit == false)
then
timer = timer - 1;
else
timer = timer - 0;
end
end
if (timer <= 0 )
then
pattern = math.random(10); timer = alarm ;
end
if (readBytes(yourbeingthrown) == true)
then
holdit = false; timer = 0; -- ....After a condition such as this GIVE them values?
end
p2voidlock.enabled = true
end
|
As for "variable variables" they said something about using the "or" operator, but they used keywords inside the code, like "variable = variable or value" which confused me. I don't want to declare a variable with a value because the interval will just constantly reset the variable back to the declared value!
|
|
| Back to top |
|
 |
Skyrimfus Cheater
Reputation: 1
Joined: 17 Mar 2016 Posts: 43
|
Posted: Thu Jan 21, 2021 1:55 pm Post subject: |
|
|
yes if you use local var inside a timer it will constantly write nil to those variables at the top of the func. You can get around this by using something like this:
| Code: |
function test1()
local a,b,c,d
print(2)
function test2()
if a==nil then a = 0 end
if b==nil then b = 0 end
if c==nil then c = 0 end
if d==nil then d = 0 end
a=a+1
b=b+1
c=c+1
d=d+1
print(a,b,c,d)
end
t.Ontimer = test2
end
t = createTimer()
t.Interval = 100
t.OnTimer = test1
|
|
|
| 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
|
|