- b = os.pullEvent("key")
- if b == 208 then
- print("Hi"
- end
Having problems with that, anyone knows why?
local event, p1 = os,pullEvent("key")
if p1 == 209 then
print("hI")
end
p = {os.pullEvent("key")}
if p[1] == 208 then
--do stuff
end
local pressKeyStartScreen
local chooseScreen == "1"
function startScreen()
while true do
--
local event, pressKeyStartScreen = os.pullEvent("key")
print("lol")
if pressKeyStartScreen == 208 then
if chooseScreen == "1" then
chooseScreen = "2"
end
if chooseScreen == "2" then
chooseScreen = "3"
end
if chooseScreen == "3" then
chooseScreen = "1"
end
end
end
startScreen()
Describe your problem in depth, otherwise we cant help you, and learn to use the code tags as well.
print("lol")
that might be it.
if a==1 then
-- do stuff
elseif a==2 then
-- do more stuff
elseif a==3 then
-- etc
end
local pressKeyStartScreen
local chooseScreen == 1
function startScreen()
while true do
local event, pressKeyStartScreen = os.pullEvent("key")
if pressKeyStartScreen == 208 then
chooseScreen=(chooseScreen+1) % 4 -- modulous!
break
end
end
end
startScreen()
storing numbers as strings is unnecicaryffffffffffffffffffffffff *tableflip*
you are doing it so wrong and everyone refuses to help
he obiously dosent understand lua's syntax
every do, then, and function needs a matching end
if statements can be combined like this:if a==1 then -- do stuff elseif a==2 then -- do more stuff elseif a==3 then -- etc end
or even better use modulousstoring numbers as strings is unnecicarylocal pressKeyStartScreen local chooseScreen == 1 function startScreen() while true do local event, pressKeyStartScreen = os.pullEvent("key") if pressKeyStartScreen == 208 then chooseScreen=(chooseScreen+1) % 4 -- modulous! break end end end startScreen()
"break" can be used to end the inner most loop (in this case the "while true do" block)
See the problem here? In a sequence of conditionals where you only want one of them to be executed, use elseif's so that only one of them is.if chooseScreen == "1" then chooseScreen = "2" end –chooseScreen is now 2
if chooseScreen == "2" then chooseScreen = "3" end –chooseScreen is now 3
if chooseScreen == "3" then chooseScreen = "1" end –chooseScreen is now 1
local event, pressKeyStartScreen = os.pullEvent("key")
if pressKeyStartScreen == "208" then
if chooseScreen == "1" then
chooseScreen = "2"
ifelse chooseScreen == "2" then
chooseScreen = "3"
ifelse chooseScreen == "3" then
chooseScreen = "1"
end
end
local event, pressKeyStartScreen = os.pullEvent("key")
if pressKeyStartScreen == 208 then
if chooseScreen == "1" then
chooseScreen = "2"
elseif chooseScreen == "2" then
chooseScreen = "3"
elseif chooseScreen == "3" then
chooseScreen = "1"
end
end
OMFGBBQ
No but seriously, you got them the wrong way around ;)/> elseif and not ifelse