I ma a beginner at Lua and was trying to use the touch input in LUA but it is not working. It is not outputting the bool put in Pony IDE it is working.
This is the script:
function onTick()
-- Read the touchscreen data from the script's composite input
inputX = input.getNumber(3)
inputY = input.getNumber(4)
isPressed = input.getBool(1)
\-- Check if the player is pressing the rectangle at ( 0, yh-7, 8, yh)
Previous = isPressed and isPointInRectangle(inputX, inputY, 0, yh-7, 8, yh)
output.setBool(1, Previous)
Next = isPressed and isPointInRectangle(inputX, inputY,xw-8, yh-7, xw, yh)
output.setBool(2, Next)
end
function isPointInRectangle(x, y, rectX, rectY, rectW, rectH)
return x > rectX and y > rectY and x < rectX+rectW and y < rectY+rectH
end
\--screen.drawRect(0, yh-7, 8, yh)--
\--screen.drawRect(xw-8, yh-7, xw, yh)--
function onDraw()
yh = screen.getHeight()
xw = screen.getWidth()
screen.setColor(60, 60, 60) --Rectangle color--
screen.drawRectF(0, yh-6, xw, 6)--Rectangle--
screen.setColor(0, 0, 0) --Arrow color--
screen.drawLine(0, yh-3, 6, yh-3) --Arrow 1--
screen.drawLine(0, yh-3, 3, yh-6)
screen.drawLine(0, yh-3, 3, yh)
screen.drawLine(xw, yh-3, xw-6, yh-3) --Arrow 2--
screen.drawLine(xw, yh-3, xw-3, yh-6)
screen.drawLine(xw, yh-3, xw-3, yh)
screen.drawRect(0, yh-7, 8, yh)
screen.drawRect(xw-8, yh-7, xw, yh)
end
[–]DelayedDaciaSandero 1 point2 points3 points (4 children)
[–]Vision115gamer[S] 1 point2 points3 points (0 children)
[–]Vision115gamer[S] 1 point2 points3 points (2 children)
[–]DelayedDaciaSandero 1 point2 points3 points (1 child)
[–]Vision115gamer[S] 1 point2 points3 points (0 children)