Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repeat-utils functions can't cancel themselves #1122

Closed
lethosor opened this issue Jun 28, 2017 · 2 comments
Closed

repeat-utils functions can't cancel themselves #1122

lethosor opened this issue Jun 28, 2017 · 2 comments
Assignees
Labels
Milestone

Comments

@lethosor
Copy link
Member

This was pointed out by Atkana on the forums:

local blah = 1
local id = "foo"
local repeatUtil = require 'repeat-util'

local function doStuff()
    print("Blah: " .. blah)
    blah = blah +1
    print("Blah is now " .. blah)
    if blah > 10 then
        print("Blah is more than 10. Stopping.")
        print("Has supposedly cancelled = " .. tostring(repeatUtil.cancel(id)))
    end
end

repeatUtil.scheduleEvery(id,50,"frames",doStuff)

This doesn't work because repeat-utils schedules the next call of doStuff() after doStuff() returns, regardless of what doStuff() does. Scheduling it before doStuff() could result in error message spam, but tracking calls to cancel() and avoiding rescheduling doStuff() if it cancelled itself could work.

@expwnent
Copy link
Member

Yup, that's bad. Should be a simple fix. I'll try to fix it today.

@lethosor
Copy link
Member Author

Fixed in #1131

@lethosor lethosor assigned BenLubar and unassigned expwnent and lethosor Jul 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants