If i type random2 it runs the else code.
write("Senha: ")
a = read()
if a == "random" then
print("mensage")
if a == "random2" then
print("potato")
end
else
print("Bye bye")
sleep(2)
os.shutdown()
end
Posted 17 January 2014 - 09:59 PM
write("Senha: ")
a = read()
if a == "random" then
print("mensage")
if a == "random2" then
print("potato")
end
else
print("Bye bye")
sleep(2)
os.shutdown()
end
Posted 17 January 2014 - 10:09 PM
write("Senha: ")
a = read()
if a == "random" then
print("mensage")
if a == "random2" then
print("potato")
end
else
print("Bye bye")
sleep(2)
os.shutdown()
end
write("Senha: ")
a = read()
if a == "random" then
print("mensage")
elseif a == "random2" then
print("potato")
else
print("Bye bye")
sleep(2)
os.shutdown()
end
Posted 17 January 2014 - 10:17 PM
theoriginalbit, on 17 January 2014 - 10:09 PM, said:
write("Senha: ")
a = read()
if a == "random" then
print("mensage")
if a == "random2" then
print("potato")
end
else
print("Bye bye")
sleep(2)
os.shutdown()
end
write("Senha: ")
a = read()
if a == "random" then
print("mensage")
elseif a == "random2" then
print("potato")
else
print("Bye bye")
sleep(2)
os.shutdown()
end
Edited by Felype, 17 January 2014 - 10:18 PM.
Posted 17 January 2014 - 10:27 PM
Felype, on 17 January 2014 - 10:17 PM, said:
theoriginalbit, on 17 January 2014 - 10:09 PM, said:
write("Senha: ")
a = read()
if a == "random" then
print("mensage")
if a == "random2" then
print("potato")
end
else
print("Bye bye")
sleep(2)
os.shutdown()
end
write("Senha: ")
a = read()
if a == "random" then
print("mensage")
elseif a == "random2" then
print("potato")
else
print("Bye bye")
sleep(2)
os.shutdown()
end
if condition then --Code elseif othercondition then --Other code elseif differentcondition then --More code else --What to do if all the conditions are false end --You only need one end.
Posted 17 January 2014 - 10:32 PM
Posted 17 January 2014 - 10:57 PM
Posted 18 January 2014 - 07:18 PM
theoriginalbit, on 18 January 2014 - 10:43 AM, said:
--I will not create a cool screensaver in this code this code is only to show what i know.
repeat
term.clear()
print("O ")
sleep(2)
term.clear()
print(" O")
until
--I Dont know where to put this \/
while true do
local event, param = os.pullEvent()
if event == "L"
os.shutdown()
end
end
Posted 18 January 2014 - 07:37 PM
local myTimer = os.startTimer(2) -- A timer event will go into the event queue in two seconds. "myTimer" records it's number.
local frameCounter = 1
while true do
local event, param = os.pullEvent() -- Wait for any event.
if event == "timer" and param == myTimer then -- Our two-second timer ended.
term.clear()
term.setCursorPos(1,1)
if frameCounter == 1 then
frameCounter = 2
print("O")
elseif frameCounter == 2 then
frameCounter = 1
print(" O")
end
myTimer = os.startTimer(2) -- Start a new timer and record its new ID number.
elseif event == "key" then -- Instead of our timer ending, our event was triggered by a keypress.
break -- Exit our "while" loop.
end
end
0 members, 1 guests, 0 anonymous users