gamethread

All other Source.Python topics and issues.
arawra
Senior Member
Posts: 190
Joined: Fri Jun 21, 2013 6:51 am

gamethread

Postby arawra » Thu Apr 17, 2014 8:13 am

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*))
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Thu Apr 17, 2014 9:12 am

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)
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Thu Apr 17, 2014 3:31 pm

Also, if you store the instance returned by TickDelays.delay, you can cancel it with:

Code: Select all

TickDelays.cancel_delay(<instance>)
arawra
Senior Member
Posts: 190
Joined: Fri Jun 21, 2013 6:51 am

Postby arawra » Fri Apr 18, 2014 12:11 pm

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)
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Fri Apr 18, 2014 3:28 pm

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.
User avatar
Doldol
Senior Member
Posts: 200
Joined: Sat Jul 07, 2012 7:09 pm
Location: Belgium

Postby Doldol » Fri Apr 18, 2014 5:15 pm

A suggestion:
Wouldn't this be more logical?

Code: Select all

myDelay = TickDelays.delay(delay_time, callBack)

myDelay.cancel_delay()
#Or
myDelay.cancel()
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sat Apr 19, 2014 3:26 am

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>).
User avatar
Doldol
Senior Member
Posts: 200
Joined: Sat Jul 07, 2012 7:09 pm
Location: Belgium

Postby Doldol » Sun Apr 20, 2014 12:42 am

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? :)

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 56 guests