Can you include a module twice?

In particular with beebeegames?

I’m trying to track down leaks and part of my problem seems to stem from timers I’m using. I’m clearing them via call back when the timer finishes, but they don’t seem to be actually clearing. Probably my bug, but cancelAllTimers() seems to work, so my plan is at the start of a level, I will simply cancel all the timers.

The problem is there are a couple of timers I don’t want to clear until they have explicitly expired.

So can I:

game = require( "beebegames" )  
mytimedevent = require("beebeegames")  

The flush all the timers using game.clearAllTimers() and when mytimedevent expires call mytimedevent.clearAllTimers()

[import]uid: 19626 topic_id: 9518 reply_id: 309518[/import]

I don’t see why not, but it would have the same usage.

When do you want to clear the timers?
Do you want to wait until the end of each level to clear the timers
or clear them as you go?

if you’re using director class then you’ll have to cancel and nil the timers manually in your cleanUp function.

check out my game:
Touch Cannon – a **FREE** game

please rate :slight_smile:
[import]uid: 12455 topic_id: 9518 reply_id: 34803[/import]

Actually I think require just checks if the package is loaded, and if it is it returns it. so game and mytimeevent would be equal to each other.

I’m not familiar with the beebegames class, but is there a reason you don’t use normal unmanaged timers for the ones you don’t want cleared?

And I don’t know what your game is, but in general I wouldn’t recommend the use of timers ~ they are full of trouble.

-Angelo [import]uid: 12822 topic_id: 9518 reply_id: 34815[/import]

I found out why my timers were not clearing. Its the old “C programmer vs. Lua” bug.

game.timerCancel(x) doesn’t work and it doesn’t throw an error either. Method calls with periods should either a) just work, no reason both syntaxes are not supported or b) an error should be thrown.

Changing them to game:timerCancel(x) solved the problem.
[import]uid: 19626 topic_id: 9518 reply_id: 34828[/import]

Cool, I’m glad you solved it. The difference in syntax is not arbitrary though, : passes the calling table as self, in fact it’s just sugar ~ you could call game.timerCancel(game,x) and it will work.

-Angelo [import]uid: 12822 topic_id: 9518 reply_id: 34831[/import]