4 posts
Posted 16 December 2017 - 10:46 AM
I'm trying to figure out a way to make seperate variables from one io.read(). Here is an example of what I want it to produce.
User input: Hello world
Var1: Hello
Var2: World
Is this possible? if so, what code is needed?
Thanks!
Morgan
2427 posts
Location
UK
Posted 17 December 2017 - 01:40 PM
4 posts
Posted 17 December 2017 - 07:45 PM
I'm still very new to Lua, So, could you help me with the specifics of what I'm looking for?
7083 posts
Location
Tasmania (AU)
Posted 18 December 2017 - 12:01 AM
The section on splitting strings, specifically. You'll also want to read up on
tables if you're not already familiar with them.
15 posts
Posted 24 December 2017 - 02:02 PM
I'll spoon feed you.
local words = {};
io.write("Enter Stuff: ");
local r = io.read()
for i in string.gmatch(r,"[^ ^]+") do
table.insert(words, i)
end
for i,v in pairs(words) do
print(v)
end