startup script?

Hi all,

How do I get a script to run just once at startup? I suppose it is a case of putting the right kind of sensor on to any old object and connecting it to a script controller, but I’m not sure what properties to give the sensor to make it work like that.

What about a way to run a script when I hit escape to end the game mode?

It’s so I can open and close the serial port. Reading from a serial port works well in python game engine by the way. It’s just that right now I have to open and close the port every time my reading script runs!

Cheers,

Ben

To run a script once at startup use an Always sensor without pulse mode and connect it to a python controller.

To run a script on exit, you could maybe use a keyboard sensor on “q” and instruct your users to press that key to exit?

Thanks Laurens that did the trick!

Ben