RenderScripts / LogicScripts


#1

Hi (dunno why I can’t log with my regular ID…)
I’ve two questions about lua scripts (RenderScripts / LogicScripts):

1- Is the “Setup” callback totally asynchronous or is it called after a precise function in the main program ?

2-Can I create a GpuTexture in the main program (python context) and pass it with “Set” function ?


#2

Hello,
For the first one, I don’t think it’s asynchronous, it’s in the lua main vm thread.
For the second, you can send any engine pointer from python to lua.
Enjoy :wink:


#3

Ah okay, it seems to work:
(self is a reference to my custom scene)

    self.test_RenderScript = gs.RenderScript(self.scene_path + "datas/test_RenderScript.lua")
    self.scene3d.AddComponent(self.test_RenderScript)
    ...
    self.test_RenderScript.Set("texture", self.texture_arriere_plan)

The script just display a 2d texture at EndDrawFrame callback.
It works only when the script is initialized.
But the only way I can wait the initialization seems to be:
`while not self.test_RenderScript.IsInitialized(): pass
…But it don’t work. Even after an Update().
How can I elegantly wait for my scipt initialization to give it my variables ?