-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8.if-then.lua
62 lines (48 loc) · 1.07 KB
/
8.if-then.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
--if else conditionals
local count = 0
if count == 1 then
print ("Equal if-then structure")
end
if count <= 1 then
print ("Less than or equal if-then structure")
end
if count >= 1 then
print ("Greater than or equal if-then structure")
end
if count ~= 1 then
print ("Not Equal if-then structure")
end
-- and,or,not
local count = 1
local answer = "yes"
local lives = 0
if count == 1 and answer == "yes" then
print("if-then using and")
end
if count == 1 or answer == "no" then
print("if-then using or")
end
if not (count == 0) then
print("if-then using not")
end
if count == 1 and ( answer == "no" or lives == 0) then
print ("if-then complex comparison")
end
--if-then-else
local count = 0
if count == 1 then
print( "Equal if-then structure count = 1")
else
print("if-then else, count ~=1")
end
--else-if
local count = 4
if count == 0 then
print("if-then count equals 0")
elseif count == 1 then
print( "elseif, count =1")
elseif count == 2 then
print( "elseif, count =2")
else
print("else,could not equal to 0,1,or 2")
end