Posted 05 September 2014 - 08:32 PM
I'm making a program that uses random words. I'm not talking about "randomly generated words". What I mean is if you type in "test" it will come up as "Hi", or "Hello" with a 50-50 chance.
local known = {
test = { "Hi", "Hello" },
}
local input = read()
if known[ input:lower() ] then
print( known[ input ][ math.random( 1, #known[ input ] ) ] )
else
print( "I don't understand!" )
end
local known = { test = { "Hi", "Hello" }, } local input = read() if known[ input:lower() ] then print( known[ input ][ math.random( 1, #known[ input ] ) ] ) else print( "I don't understand!" ) end
Does this help?
That comma is fine and can be there or not - it'll work either way. :)/>Extra comma in the end of the second line
local input = read():lower()