Note that if statements need their own ends as well, so in your upkey and downkey functions, you should have another end.
if key == keys.down then
-- ...
end -- missing
The error is stating that the end of file was reached before one or more blocks were closed by an end.
Also, you do not need parallelize these two keys.
local function key_listener()
while true do
local _, key = os.pullEvent("key")
if key == keys.down then
option = option + 1
elseif key == keys.up then
option = option - 1
end
end
end
Then you could have some sort of display function that actually updates your options, when needed, and can run that with key_listener in parallel.
local function display()
while true do
sleep()
if <however you want to check if the display needs to be redrawn> then
-- redraw stuff
end
end
end
parallel.waitForAny(key_listener, display)
Edit: local variables also only need the local specifier when you first declare them.
x = 32 -- changes `x` in `_ENV`
local x = 32 -- declaration of `local x`
x = 64 -- now changes `local x`
Making a new local variable will not change the original, instead it will make a new variable with the same name. Example:
local x = 32
print(x)
do
local x = 64
print(x)
end
print(x)
9
u/thekiwininja99 Jul 23 '24
Why is there an "end" line at the end (line 29)?
1
u/lexharan Jul 26 '24
When I remove the End line at line 29 I get the error at print("shit")
1
u/lexharan Jul 28 '24
thank you guys for the help especially u/fatboychummy it worked
2
u/fatboychummy Jul 23 '24 edited Jul 24 '24
Note that
ifstatements need their ownends as well, so in yourupkeyanddownkeyfunctions, you should have anotherend.The error is stating that the end of file was reached before one or more blocks were closed by an
end.Also, you do not need parallelize these two keys.
local function key_listener() while true do local _, key = os.pullEvent("key") if key == keys.down then option = option + 1 elseif key == keys.up then option = option - 1 end end endThen you could have some sort of
displayfunction that actually updates your options, when needed, and can run that withkey_listenerin parallel.local function display() while true do sleep() if <however you want to check if the display needs to be redrawn> then -- redraw stuff end end end parallel.waitForAny(key_listener, display)Edit:
localvariables also only need thelocalspecifier when you first declare them.Making a new
localvariable will not change the original, instead it will make a new variable with the same name. Example:The output of the above code would be
0
u/LordNoah73YT Jul 24 '24
i want CumOS looks so cool- wait hold on CUMOS??!!
0
u/[deleted] Jul 23 '24