Page 1 of 1

gamethread

Posted: Thu Apr 17, 2014 8:13 am
by arawra
Is there a gamethread module/package added? If so, does it work the same way?

Code: Select all

import gamethread

gamethread.delayed(delay_time, myCallback(args*))

Posted: Thu Apr 17, 2014 9:12 am
by L'In20Cible
Well, your syntax for gamethread is wrong. It should be:

Code: Select all

import gamethread

gamethread.delayed(delay_time, myCallback, args)
Anyways, to answer your question, yes there is:

Code: Select all

from tick.delays import TickDelays

TickDelays.delay(delay_time, myCallback, *args)

Posted: Thu Apr 17, 2014 3:31 pm
by satoon101
Also, if you store the instance returned by TickDelays.delay, you can cancel it with:

Code: Select all

TickDelays.cancel_delay(<instance>)

Posted: Fri Apr 18, 2014 12:11 pm
by arawra
satoon101 wrote:Also, if you store the instance returned by TickDelays.delay, you can cancel it with:

Code: Select all

TickDelays.cancel_delay(<instance>)


The instance would be the name of the variable, correct?

Code: Select all

myDelay = TickDelays.delay(delay_time, callBack)

TickDelays.cancel_delay(myDelay)

Posted: Fri Apr 18, 2014 3:28 pm
by satoon101
Yes, or you could, for instance, use a dictionary to store an instance for each player. Also, when you use cancel_delay, if the delay has already passed, no error is raised.

Posted: Fri Apr 18, 2014 5:15 pm
by Doldol
A suggestion:
Wouldn't this be more logical?

Code: Select all

myDelay = TickDelays.delay(delay_time, callBack)

myDelay.cancel_delay()
#Or
myDelay.cancel()

Posted: Sat Apr 19, 2014 3:26 am
by satoon101
I originally thought about adding this, but never did. I cannot remember why I decided not to, though. It would be very easy to add in.

Also, TickDelays is a dictionary object, so it is just as logical to use the current implementation. And, if we were to add in <instance>.cancel_delay(), we would still keep TickDelays.cancel_delay(<instance>).

Posted: Sun Apr 20, 2014 12:42 am
by Doldol
satoon101 wrote:I originally thought about adding this, but never did. I cannot remember why I decided not to, though. It would be very easy to add in.

Also, TickDelays is a dictionary object, so it is just as logical to use the current implementation. And, if we were to add in <instance>.cancel_delay(), we would still keep TickDelays.cancel_delay(<instance>).


So no reason to not add it then? :)