Page 1 of 1

Jetpack with timer

Posted: Sun Dec 27, 2015 6:32 pm
by Kami
Hey guys, I've run into a strange error.

So I tried using player.set_jetpack and after 5 seconds removing it with this line:

Code: Select all

timer_jet = tick_delays.delay(5, player.set_jetpack(0))


Now with that line I get an error from the tick.py saying "NoneType object is not callable"-

Other timers worked just fine, like:

Code: Select all

timer_entity = tick_delays.delay(5, entity.remove)


Any thoughts? Thanks :)

Posted: Sun Dec 27, 2015 6:38 pm
by satoon101
You are passing the argument directly to the function at runtime when you need to pass it to the delay instead:

Syntax: Select all

timer_jet = tick_delays.delay(5, player.set_jetpack, 0)


Also, when posting Python code, use the Python syntax blocks: [python][/python]

Posted: Mon Dec 28, 2015 11:46 am
by Ayuto
I have added a sanity check, so a descriptive error will be already raised when you create the delay.
https://github.com/Source-Python-Dev-Team/Source.Python/commit/5918ba1bf989cc56e822dc1bc09ec81aa354b126

Posted: Tue Dec 29, 2015 2:35 pm
by Kami
Thank you very much satoon, this really helped me out a lot! :)