Cool VL Viewer forum
http://sldev.free.fr/forum/

Lua scripting related requests
http://sldev.free.fr/forum/viewtopic.php?f=9&t=1737
Page 6 of 10

Author:  ZaneZimer [ 2017-04-17 17:25:25 ]
Post subject:  Re: Lua scripting related requests

It seems to be related to using CallbackAfter() more than one time in my script for different callback functions. Which ever one is executed first is the one that will continue to work for future calls. Any CallbackAfter() set after the first one, doesn't seem to fire.

Author:  Henri Beauchamp [ 2017-04-17 17:33:40 ]
Post subject:  Re: Lua scripting related requests

ZaneZimer wrote:
It seems to be related to using CallbackAfter() more than one time in my script for different callback functions. Which ever one is executed first is the one that will continue to work for future calls. Any CallbackAfter() set after the first one, doesn't seem to fire.
Strange. I'll have a look at it.

Author:  ZaneZimer [ 2017-04-17 17:46:25 ]
Post subject:  Re: Lua scripting related requests

Henri Beauchamp wrote:
Strange. I'll have a look at it.
Thanks. This test.lua may help illustrate:
Code:
local function Callback1()
  print("Callback 1")
end

local function Callback2()
  print("Callback 2")
end

function OnLogin()
    CallbackAfter(2, Callback1)
    CallbackAfter(3, Callback2)
end
Callback1 is executed 2 times where Callback2 is never executed.

Author:  Henri Beauchamp [ 2017-04-17 19:08:38 ]
Post subject:  Re: Lua scripting related requests

Yes, this is very weird, because my code does properly store each callback in a different slot of the LUA_REGISTRYINDEX table, and does pass the corresponding (Lua-engine-allocated) reference to the callback. With debug messages on, I can see both callbacks properly queued with different references, and then called with the corresponding references. It's like if Lua was returning the first callback data (function + parameters) for *both* references... I'll investigate further but to me, it looks like a Lua bug !

Author:  Henri Beauchamp [ 2017-04-17 21:58:07 ]
Post subject:  Re: Lua scripting related requests

I found the bug: my code missed a lua_pop() in HBViewerAutomation::doAfterIntervalCallback(). In fact, as is, it should never have worked at all (because on lua_pcall() the first stack element is a number instead of the function "pointer", which only appears as the second element on stack), but apparently, a bug in Lua makes it more or less work (but only calling the first function)... :shock:

Fixed for next release.

Author:  ZaneZimer [ 2017-04-17 22:09:26 ]
Post subject:  Re: Lua scripting related requests

Henri Beauchamp wrote:
I found the bug: my code missed a lua_pop() in HBViewerAutomation::doAfterIntervalCallback(). In fact, as is, it should never have worked at all (because on lua_pcall() the first stack element is a number instead of the function "pointer", which only appears as the second element on stack), but apparently, a bug in Lua makes it more or less work (but only calling the first function)... :shock:

Fixed for next release.
Ugh, those are some of the most insidious types of bugs to trace. A few effects can combine and 'sort of work' but they mask what the real problem is. Thanks for tracking it down.

Author:  Henri Beauchamp [ 2017-04-29 09:35:13 ]
Post subject:  Re: Lua scripting related requests

ZaneZimer wrote:
As a side, a reload menu option might be nice to stop and reload the automation script instead of popping the file picker dialog.
Implemented in today's release.

Author:  ZaneZimer [ 2017-04-30 13:38:10 ]
Post subject:  Re: Lua scripting related requests

Henri Beauchamp wrote:
ZaneZimer wrote:
As a side, a reload menu option might be nice to stop and reload the automation script instead of popping the file picker dialog.
Implemented in today's release.
Thanks. I appreciate the add, as it saves me a few clicks when working on my automation and testing it.

Author:  ZaneZimer [ 2017-04-30 23:59:27 ]
Post subject:  Re: Lua scripting related requests

As I was working on my Lua automation today, a couple of ideas for enhancements occurred to me:
  • TeleportAgentToPos() - allow a 'look at' parameter similar to the LSL one for llTeleportAgentGlobalCoords()
  • GetGridSimAndPos() - might need to have the cardinal direction returned too to be symetric with TeleportAgentToPos()
  • GetAgentInfo() new - similar to llGetAgentInfo() either for self only or any avatar UUID
Any thoughts?

Author:  Henri Beauchamp [ 2017-05-04 09:07:20 ]
Post subject:  Re: Lua scripting related requests

ZaneZimer wrote:
As I was working on my Lua automation today, a couple of ideas for enhancements occurred to me:
  • TeleportAgentToPos() - allow a 'look at' parameter similar to the LSL one for llTeleportAgentGlobalCoords()
  • GetGridSimAndPos() - might need to have the cardinal direction returned too to be symetric with TeleportAgentToPos()
  • GetAgentInfo() new - similar to llGetAgentInfo() either for self only or any avatar UUID
Any thoughts?

Please note that viewer-side Lua scripting is not meant to replace server-side LSL scripting (especially since you can have LSL scripts invoking Lua commands, bringing a whole new lot of possibilities for your scripts). So, I'm not going to reimplement on the viewer side all what already exists on server side with LSL...

However, I implemented the following for next release:
  • GetAgentInfo() will return a table for the agent (i.e. your avatar only) containing sundry info (legacy name, display name, agent UUID, maturity, active group, control flags, flying and sitting booleans, RLV info/restrictions...).
  • TeleportAgentToPos() was extended to accept a boolean as an optional fourth parameter which, when present and true, causes the TP to preserve the "lookat" vector (i.e. your avatar will face the same direction on arrival as on departure): I don't find any practical use in adding a facing vector, since there is little to no chance to know what direction to look at for a random destination: better trusting the builder and parcel owner about what your avatar should face on arrival.
  • TeleportAgentHome() has been added.
There will also be group-related functions for getting agent group info and setting agent group and title (role).

Page 6 of 10 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/