A bug with the every n seconds do end thingy.
This wasn't a bug, but became a conversation lol
I've been trying to use these kind of new microScript 2 features. In the process I ran into a problem with "every". If I understand it correctly it suposse to work as a somewhat timer, but in this bug/case it kinda just does what "after" does.
Hope this helps, cheers mrBoi =D
Try this =)
init = function()
year = 0
every 5 seconds do
year += 1
draw = function()
screen.drawText("Year: " + year ,0,0,20,"rgb(255,255,255)")
To remember, 'every' creates a new independent thread that runs parallel to the others (update, draw).
So if you define it in the update loop that gets called 60 times per second, you create 60 new ones a second that clash with each other ...
Yes, I did that too, LOL
Thanks! But if what your saying is true(which it probably is) then I may or may not found another wierd thing with every or probably any other tread thing. I made the same mistake, but I created a class with a function that had a thread in it. Then I called this function in the classes update function, which is then called in the main update function.
I am sorry if this is confusing, I just found this interesting=D
Yep, it can be tricky =)
Best thing is to name them, like so:
init = function()
count = 0
timer1 = every 1 second do count+=1 end
timer1.pause() // pause execution
Then you can use
xxx.resume() to start/stop them as needed.
xxx.stop() will kill the thread completely
Is there a way to only stop threads that are in a specffic class?
For f in fruits
Is something like this possible?
Thanks for the help, cheers, mrBoi
Oh oh, what are you up to? LOL
In theory I'd say yes, depends on how you manage the threads you create.
Also, you can always see all running threads looking at
Really hard to tell without knowing what you would like to achieve.
The expert microStuds here might now better =)
I am SnEaKY... So I won't tell, but this is mainly for petformace isuess, because having a list of objects that run their own threads would be fps intesive so stopping some would help it.
I will give you a hint: "it is quite contagious ;) "
Thanks for your help,