Cool VL Viewer forum

View unanswered posts | View active topics It is currently 2017-10-24 09:26:41



Reply to topic  [ 79 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8  Next
Lua scripting related requests 
Author Message

Joined: 2016-06-19 21:33:37
Posts: 86
Location: San Francisco bay area, CA, USA
Reply with quote
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.


2017-04-17 17:25:25
Profile

Joined: 2009-03-17 18:42:51
Posts: 3638
Reply with quote
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.


2017-04-17 17:33:40
Profile WWW

Joined: 2016-06-19 21:33:37
Posts: 86
Location: San Francisco bay area, CA, USA
Reply with quote
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.


2017-04-17 17:46:25
Profile

Joined: 2009-03-17 18:42:51
Posts: 3638
Reply with quote
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 !


2017-04-17 19:08:38
Profile WWW

Joined: 2009-03-17 18:42:51
Posts: 3638
Reply with quote
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.


2017-04-17 21:58:07
Profile WWW

Joined: 2016-06-19 21:33:37
Posts: 86
Location: San Francisco bay area, CA, USA
Reply with quote
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.


2017-04-17 22:09:26
Profile

Joined: 2009-03-17 18:42:51
Posts: 3638
Reply with quote
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.


2017-04-29 09:35:13
Profile WWW

Joined: 2016-06-19 21:33:37
Posts: 86
Location: San Francisco bay area, CA, USA
Reply with quote
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.


2017-04-30 13:38:10
Profile

Joined: 2016-06-19 21:33:37
Posts: 86
Location: San Francisco bay area, CA, USA
Reply with quote
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?


2017-04-30 23:59:27
Profile

Joined: 2009-03-17 18:42:51
Posts: 3638
Reply with quote
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).


2017-05-04 09:07:20
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 79 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8  Next

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.