Frequency Edit Script?

I need some help with a script for a game I’m working on… I have a door setup with an “Always” sensor with “TRUE level triggering” enabled, and a frequency of 3, attached to an “F-Curve” actuator so that the door opens and closes continuously.

What I need is a script that makes it so that when I press “R” the frequency of the “Always” sensor increases to 6…

How can do this, or is it even possible? Also, could I make it change back to 3 after 5 seconds?

Attachments


It is possible to do that, but…

I think you are misinterpreting what the f: paramterer is doing. For more informations you can find some guides in my signature.

The sensor does not let an animation run slower, as the actuator plays the animation by itself. Which means you do not need the True pulse mode.

For slowing down or speeding up curve/action actuators better switch to property mode of the actuator. Then you have absolute control on the animation.

You can setup a frame property (Frame not Frame Prop!) as float.
With that you set what frame of the animation is shown. If you increase the property you ply forward, if you decrease you play reverse. The speed is determined by the incremental/decremental value. Small steps = slow; large steps = fast.
You can use the property actuator for that (no Python needed).

I hope it helps.

That helped a little… But it still isn’t what I need.

The animation for the door is from frame 1 to frame 5, and it just opens… I have it set to “ping pong” so that it repeats and plays continuously.

I need it to play slower when I press “R” and return to normal speed

import bge
controller = bge.logic.getCurrentController()
owner = controller.owner

##User Variables#######

#name of the keyboard sensor (slow)
keyboard = ""
#name of the ipo property actuator
ipo = ""
endframe = 5
startframe = 1
speedfast = 1/15
speedslow = 1/30

###################

slow = controller.sensors[keyboard]
ipo = controller.actuators[ipo]

if not "count" in owner:
    owner["count"] = speedfast
if not "dir" in owner:
    owner["dir"] = True
        
if owner["frame"] >= endframe:
    owner["dir"] = False
elif owner["frame"] <= startframe:
    owner["dir"] = True

if owner["dir"] == True:
    owner["frame"] += owner["count"]
else:
    owner["frame"] += -owner["count"]        

if slow.positive:
    owner["count"] = speedslow
else:
    owner["count"] = speedfast
controller.activate(ipo)

It is in fact what you could use.
Make the ipo actuator run from a float property, and then make a script running at true pulse
in the script, make it count and then count down etc.
when the r sensor is pressed, change the count value.

How to use:
1)Make a True Pulse Always sensor, running at f:0
2)Make a keyboard sensor, for slowing the animation, and type its name in the user properties (Make it True Pulse)
3)Make an ipo actuator, set it to property and connect it to script. Type its name in the user properties.
#4)If you want to change the start or end frame, or speed etc, change the variables in the user properties

I still can’t make it work… I’ve provided a link to the .blend file for the game demo… Could someone please show me what I’m doing wrong?

http://www.pasteall.org/blend/7081

I can’t open your from here. But you could look at
Play Rate of the Action actuator

it does that what you need ust with actions. The same works with IPO too.