Interesting, i’ve thought of using OSC too (am otherwise a bit of a supercollider hangaroundist). Do you read it from a socket and/or how? I’ve just made a remote controllable Blender engine using a simple non-protocol (just sending out commands as strings) but might be better off using something like OSC in the future.
The code you posted was quite nonsense
What do you want to do? Set a property of some Blender object to some value, or just assign the value to some python variable/object? In Python it is simply (given you have the i already, as you say):
a=i
That creates a new object ‘a’ with the value from ‘i’, which is int so a becomes int too – Python is not statically typed like C or Java so you never specify the types, it just figures them out itself.
Normally in Python that’s all you need, but to make things persistent in GameBlender people seem to use the GameLogic module itself as a kind of a container (a new Register module might come for this in future versions). So that way it’d be:
import GameLogic
GameLogic.a=i
I don’t do that myself, but have all my code running in external modules where it seems to work like normally with Python…
And finally, if you want put that value to a property of some Blender/gameobject, i.e. something created in Blender that may be a visible object in the game and can have property driven IPOs etc., you first need to get the reference to that object and can then set the property similarly.
https://blenderartists.org/forum/viewtopic.php?t=3245&highlight= introduces a nice way of dealing with gameobjects in Python, but I’ll paste the particular part here as well:
import GameLogic
controller = GameLogic.getCurrentController()
owner = controller.getOwner()
owner.a=i
I actually don’t know what setProperty and setValue are for, 'cause you can set them directly/normally like this?-o Then again, this is still quite new for me too…
~Toni