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 


IIF in CE Lua format

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Wed Nov 04, 2020 12:11 am    Post subject: IIF in CE Lua format Reply with quote

IIF function is used to evaluate an expression and perform one of two actions based on the outcome of the evaluation.

Example in Lua:

Code:
if x < 10 then   -- expression 1
  print('lower') --  action 1
elseif  x > 10 then -- expression 2
  print('higher') --  action 2
end


So, this is from not Lua script:

Code:
x =iif(b, not Z, Z)


then in CE Lua is ...... ? , using ternary function?

like this:

Code:
print('x is ' .. if  b then not Z else  Z end)


or

Code:
local x

 if b then
  x = not Z
 else
  x = Z
 end


Is that right? Question Question

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4718

PostPosted: Wed Nov 04, 2020 12:52 am    Post subject: Reply with quote

Code:
print(true and 1 or 2)
print(false and 3 or 4)

-- prints 1 \ 4

Search "Lua ternary operator"

_________________
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
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Wed Nov 04, 2020 1:13 am    Post subject: Reply with quote

Thanks @ParkourPenguin, I did and got knew for the ternary operator.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
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