When i try to put in a if then statement that i have already tested on my lua executor. It doesn’t work. Here is the code
local input = nil
print(“Please enter your name”)
input = io.read ()
if input == “Alex” then
print(“Welcome Alex”)
local timer= os.time ()
repeat until os.time () > timer + 2
else
print(“Name Unknown”)
local timer = os.time ()
repeat until os.time () > timer +2
end
Welcome to the forums! Sorry, Codea doesn’t have the io.read() function, and doesn’t have any functionality for waiting on a line, as it is intended for games and runs slightly differently on a draw loop 60 times per second. It might sound a bit confusing, but don’t worry, you’ll get used to it.
function setup()
local input = nil
print("Please enter your name") input = io.read ()
if input == "Alex" then
print("Welcome Alex")
local timer= os.time ()
repeat until os.time () > timer + 2
else
print("Name Unknown")
local timer = os.time ()
repeat until os.time () > timer +2
end
end
This can be simplified to
print("Please enter your name")
input = io.read()or "unknown"
print("Welcome "..input)
local timer= os.time()
repeat until os.time() > timer + 2
there is no build-in ‘screen’ object. You can check the ‘window library’ thread on this forum to get one.
Or you can start with standard output of codea (that is pbly better for a newbe).
Here is an example:
function setup()
print("Please enter your name")
parameter.text("name","unknown")
parameter.action("submit",nameCallback)
end
function nameCallback()
print("Welcome "..name)
end
@EagerEnglishman - what you need is a “state” variable. I explain this in one of my posts (see the Game Template link on the page below). Basically, you set your program to draw different things, depending on what state it is in.