Resetting all of Löve's callbacks?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- DaedalusYoung
- Party member
- Posts: 407
- Joined: Sun Jul 14, 2013 8:04 pm
Re: Resetting all of Löve's callbacks?
Why not do it the other way? Don't define any callbacks until the version check is passed.
- zorg
- Party member
- Posts: 3449
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Resetting all of Löve's callbacks?
Now that i think about it, you needn't do anything more complicated than this:
Since love's default err(or)hand(ler) routine basically creates an infinite loop inside itself, acting like a "new love.run", the original will never execute any callbacks ever again, and in the new one, it only detects quit events and whether you pressed escape (to quit) or not.
Code: Select all
--either the top of main.lua or love.load, shouldn't matter
-- ...
local major, minor, revision, codename = love.getVersion( )
if minor ~= 9 then error ""Using wrong löve version! Need Version 0.9" end -- also, you wanted ~= instead of !=
-- ...
Last edited by zorg on Sun Mar 15, 2015 12:02 am, edited 1 time in total.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Resetting all of Löve's callbacks?
Plus why would you need to nil callbacks you never created? just nil the ones you use, load, update draw, if a callback called "love.superMegaLoveCallbackNewWhichWasntInOtherVersions" exist but you dont define it then it will be nil by default, no need to make it nil again...
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
- zorg
- Party member
- Posts: 3449
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Resetting all of Löve's callbacks?
From what i can tell, germanunkol was worried that other existing callbacks would have been ran per-frame under the error screen, which they wouldn't have. (with the default love.errhand that is)Positive07 wrote:Plus why would you need to nil callbacks you never created? just nil the ones you use, load, update draw, if a callback called "love.superMegaLoveCallbackNewWhichWasntInOtherVersions" exist but you dont define it then it will be nil by default, no need to make it nil again...
Since the error usually results in the program exiting, you need not nil anything anyway.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
-
- Party member
- Posts: 712
- Joined: Fri Jun 22, 2012 4:54 pm
- Contact:
Re: Resetting all of Löve's callbacks?
Hey, thanks for all the feedback!
Right, I forgot about the posibility to write my own error handler function. That of course solves the rest of the problems, because it won't accept any more input (I think).
Thanks!
Right, I forgot about the posibility to write my own error handler function. That of course solves the rest of the problems, because it won't accept any more input (I think).
Thanks!
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Who is online
Users browsing this forum: No registered users and 6 guests