Count Down Timer

I need to update a script that I found here a while back. It’s just a simple python script that displays a countdown timer. Unfortunatly Blender 2.49 doesn’t work with it. I don’t know any python so any help in updating it would be greatly appricated.

own = GameLogic.getCurrentController().getOwner()

timer = 300 - own.timer
minutes = int(timer/60)
seconds = int(timer%60)

own.Text = str(minutes) + “:” + str("%02i"% seconds)

Here is the website that I got it from

try this code :

ob = GameLogic.getCurrentController().getOwner()

timer = 300 - ob[“timer”]
minutes = int(timer/60)
seconds = int(timer%60)

ob[“Text”] = str(minutes) + “:” + str("%02i"% seconds)

Thanks that works.

but it still says “Method getOwner() is deprecated please use the owner property instead”. I would like to get everything updated, but at least it works now.

replace :
ob = GameLogic.getCurrentController().getOwner()
ob = GameLogic.getCurrentController().owner

Ok great thanks very much.

Just one more quick question. I found a video script and when I ran that it had the same error plus a depreciated “getSensor()” so I just replaced it with “sensor” and that works great but I don’t know how to fix “depreciated Method isPositive()”. It says to use “the read-only positive property in stead”. If I could fix this then everything would be up to date with the newest version of blender and I wouldn’t have any more errors from my scripts.

This is the line that needs fixed.

if contr.sensors[0].isPositive():

if contr.sensors[0].positive:

Ok that fixes everything. :slight_smile:

Thank you so much. Now I can have a count down timer for my game and a video playing on the main menu. Plus it doesn’t use GLSL to play the video.

np , if you need any more help just PM me

you can also convert those deprecated syntax with blender. Go to Text wndow>> click Text >> click Text Plugins >> then Convert BGE 2.49. Note: you need to have python installed