
Luca_S, on 05 July 2016 - 03:29 PM, said:
Also if you post intend your code
Edit: Actually always intend your code it will make it WAY easier for you to read
local list = { [2] = "value1", [6] = "value2"}
local foundvalue = false
local uservalue = io.read()
for key,value in pairs(list) do
if value == uservalue then
foundvalue = true
else
--nothing is supposed to go here
end
end
if foundvalue == false then--executes code at the end of the for loop if it has not found the value
--blah,blah,blah
vs.
local list = { [2] = "value1", [6] = "value2"}
local foundvalue = false
local uservalue = io.read()
for key,value in pairs(list) do
if value == uservalue then
foundvalue = true
else
--nothing is supposed to go here
end
end
if foundvalue == false then--executes code at the end of the for loop if it has not found the value
--blah,blah,blah
Indent*
Edit: Indented code probably looks like this:
local list = { [2] = "value1", [6] = "value2"}
local foundvalue = false
local uservalue = io.read()
for key,value in pairs(list) do
if value == uservalue then
foundvalue = true
else
--nothing is supposed to go here
end
end
if foundvalue == false then--executes code at the end of the for loop if it has not found the value
--blah,blah,blah
end -- before, you had a missing end
Not this:
local list = { [2] = "value1", [6] = "value2"}
local foundvalue = false
local uservalue = io.read()
for key,value in pairs(list) do
if value == uservalue then
foundvalue = true
else
--nothing is supposed to go here
end
end
if foundvalue == false then--executes code at the end of the for loop if it has not found the value
--blah,blah,blah
end -- before, you had a missing end
Edited by LoganDark, 05 July 2016 - 07:23 PM.