Common functions

I finally made a module of some very useful bge functions. These I use in nearly every script I’ve ever written.
Inside the zip are both the module and the documentation for it.

You’ll need to have a basic knowledge of python to use these properly.

To use these functions:


import common

#Get an object from inactive layer with property bullet
common.getFunct.objectFromProperty('bullet', 'LevelScene', 'Inactive')

Version 1:
Features:

  • Objects from name
  • Objects from property
  • Children from property
  • Scene from name
  • Percent
  • Angle between two objects
  • Line of sight between two objects
  • Get all addObject actuators
  • Activate a list of actuators
  • Game Path
  • Game Path up a level (if you are running from inside a data folder)

Download:
common v1.zip (19.2 KB)

Have fun with it, and let me know what else I should add.

Critiques over how I’ve done something are accepted

Hello sdfgeoff

thank you very much for sharing!
Great work…I guess, I know nothing about Python! :wink:

That’s why I’m asking you, if you could make some basic examples about how to use those functions?
It’ll be an useful resource, I’m sure!

Bye

Hi sdfgeoff,

Thank you for your work. Good to hear, you can take a crtics.

IMHO / on # by python coder
I dont see a too much of need for the module, which is containing a functions with a just few lines of code.

You can easily a copy/paste needed parts to your main code/s, and modify as needed.

It would be a different story, if module is containing a very complex function/s codes and is maintained by provider.
IMHO / off

@OTO:
None of these functions can be used outside of another python script, so I can’t really give examples of how to use them.

@Xjazz:
Yes each function is short, but they are used very often, hence it’s function. In multi-script games (like DEEP Space, where I have ~8 scripts), I use these functions in all of them, and don’t want to have too many duplicates to maintain.

I am planning some longer ones, like my ‘getBestToTrackTo’ function. It just needs some cleaning up to fit in with the rest of the module.

Suggestions for other functions are welcome

Hi sdfgeoff

Ok. I understand now, why you want to have it that way. It makes totally a sense in that scenario.