34 posts
Posted 06 September 2012 - 08:21 PM
i am making a program on my computer the first part of the program is print whats your name then the user puts in there name then i want to have it print welcome and then the name they put in.
this is what i have so far i don t no how to have it print what they typed i put ?? where i am confused on what to do
—–
print("hello whats your name")
–they type in there name here there name is printed in the next line
print("welcome –there name i dont no how to put that there plz help thank u")
14 posts
Posted 06 September 2012 - 08:25 PM
use the string.format function
name = read()
print(string.format( " The name is %s ", name))
34 posts
Posted 06 September 2012 - 08:26 PM
thank u
49 posts
Posted 06 September 2012 - 08:28 PM
Use string concatenation, just do "string"..variable
so:
print("Hello, what's your name?")
name = read()
print("Welcome,"..name)
34 posts
Posted 06 September 2012 - 08:30 PM
guys i got another quetion can i make it so that there name is saved into the code of a program called names automasticly when they type it
49 posts
Posted 06 September 2012 - 08:31 PM
guys i got another quetion can i make it so that there name is saved into the code of a program called names automasticly when they type it
You mean like a save file? so it has a list of peoples names?
34 posts
Posted 06 September 2012 - 08:32 PM
yah just like that
49 posts
Posted 06 September 2012 - 08:35 PM
<Shameless Self Promotion>
Well, i've just released an API which helps you save data to a file, so you could use that for a quick solution:
Here</Shameless Self Promotion>
Or you can read up on the fs API on the wiki and write your own functions to sort out the data
There
34 posts
Posted 06 September 2012 - 08:43 PM
listen i suck at tekkit can u be more specfic and acutly type the code i need for this exact situation
49 posts
Posted 06 September 2012 - 08:45 PM
I'll give you a hand in a little when i'm not busy, but really, it's a much better idea to at least read through the docs on the wiki, or use somebody elses API, it'll help you get better.
318 posts
Location
Somewhere on the planet called earth
Posted 06 September 2012 - 08:46 PM
while true do
write("What is you're name: ")
name = read()
file = fs.open("filename", "w") open the file filename in write mode
file.writeLine(name) --Writes the variable name to the file filename
file.close() --Prevents it messing up
end
I belive that works
34 posts
Posted 06 September 2012 - 08:50 PM
it says on line 4 = expected
49 posts
Posted 06 September 2012 - 08:53 PM
it says on line 4 = expected
put '–' before the second "open" on line 4, without the quotes