-- Alerts

So I’m trying to incorporate alerts into my projects but It always goes into infinite loops since the variable is always true and I have tried so many ways to only alert the user once but it I’ve gotten it to do it 2 times.

Here’s what I did, can someone make it so it only asks once?

alertT=false
alertTimer=0
startTimer=false
end
if Currenttouch.x > blah blah and currenttouch.x < blah blah and so on THEN
alertT=true
startTimer=true
end
if alertT == true then
alert("test","test")
end
if startTimer == true then
alertTimer=alertTimer+1
end
if alertTimer>0.000000001 then
alertT=false
alertTimer=0

That isn’t the exact code since I don’t have my iPad with me but it is basically the same thing summed up.

I had even put:

text(alertTimer,WIDTH/2,HEIGHT/2)

And I noticed that after the timer goes back to zero it keeps going back up to 0.000001 and restarting over and over again.

Please help

I suggest you write it something like this

if CurrentTouch == something then
    if alerted==nil then alert("test") alerted=true end
elseif alerted then alerted=nil end

This alerts the first time and sets “alerted” to true, preventing the alert being repeated. As soon as the touch stops, “alerted” is set to nil so that the next touch will trigger an alert.

@Wallisch_pls The problem with using CurrentTouch is that once you touch the screen, CurrentTouch still keeps that value until you touch somewhere else. So if CurrentTouch is in a loop, it will continue to make alertT = true.

Alright, thanks, when I have time I’ll try that out.

And are there boolean alerts yet? like “yes” or “no”??

As far as I know of, there is not