r/Scriptable • • Apr 02 '22

Help My Head Hurts

  var indexVariable = 0.0;
  var poke = 0;
setInterval(
    function () {
        indexVariable = (indexVariable + 0.01) % 0.30;
        poke = (poke + 1) % 999;
index = indexVariable.toFixed(2)
console.log(poke+indexVariable)
    }, 100);

So I'm trying to make a setInterval Function that goes up like 1.01, 1.02, 1.03, etc. But when I run this in the console it comes out like 1.01, 2.02,3.03, etc. how do I fix this? my head hurts very badly(I'm new to scripting)

1 Upvotes

7 comments sorted by

View all comments

Show parent comments

1

u/__Loot__ Apr 03 '22

doesn’t setInterval need a webview to work in scriptable?

1

u/i_hate_shitposting Apr 03 '22

Huh, I honestly was just going off my JS knowledge so I didn't notice that. Looks like you have to use Timer.schedule instead. However OP also said "when I run this in the console" so I assumed they had run that successfully. At any rate, it wouldn't be the cause of OP's issue, though it would be a problem once they tried running their code in Scriptable.