Some more python questions.

Just a couple of python questions, not urgent, and I’m sure most or all of these are easily possible, just wondering if anyone knows how to achieve these (: thanks in advanced

  • Displaying an objects location on a text object
  • Getting the fps on a text object
  • Opening a URL externally

set target->object to get position

target=scene.objects[‘target’]
own[‘Property’]=str(object.worldPosition)

in text object

always -----------and------------copy property text from (own[‘Property’] you set )

Now the time you need last frame system time Vs this frame,

I think python can trigger external apps, if you know where they are, so you will need to have a property set by the end user
own[‘path’]=“C:\Location\application.exe” etc.

file is ready :smiley:



import bge




def main():


    cont = bge.logic.getCurrentController()
    own = cont.owner
    
    target=own['Target']
    scene=bge.logic.getCurrentScene()
    T =scene.objects[target]
    own['Position']=str(T.worldPosition)
    


main()




Attachments

LocationCopyExample.blend (447 KB)

1: like blueprintrandom said.

2: The logic class actually already has a “getAverageFrameRate” function. This is probably what you are looking for.
http://www.blender.org/documentation/blender_python_api_2_64_release/bge.logic.html#bge.logic.getAverageFrameRate
From there it follows the same principal for getting any property to text.

3: You can use the webbrowser module:
https://docs.python.org/3.4/library/webbrowser.html

An example that opens a tab in the default browser and goes to the Google website:

import webbrowser
webbrowser.open("http://www.google.com",0,True)

Hope this all helps! :yes:

Interesting, thanks guys!