# Common functions

**URL:** <https://blenderartists.org/t/common-functions/558773>\
**Category:** Game Engine Resources\
**Created:** [December 5, 2012, 9:21pm UTC](https://blenderartists.org/t/common-functions/558773 "2012-12-05T21:21:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdfgeoff](https://blenderartists.org/user_avatar/blenderartists.org/sdfgeoff/32/15010_2.png) [@sdfgeoff](https://blenderartists.org/u/sdfgeoff)\
**Post date:** [December 5, 2012, 9:21pm UTC](https://blenderartists.org/t/common-functions/558773/1 "2012-12-05T21:21:47Z")

</div>

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:

```auto

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](https://blenderartists.org/uploads/default/original/3X/c/8/c8a8720fafd20844107ab5ad35f9773dedea6a1a.zip) (19.2 KB)

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

---

<div class="post-metadata">

**Author:** ![sdfgeoff](https://blenderartists.org/user_avatar/blenderartists.org/sdfgeoff/32/15010_2.png) [@sdfgeoff](https://blenderartists.org/u/sdfgeoff)\
**Post date:** [December 5, 2012, 9:23pm UTC](https://blenderartists.org/t/common-functions/558773/2 "2012-12-05T21:23:23Z")

</div>

Critiques over how I’ve done something are accepted

---

<div class="post-metadata">

**Author:** ![OTO](https://blenderartists.org/letter_avatar_proxy/v4/letter/o/e8c25b/32.png) [@OTO](https://blenderartists.org/u/OTO)\
**Post date:** [December 6, 2012, 2:15am UTC](https://blenderartists.org/t/common-functions/558773/3 "2012-12-06T02:15:35Z")

</div>

Hello sdfgeoff

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

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

---

<div class="post-metadata">

**Author:** ![Xjazz](https://blenderartists.org/letter_avatar_proxy/v4/letter/x/ea666f/32.png) [@Xjazz](https://blenderartists.org/u/Xjazz)\
**Post date:** [December 6, 2012, 1:49pm UTC](https://blenderartists.org/t/common-functions/558773/4 "2012-12-06T13:49:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sdfgeoff](https://blenderartists.org/user_avatar/blenderartists.org/sdfgeoff/32/15010_2.png) [@sdfgeoff](https://blenderartists.org/u/sdfgeoff)\
**Post date:** [December 6, 2012, 4:13pm UTC](https://blenderartists.org/t/common-functions/558773/5 "2012-12-06T16:13:12Z")

</div>

**@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

---

<div class="post-metadata">

**Author:** ![Xjazz](https://blenderartists.org/letter_avatar_proxy/v4/letter/x/ea666f/32.png) [@Xjazz](https://blenderartists.org/u/Xjazz)\
**Post date:** [December 13, 2012, 11:34am UTC](https://blenderartists.org/t/common-functions/558773/6 "2012-12-13T11:34:00Z")

</div>

Hi sdfgeoff

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