That's really not how the parallel API works. Please post your current code so we can help you fix it to work correctly. You may not need anything more than a simple event handling loop, depending on what you're trying to do.
I'm trying to implement a gravity and movement system. The problem is that you can only move 1 pixel in midair per pixel it falls. Here's the whole code:
x,y = 10,3
--first number is x, next is y
wallpos = {10,15,11,15,12,15,13,15,14,15,15,15,16,15,17,15,18,15,19,15,20,15,12,17}
local minmomentum = .5
local maxmomentum = .1
local momentum = .5
local onGround = false
term.setBackgroundColor(2048)
term.clear()
while true do
onGround = false
parallel.waitForAll(
function ()
newy,newx = 0,0
local possibleStopGravity = false
event,key = os.pullEvent()
for i=-1,#wallpos,2 do
if (event == "key" and key == 203) then
if (x-1 ~= wallpos[i] or y ~= wallpos[i+1]) then
paintutils.drawPixel(x,y,2048)
newx = -1
if (y+1 == wallpos[i+1] and newx+x == wallpos[i]) then
possibleStopGravity = true
end
if (onGround == false) then
paintutils.drawPixel(x-1,y,16)
end
else
newx = 0
possibleStopGravity = false
break
end
end
if (event == "key" and key == 205) then
if (x+1 ~= wallpos[i] or y ~= wallpos[i+1]) then
paintutils.drawPixel(x,y,2048)
newx = 1
if (y+1 == wallpos[i+1] and newx+x == wallpos[i]) then
possibleStopGravity = true
end
if (onGround == false) then
paintutils.drawPixel(x+1,y,16)
end
else
newx = 0
possibleStopGravity = false
break
end
end
--if (event == "key" and key == 208) then
--if (y+1 ~= wallpos[i+1] or x ~= wallpos[i]) then
--paintutils.drawPixel(x,y,2048)
--newy = 1
--else
--newy = 0
--redstone.setOutput("left", true)
--break
--end
--end
if (event == "key" and key == 200) then
if (onGround == true) then
paintutils.drawPixel(x,y,2048)
newy = -3
end
end
end
x = x+newx
y = y+newy
if (possibleStopGravity == true) then
onGround = true
end
end,
function ()
for i=0,#wallpos,2 do
if (y+1 == wallpos[i] and x == wallpos[i-1]) then
onGround = true
momentum = minmomentum
break
end
end
if (onGround == false) then
local timer = os.startTimer(momentum)
while true do
local event,timerID = os.pullEvent("timer")
if (timerID == timer) then
if not onGround then
paintutils.drawPixel(x,y,2048)
y = y+1
if (momentum - .1 >= maxmomentum) then
momentum = momentum - .1
end
break
else
momentum = minmomentum
break
end
end
end
end
end
)
paintutils.drawPixel(x,y,16)
for i=1,#wallpos,2 do
paintutils.drawPixel(wallpos[i],wallpos[i+1],128)
end
end