IPO "pydrivers.py" not working in saved runtime?

Hello everybody!

Here is an attempt to create running wall clock simulator.
It uses pydrivers.py supported by IPO and seems to work ok
when ALT-A animation is activated and also in game mode INSIDE
blender.

download .blend here: http://www.simnet.is/~zt/clock.blend

PROBLEM: why the simulation is not working in saved runtime (.exe file)?
This is the same in Windows and Linux :frowning:

Does it have to do anything with Python paths?
Did I miss something? Please advise!

Zbigniew. [email protected]

I think that problem is with time module, which you are importing in your scripts. This module is not in standart Blender libraries, so this could make problems (I think). Anyways, if someone else would run your project, he should have python installed to run it properly (these are my experiences).

Hello, thanks for reply REiKO. The problem is in fact that the Runtime is not working on THE SAME machine that runs .blend file ok. Can you run clock in your machine in blender (as game and ALT-A)? How about Save as Runtime? Does it run on your computer? So, I am still puzzled…

Oh, I found it. You have correctly set the logic bricks, but in IPO window, there is no valid IPO curve. You are using IPO channel method (which I see first time) and it works in Blender, but this method s not usable in GameLogic, if you want to make working runtime, you must make standart IPO curve (which would be maybe not what you need) or use python time module and setOrientation() method. Remember, that if you use time module, users of your program should have python installed.

I hope I helped. Good Luck :).

Thanks, I start to see bigger picture now… Did you experiment with my original file applying IPO stardard curves? If so could you send it/publish to me? I am afraid that if I make some IPO curve then it will distort the clock functionality. Or should i just make some dummy “placebo” curve to trick GameLogic into using just the “pydrivers.py”? The latter method I find particularly elegant.
What do you mean by suggesting setOrientation method, could you show a code example? apply into the file?
Thanks in advance :slight_smile:
Happy blending…

BTW: Does it mean that even after if I get IPO “pydrivers.py” working in BLENDER (after pressing P for Game) this will never work in Runtime executable?
What would you suggest for alternative approach? I tried by setting RotZ on ALWAYS controller, but it doesn’t show up without Redraw() and then I am getting terrible flicker. Could you corrent my file and send it back. I will greaaaaaaatly appreciate!

Ok, I assume that IPO drivers will not work outside Blender. So I tried script activated by ALWAYS sensor in GameLogic.
I use second_hand, chose ALWAYS sensor connect it to Python CONTROLLER and use following script:


import time
import math
contr = GameLogic.getCurrentController()
owner = contr.getOwner()
owner.RotZ = math.radians(360 - time.localtime(time.time())[5]*6)

Nothing happens in Blender when I run Game and nothing happens in Runtime…

(BTW when I try to run it in Blender I get “GameLogic module not found error”), but when I run as Game (key P) the output is silent. Strange…

Then I tried another code:


import time
import math
import Blender

sh = Blender.Object.Get("sec_hand")
sh.RotZ = math.radians(360 - time.localtime(time.time())[5]*6)
Blender.Redraw()

I am getting the second hand of the clock moving in Blender and no errors in console when using ALT-P in script window. There is a terrible flicker like machine is just about to explode though…
And then when I compile runtime the more strange thing happens! There is an error the Blender module is not defined… Now I am completely lost… Please advise.

Maybe I´ve picked impossible task in Blender? All I wanted to do is a wall clock simulator that shows local computer time. Seemed to be a trivial task…

HI. Sorry that i dont respond immediately, but I have some work to do and I am “pending” between home and school.

There are only 3 modules, which you can use in your games: GameLogic, Rasterizer, GameKeys. Blender module is only available if users of your program (and you of course) have Blender installed. If you use time module, anyone using your program should have python installed.

Check this link for available methods, classes you can use in your game projects.

I think there is no way to gain current time without using the time module. You can make initiating code which will load and convert current time, make it global variable (for example: GameLogic.varName = varValue). and let the script assamble this value to property “seconds” of seconds handle object (I dont know the term in english) and add a logic brick

Always sensor (freq=60) -------- AND ---------- Property Actuator (add +1 to property “seconds”).

(this should add add value one to property “seconds” each second)
Then you must make an IPO curve to seconds handle object — simple 2*pi in radians after 60 frames. Then add another logic brich to seconds handle object

Property sensor (Type changed; Prop: seconds) ----- AND ----- IPO actuator (Type property; Prop: seconds).

So this way (I think) you could make working seconds handling of your clock.

I would try to make blend file, but I have some work to do.

Anyway, you can check my old project on this link— I have dealed there with time too ;).

I hope it helped a bit – feel free to ask again.

Hello again,

Thanks a lot for the response! it is valuable!

I am running Runtime and in-blender Game mode (Key P pressed) on the machine where Blender is installed. I save the runtime in Blender program directory. Still there is a error report that Blender module is missing…

I will try to decode your recipe, although it looks hard to understand at the moment. Should I introduce property seconds as integer and then work on it incrementing it? Anyway I will try to construct .blend file as you advise and submit it back to the thread.

Your example “InGame Day-Night change” deals with text display. This is possible. I am dealing with the geometry (clock hands) rotation and this is what fails all the time in runtime…

I respoect your time, but could you shortly addvise on following problem: should i expect Blender not to perform same action in game mode (P pressed) and runtime ON THE SAME MACHINE?

Be back with more finding, as you see i am hell bend to get this - “should-be-trivial” task.

Cheers, na shledanou!

OK. I had a time today, so I tried to make those clock hands and I found that it is simple.

Check this file.

The script is always assigning seconds. minutes and hours to seconds hand, minutes hand, etc., respectively to properties sec, min, hour. On each hand, there is Property sensor which is activated if that property changes. IPO actuator is playing IPO curve with property changing.

So I added IPO of 60 frames length to seconds and minutes hands and of 12 frames length to hours hand.

And thats it. Remember, that I am using time module, si you shuold have python installed.

P.S.: I havent tried to meka a runtime from it, but it definitively should work in exe form.

if you use other python modules you can just distribute the python25.dll that comes with blender. Most of the modules are in that DLL. The python documentation tells you what modules are included in it. If you use other python modules, you can just include the respective DLL’s for them as well.

Put it, as well as the other dll’s you need in the directory where the exe lives.

You don’t have to have python installed for this to work on other computers etc.

Wow! This is that simple! Simplicity is the sign of genius, they say… Many, many thanks!!! This example speaks volumes. I will study it so it’s tatooed in my brain!
Runtime goes smoothly as well - you are right!
Should you need custom music for your productions please tell me - I am a professional composer. I’d be glad to help.
Thanks kirado - yes there is a python dll about 2 MB in the program directory. I will test the runtime on the non-blender computer today to check the dependencies.
Best to all of you Blenderers!

Hello,
Now I see how the clock is coming alive. The actuator runs into relvant frame in IPO.

I adjusted code in the end of the “clock” script in the following way:


minute_factor = 1.0/60.0

secHandle.sec = sec0
minHandle.min = min0 + minute_factor*sec0
hourHandle.hour = hour0 % 12 + minute_factor*min0 + minute_factor*minute_factor*sec0

I changed the min and hour property to FLOAT type. So conseqnently the minute and hour hands can move proportionally.
Finally I added modulo operator for the hour frame calculation, so after 12 PM we still have hour hand running.

Luckily IPO is able to refer the “play head” to fraction of a frame! Cool!

Thanks again!

Ok. I am glad to help ;).