Unable to get sensor.pos_ticks or sensor.neg_ticks working

it returns 0 in every cases . Why ?

sen.pos_ticks : returns the number of ticks since the last positive pulse.


What are you trying to accomplish? I believe sensor.pos_ticks or sensor.neg_ticks is the current tick the sensor is on while it is running in TRUE or FALSE Pulse mode. Were you thinking it meant something like ticks since last triggering?

If you have a sensor in TRUE or FALSE Pulse mode and had something else that was always running(another always sensor set to TRUE), you could see that the pos_ or neg_ ticks of the sensor in question are just counting up to the Skip amount and resetting to 0 over and over again. It should have no effect when either not in Pulse mode, skip is set to 0, or you are using the sensor itself to trigger a print statement.

im not sure this would have any sense to use it on pulse mode because, the answer would be the same than the return of the .skippedTicks (so 0 by default). For me, the .pos_ticks has to be used to know the delay between each time the same sensor is + (like pushing 2 times same button) (not on pulse mode ofc). I can make it other way but i was just wanting to know if this function is bugged.

It’s not bugged, it just doesn’t do what you think or want it to do. You use sensor.skippedTicks to set the amount of ticks(frames) you want this sensor to skip between positive or negative pulses. And I mean automatic pulses that are generated by the sensor without any other input. sensor.pos_ticks or sensor.neg_ticks shows which tick it is currently on in the current frame in regards to that skippedTicks setting. These values are not the same as skippedTicks as they increase each frame until skippedTicks is reached.

You most likely need to make it using a timer or custom timer class or something similar that checks the time between button presses and acts accordingly. Check out Goran Milovanovic’s great tutorial on key combos for some good info on timing button presses if you’re interested.

But i never said i was using the pulse mode :slight_smile: and yes, indeed, i though it was recording the delay (number of ticks between 2 pulses. But as you mention, obviously this function works with skippedTicks (so a sensor on pulse mode) which doesn’t interest me at all as pulse mode is just an indicator of poor architecture in the game system. I was just looking a function to tell me how many ticks since last time i push same button