44 posts
Location
Australia
Posted 12 July 2013 - 01:51 AM
Hi i am making a turtle game and i need a way to take an input at the start of the program and show it later
eg:
print ("Hello")
textutils.slowPrint ("What is your name?")
local input = read()
print ("OMG")
print ("LOL")
print ("Computer craft")
print ("Loads of other garble")
print ("ok mister (INPUT), lets play a game") -- Where it says (INPUT) I need to put the text from the local input = read() string
As you can see i want an input from the start to be displayed later INSIDE or at the end of (but in the same line) a print string!
If this is possible post the actual code for it or modify this code with the required arguments.
THANKS
51 posts
Posted 12 July 2013 - 02:09 AM
Hi i am making a turtle game and i need a way to take an input at the start of the program and show it later
eg:
print ("Hello")
textutils.slowPrint ("What is your name?")
local input = read()
print ("OMG")
print ("LOL")
print ("Computer craft")
print ("Loads of other garble")
print ("ok mister (INPUT), lets play a game") -- Where it says (INPUT) I need to put the text from the local input = read() string
As you can see i want an input from the start to be displayed later INSIDE or at the end of (but in the same line) a print string!
If this is possible post the actual code for it or modify this code with the required arguments.
THANKS
Well thats simple.
print ("ok mister "..input..", lets play a game")
808 posts
Posted 12 July 2013 - 02:14 AM
Well thats simple.
print ("ok mister "..input..", lets play a game")
Just to clarify because clearly Galactica4 is kinda new to Lua, two periods next to each other like that is the concatenation operator. Basically means to stick the two strings together.
print("string 1" .. "string 2") -- combine "string 1" and "string 2"
outputs "string 1string 2"
So you can use this to put strings and variables together like you want.
local input = read()
print("Hey, " .. input) -- concatenating input to the end of "Hey, "
44 posts
Location
Australia
Posted 12 July 2013 - 02:19 AM
Hi i am making a turtle game and i need a way to take an input at the start of the program and show it later
eg:
print ("Hello")
textutils.slowPrint ("What is your name?")
local input = read()
print ("OMG")
print ("LOL")
print ("Computer craft")
print ("Loads of other garble")
print ("ok mister (INPUT), lets play a game") -- Where it says (INPUT) I need to put the text from the local input = read() string
As you can see i want an input from the start to be displayed later INSIDE or at the end of (but in the same line) a print string!
If this is possible post the actual code for it or modify this code with the required arguments.
THANKS
Well thats simple.
print ("ok mister "..input..", lets play a game")
Well thats simple.
print ("ok mister "..input..", lets play a game")
Just to clarify because clearly Galactica4 is kinda new to Lua, two periods next to each other like that is the concatenation operator. Basically means to stick the two strings together.
print("string 1" .. "string 2") -- combine "string 1" and "string 2"
outputs "string 1string 2"
So you can use this to put strings and variables together like you want.
local input = read()
print("Hey, " .. input) -- concatenating input to the end of "Hey, "
BOTH OF YOU NEVER SAID ANYTHING, I DID NOT MAKE A MISTAKE, WHAT ARE YOU TALKING ABOUT??????
:ph34r:/> NOTHING, :blink:/> NoThInG :unsure:/> What are you talking about? :wacko:/> OK Fine you got me, i made a mistake! <_</> I'm sorry (JOKES)
Any way, thanks for that both of you :lol:/> :D/>