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 


Lua IF

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

Joined: 09 Apr 2022
Posts: 27

PostPosted: Wed Apr 20, 2022 4:18 pm    Post subject: Lua IF Reply with quote

I would need to have an "if" that if an address value is 4 then it writes FF and it stops the "for" below but if that value is not 4 anymore than the "for" can resume.
Code:

[ENABLE]
{$lua}
b={}
timercharactersstand = createTimer(nil, false)
timercharactersstand.Interval = 20
timercharactersstand.Enabled = true
timercharactersstand.OnTimer = function(timer)

for i=1,2 do
  repeat
    b[i]=math.random(70)
    until not ((b[i]==0x28) or (b[i]==0x09) or (b[i]==0x0a) or (b[i]==0x0c) or (b[i]==0x11) or (b[i]==0x17) or (b[i]==0x1b) or (b[i]==0x1c)or (b[i]==0x1d) or (b[i]==0x1e) or (b[i]==0x1f) or (b[i]==0x20) or (b[i]==0x21) or (b[i]==0x22) or (b[i]==0x23) or (b[i]==0x24) or (b[i]==0x25) or (b[i]==0x26) or (b[i]==0x27) or (b[i]==0x28) or (b[i]==0x29) or (b[i]==0x2a) or (b[i]==0x2b) or (b[i]==0x2c) or (b[i]==0x2d) or (b[i]==0x2e) or (b[i]==0x2f) or (b[i]==0x30) or (b[i]==0x31) or (b[i]==0x32) or (b[i]==0x33) or (b[i]==0x34) or (b[i]==0x36) or (b[i]==0x37) or (b[i]==0x39) or (b[i]==0x3c) or (b[i]==0x3d) or (b[i]==0x3e) or (b[i]==0x3f) or (b[i]==0x40) or (b[i]==0x41) or (b[i]==0x44) or (b[i]==0x45) or (b[i]==0x35))
end

writeBytes(0x2059E084,b)
end

[DISABLE]
{$lua}
timercharactersstand.Enabled = false
if readByte(0x2059DDA0,4) then
writeBytes(0x2059E084,0xFF)
writeBytes(0x2059E085,0xFF)
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1257

PostPosted: Thu Apr 21, 2022 1:44 pm    Post subject: Reply with quote

Actually, a "for" loop is also unnecessary here.
You can use it as in the example or rearrange your code.
Code:
b={}
b[1]=math.random(0x70)
b[2]=math.random(0x70)
i=1
    if not ((b[i]==0x28) or (b[i]==0x09) or (b[i]==0x0a) or (b[i]==0x0c) or (b[i]==0x11) or (b[i]==0x17) or (b[i]==0x1b) or (b[i]==0x1c)or (b[i]==0x1d) or (b[i]==0x1e) or (b[i]==0x1f) or (b[i]==0x20) or (b[i]==0x21) or (b[i]==0x22) or (b[i]==0x23) or (b[i]==0x24) or (b[i]==0x25) or (b[i]==0x26) or (b[i]==0x27) or (b[i]==0x28) or (b[i]==0x29) or (b[i]==0x2a) or (b[i]==0x2b) or (b[i]==0x2c) or (b[i]==0x2d) or (b[i]==0x2e) or (b[i]==0x2f) or (b[i]==0x30) or (b[i]==0x31) or (b[i]==0x32) or (b[i]==0x33) or (b[i]==0x34) or (b[i]==0x36) or (b[i]==0x37) or (b[i]==0x39) or (b[i]==0x3c) or (b[i]==0x3d) or (b[i]==0x3e) or (b[i]==0x3f) or (b[i]==0x40) or (b[i]==0x41) or (b[i]==0x44) or (b[i]==0x45) or (b[i]==0x35))
then
print(b[1],b[2])
else
print("b1: " .. b[1])
end


or

Code:
[ENABLE]
{$lua}
b={}
timercharactersstand = createTimer(nil, false)
timercharactersstand.Interval = 20
timercharactersstand.Enabled = true
timercharactersstand.OnTimer = function(timer)

for i=1,2 do
  --repeat
    b[i]=math.random(0x70)
    if not ((b[i]==0x28) or (b[i]==0x09) or (b[i]==0x0a) or (b[i]==0x0c) or (b[i]==0x11) or (b[i]==0x17) or (b[i]==0x1b) or (b[i]==0x1c)or (b[i]==0x1d) or (b[i]==0x1e) or (b[i]==0x1f) or (b[i]==0x20) or (b[i]==0x21) or (b[i]==0x22) or (b[i]==0x23) or (b[i]==0x24) or (b[i]==0x25) or (b[i]==0x26) or (b[i]==0x27) or (b[i]==0x28) or (b[i]==0x29) or (b[i]==0x2a) or (b[i]==0x2b) or (b[i]==0x2c) or (b[i]==0x2d) or (b[i]==0x2e) or (b[i]==0x2f) or (b[i]==0x30) or (b[i]==0x31) or (b[i]==0x32) or (b[i]==0x33) or (b[i]==0x34) or (b[i]==0x36) or (b[i]==0x37) or (b[i]==0x39) or (b[i]==0x3c) or (b[i]==0x3d) or (b[i]==0x3e) or (b[i]==0x3f) or (b[i]==0x40) or (b[i]==0x41) or (b[i]==0x44) or (b[i]==0x45) or (b[i]==0x35))
then

writeBytes(0x2059E084,b[i]) -- not "b" , b[1] or b[2]
end
end


{$asm}
[DISABLE]
{$lua}
timercharactersstand.Enabled = false
if readByte(0x2059DDA0,4) then
writeBytes(0x2059E084,0xFF)
writeBytes(0x2059E085,0xFF)

_________________
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
Lorizzuoso
Cheater
Reputation: 0

Joined: 09 Apr 2022
Posts: 27

PostPosted: Thu Apr 21, 2022 5:05 pm    Post subject: Lua IF Reply with quote

Ok solved it,thanks!
Back to top
View user's profile Send private message
Bernice
How do I cheat?
Reputation: 0

Joined: 03 Apr 2022
Posts: 6

PostPosted: Thu Apr 21, 2022 8:01 pm    Post subject: Reply with quote

hi,
i had the same doubt and was stuck for days.
thanks for this
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