3 posts
Posted 03 December 2012 - 02:29 PM
I want people to send applications for a thing I'm doing in a server, so when you start the program, it makes a form that you have to fill-in.
What I'm trying to say is that so you can do this:
Name >
(you fill in the name slot to get to the next one)
Age >
(fill in age to get to the next slot and so on and so on)
17 posts
Posted 03 December 2012 - 02:33 PM
Hi shifter619,
If I understand your question correctly, the code below should do what you want:
write("Name > ")
local name = read()
write("Age > ")
local age = read()
Basically, what this does is instead of append a newline character, like print() does, it simply outputs the text then stops. Then, the read() function allows the user to input data, while it still appears on the same line as the text.
Hope this helps! :)/>
3 posts
Posted 03 December 2012 - 03:04 PM
Hi shifter619,
If I understand your question correctly, the code below should do what you want:
write("Name > ")
local name = read()
write("Age > ")
local age = read()
Basically, what this does is instead of append a newline character, like print() does, it simply outputs the text then stops. Then, the read() function allows the user to input data, while it still appears on the same line as the text.
Hope this helps! :)/>
Thanks! The program runs perfectly and now I can get on with my thing on the server!
3 posts
Posted 03 December 2012 - 03:12 PM
Hi shifter619,
If I understand your question correctly, the code below should do what you want:
write("Name > ")
local name = read()
write("Age > ")
local age = read()
Basically, what this does is instead of append a newline character, like print() does, it simply outputs the text then stops. Then, the read() function allows the user to input data, while it still appears on the same line as the text.
Hope this helps! :)/>
Sorry for the extra question, but how do I make it so that it saves those forms. If there is no way to it's fine with me.
1688 posts
Location
'MURICA
Posted 03 December 2012 - 04:21 PM
Depends on how you want to load them later on. The simplest way would probably be to write the answers to each question on their own lines in a file, then later on read each line individually.
If you're saving your forms to a file called "data":
-- saving
file = fs.open('data','w')
file.writeLine(name)
file.writeLine(age)
file.close()
-- loading
file = fs.open('data','r')
name = file.readLine()
age = file.readLine()
file.close()