CallFunction/callLua bug

Describe the bug:

engine.on("LocalOnButtonPressed",function(button){
  Crayta.callLua("PingToLua")
})
engine.on("PingFromLua",function(){
  console.log('Ping received')
})
function ScriptName:PingToLua()
  self:GetEntity().widgetName:CallFunction("PingFromLua")
end

‘engine.on(“PingFromLua”)’ never executes

How do you cause this bug?

  • List the steps
    Try to replicate the JS to Lua to JS ping from above (starting with a engine.on(‘LocalOnButtonPressed’,…)). Add print/log statements and see that it doesn’t work.
    (define widget and place script and widget on the user entity as example)

Your Crayta username:
Daigoro

Game seen in (including “Hub” or “Editor for XYZ”):
All test games that i tried.
How regularly do you see this? (E.g. 2/3 times - please try 3 times if possible):
10/10 (+Vilva can confirm)

1 Like

Hey there @Ya_shi_shi !

Thank you for working hard on isolating the issue! :muscle:t2: :slightly_smiling_face:
I have entered a ticket in for you so that our Internal team can further investigate this issue.

@Ya_shi_shi our JS wizards are looking into this, it seems maybe only the log output is missing? While we investigate in the meantime I’ve heard the suggestion try using console.info rather than console.log if log isn’t working!

1 Like

Thanks for the feedback, it does indeed not trigger anything. I create a div in a function that is structured like that and LocalOnButtonPressed/-Released as source of the function chain causes the final js function to ignore the ping/call from Lua.

I hope this helps to isolate the issue further: If i wrap Crayta.callLua("PingToLua") into a window.requestAnimationFrame it works as intended.

So this is the only “fix” I’ve found so far, which makes it seem like there is a window between two frames (in which LocalOnButtonPressed fires in widgets), in which js events can’t be called trough Lua.