Page 1 of 1

problem with cel//urls in lua scripts

Posted: 30.04.2010, 09:27
by jogad
Hello,

This is a very minimal script that tries to display a cel//url every 5 seconds
(installed in celestia/extras/defil an run together with lua_plugins)

Code: Select all

local t, t0 =0,0
local vue = 1
local cels={}
local active = false

defil = CXBox:new()
    :init(0, 0, 0, 0)
    :movable(false)
    :attach(screenBox,0, 0, 0, 0)

defil.Customdraw = function(this)
   if not active then return end
   t=celestia:getscripttime()
   if t - t0>= 5 then
      celestia:print("celURL #"..vue,5)
      celestia:seturl(cels[vue]) --           <== problem here
      vue = vue % #cels + 1
      t0=t
   end
end

local toggleDefil = function ()
   active = not active
   if active
      then celestia:print("defil active",4)
      else celestia:print("defil inactive",4)
   end
end

keymap["d"] = toggleDefil

-- 20 cel://urls as example
cels = {
"cel://SyncOrbit/Sol:Earth/2004-05-20T22:25:58.53762?x=SFWD6wim9P///////////w&y=Tqej4HXdbQ&z=hRnrmF2p/f///////////w&ow=-0.404799&ox=0.397894&oy=0.584917&oz=-0.579387&track=Polaris&select=HIP%2053612&fov=84.8542&ts=1000&ltd=0&p=0&rf=1183&lm=2&tsrc=0&ver=3",
"cel://Chase/Sol:Earth:ISS/2003-08-19T01:54:43.50915?x=du/YfyI&y=uEV39vP//////////////w&z=R+JBy/T//////////////w&ow=0.143802&ox=0.672601&oy=-0.440693&oz=0.576817&select=Sol:Earth:ISS&fov=68.3125&ts=100&ltd=0&p=0&rf=40855&lm=49152&tsrc=0&ver=3",
"cel://Follow/Sol:Earth/2003-09-08T17:06:17.48057?x=gCtfeVwmef3//////////w&y=RtNTaKftPQ&z=EDhTrlarM////////////w&ow=0.583109&ox=0.211381&oy=0.778011&oz=-0.1&select=Sol:Earth&fov=23.221&ts=10000&ltd=0&p=0&rf=2711&lm=49152&tsrc=0&ver=3",
"cel://Follow/Sol:Earth/2005-04-16T07:10:22.54873?x=AABBcLjv2dfq/////////w&y=AADAgi1CKH64&z=AAAEh/hxw663/////////w&ow=0.365811&ox=0.459924&oy=0.685501&oz=0.429815&select=Sol:Earth&fov=25.746&ts=1e+006&ltd=0&p=0&rf=2083&lm=49154&tsrc=0&ver=3",
"cel://Follow/Sol/2248-10-10T06:03:10.05316?x=AACqn72DO3oV&y=AABYwLMdOLQv&z=AAB4qjfrA4B4/////////w&ow=-0.101865&ox=-0.199312&oy=0.95808&oz=0.178833&select=Sol&fov=50.9753&ts=1e+006&ltd=0&p=0&rf=2083&lm=49154&tsrc=0&ver=3",
"cel://PhaseLock/Sol:Earth/Sol:Earth:Moon/2003-08-01T22:45:20.15578?x=wYt0jpERrv///////////w&y=rCFi/fU8wv///////////w&z=9rpP6PR3Cw&ow=-0.444334&ox=0.559807&oy=-0.429046&oz=-0.552361&select=Sol:Earth:Moon&fov=1.18416&ts=100000&ltd=0&p=0&rf=2711&lm=49152&tsrc=0&ver=3",
"cel://PhaseLock/Sol:Earth/Sol/2007-08-28T07:19:24.20184?x=mS11i+DC5uT//////////w&y=cVpm17uEAg&z=reVJUMG++f///////////w&ow=-0.375458&ox=0.599217&oy=-0.376007&oz=-0.598823&select=Sol:Earth:Moon&fov=1.59564&ts=1000&ltd=0&p=0&rf=35735&lm=49156&tsrc=0&ver=3",
"cel://Chase/Sol:Earth:Moon/2003-09-29T08:51:07.62031?x=Uyjq5huI7P///////////w&y=LC8yE/gXwf///////////w&z=wXHD5NwC8////////////w&ow=-0.0200548&ox=-0.0247442&oy=-0.730913&oz=0.681727&select=Sol:Earth:Moon&fov=25&ts=10000&ltd=0&p=0&rf=2711&lm=49152&tsrc=0&ver=3",
"cel://Follow/Sol:Earth:ISS/2004-01-21T20:41:12.64836?x=s5OF1BL3/////////////w&y=c8Nu6P///////////////w&z=56h00DLx/////////////w&ow=-0.222393&ox=-0.537671&oy=-0.799421&oz=0.149589&select=Sol:Earth:ISS&fov=0.47917&ts=50&ltd=0&p=0&rf=68503&lm=49158&tsrc=0&ver=3",
"cel://PhaseLock/Sol:Earth:ISS/Sol/2004-01-21T23:37:53.97263?x=R2EUAVr5/////////////w&y=NjH+/////////////////w&z=ayY&ow=0.195459&ox=0.679555&oy=0.195459&oz=-0.679555&select=Sol&fov=1.97233&ts=1&ltd=0&p=0&rf=2967&lm=49152&tsrc=0&ver=3",
"cel://Follow/Sol:4179%20Toutatis/2004-09-28T15:54:49.07196?x=zPLWywr1/////////////w&y=KbVfW5X4/////////////w&z=NBof6L0D&ow=0.031327&ox=-0.354344&oy=-0.430295&oz=0.829642&select=Sol:Earth&fov=45&ts=1&ltd=0&p=0&rf=6419&lm=2&tsrc=0&ver=3",
"cel://PhaseLock/Sol:Earth/Sol/1210-09-17T10:22:54.77193?x=p4K24FEoAw&y=V83S3Hfo3P///////////w&z=7aCWGHF6JQ&ow=-0.471689&ox=0.581909&oy=-0.413836&oz=-0.517331&select=Sol:Venus&fov=0.013397&ts=100&ltd=0&p=0&rf=-1374118629&lm=-1074932214&tsrc=0&ver=3",
"cel://Follow/Sol:Earth/1278-08-25T14:18:46.02806?x=IwKRXRTAHg&y=OJaHU0wEEA&z=RMdeXkkA2v///////////w&ow=0.752377&ox=0.116945&oy=-0.62964&oz=0.154291&fov=0.00181&ts=10&ltd=0&p=0&rf=-1374118629&lm=-1074932214&tsrc=0&ver=3",
"cel://SyncOrbit/Sol:Halley/2061-05-06T20:28:19.92988?x=E6TuFVsI8I8C&y=brSnVTLgze///////////w&z=uSdcVsqxg73//////////w&ow=-0.137349&ox=0.72066&oy=0.103172&oz=0.67167&select=Sol:Halley&fov=37.5174&ts=1&ltd=0&p=0&rf=56215&lm=0&tsrc=0&ver=3",
"cel://SyncOrbit/Sol:Earth:Moon/2004-06-23T19:52:30.92834?x=+27lgqIHblz3/////////w&y=WfJm2OOgjvI&z=1BAHJktwZPr+/////////w&ow=-0.58167&ox=-0.430518&oy=-0.610773&oz=0.321356&select=Sol:Earth&fov=0.004361&ts=1e-006&ltd=0&p=0&rf=40839&lm=128&tsrc=0&ver=3",
"cel://Freeflight/2008-12-26T09:58:24.56973?x=4HoVmJ8+r5dw/////////w&y=v7MVGG59MREF&z=SRjzNPMvwkTb/////////w&ow=0.107477&ox=0.615451&oy=-0.775227&oz=0.093236&track=Sol:Saturn:Pandora&fov=35.5732&ts=5000&ltd=0&p=0&rf=57239&lm=0&tsrc=0&ver=3",
"cel://PhaseLock/Sol:Earth/Sol:Earth:Moon/2008-12-17T11:11:14.36992?x=6poN1OkvEA&y=Ni6RP1xf8P///////////w&z=tnnv4cQuJg&ow=-0.389271&ox=0.590092&oy=-0.379906&oz=-0.596599&select=Sol:Earth&fov=0.796068&ts=1e+006&ltd=0&p=0&rf=-1374102141&lm=-1074933760&tsrc=0&ver=3",
"cel://PhaseLock/Sol:Earth/Sol:Earth:Moon/2009-03-25T01:54:36.94363?x=lJrsmQ2xsw0&y=nn7rgtUiFg&z=BN4r7yOiAg&ow=0.378681&ox=-0.589507&oy=-0.388309&oz=-0.59858&select=Sol:Earth&fov=3.25781&ts=200000&ltd=0&p=0&rf=-1407656557&lm=-1074933760&tsrc=0&ver=3",
"cel://PhaseLock/Sol:Earth/Sol:Earth:Moon/2006-07-08T11:09:50.17267?x=dRI6S2P4EAs&y=eVSlzzyTDg&z=sBKGt5WZBw&ow=0.36545&ox=-0.537889&oy=-0.404679&oz=-0.642928&select=Sol:Earth:Moon&fov=35.5795&ts=100000&ltd=0&p=0&rf=-1407656557&lm=-1074933760&tsrc=0&ver=3",
"cel://SyncOrbit/Sol:Earth:Moon/2009-01-29T17:03:42.69730?x=lLfOceENAg&y=jwUn0whyAg&z=mn5FNeJk9P///////////w&ow=-0.553858&ox=-0.451806&oy=-0.54706&oz=0.435704&select=Sol:Earth&fov=23.8374&ts=200000&ltd=0&p=0&rf=-1407656557&lm=-1074933760&tsrc=0&ver=3",
}


The left upper overlay shows that the seturl command is launched as expected every 5 seconds but is not displayed properly.

errcelurl.jpg

The screen remains black and the distance is weird. :roll:

This problem doesn't occur in celx scripts nor in lua scripts when the seturl command is called from a keystroke or a mouse click.

Re: problem with cel//urls in lua scripts

Posted: 30.04.2010, 17:47
by Vincent
Jo?l,

I can indeed reproduce the problem on my system.
What is interesting is that it doesn't occure when
the observer is travelling after pressing the G key...

Re: problem with cel//urls in lua scripts

Posted: 30.04.2010, 19:34
by Chuft-Captain
Guys,
This may have something to to with an undefined reference frame for the observer when using Phaselock.

Have a look at this post: viewtopic.php?f=3&t=13628&p=113838&hilit=hell#p113838
.... just seems to be a slightly similar situation and similar symptoms....

Read Chris' comments in that thread. (I don't know if he's yet got to the bottom of that particular issue, but if the 2 problems are related, that info alone might provide some insight.)

Hope this helps.

Re: problem with cel//urls in lua scripts

Posted: 02.05.2010, 19:21
by Vincent
I've managed to track the problem. :)
Actually, it is due to the os.setlocale("", "numeric") call which is used in the Lua Tools to display numeric values with
the system locale. In some locale, e.g., in France, the decimal-point separator is replaced with a comma. So decimal
values inside URL strings are not correctly parsed anymore.

To avoid this problem, one has to make sure that the numeric category is set to the "C" locale when using URL strings.
In the case of Jogad's scripts, this can be fixed by adding the two following lines:

Code: Select all

defil.Customdraw = function(this)
   if not active then return end
   t=celestia:getscripttime()
   if t - t0>= 5 then
      celestia:print("celURL #"..vue,5)
      os.setlocale("C", "numeric") -- Set the numeric category to the "C" locale
      celestia:seturl(cels[vue])
      os.setlocale("", "numeric") -- Set the numeric category to the system locale
      vue = vue % #cels + 1
      t0=t
   end
end

Re: problem with cel//urls in lua scripts

Posted: 09.05.2010, 07:48
by jogad
Hi Vincent,

Amazing to see that even few lines of code may cause so much trouble and and how you solve the problems easily. 8)

But I have still a problem with it. :(

If I let this script running for a while, it causes Celestia to crash sooner or later.
Time may be rather long but the issue inevitably happens.

It is difficult to be certain of that, but it seems it happens when running together with the compass tool of the Lua_Plugins.
Apparently there is no problem with the same tool of the Lua_Edu_Tools.

Re: problem with cel//urls in lua scripts

Posted: 09.05.2010, 10:37
by Vincent
jogad wrote:If I let this script running for a while, it causes Celestia to crash sooner or later.
Time may be rather long but the issue inevitably happens.

It is difficult to be certain of that, but it seems it happens when running together with the compass tool of the Lua_Plugins.
Apparently there is no problem with the same tool of the Lua_Edu_Tools.

Hi Jo?l,

I've left the script running for almost 10 mn with all other plugins enabled.
I couldn't experience any crash, though.

Re: problem with cel//urls in lua scripts

Posted: 29.06.2010, 17:26
by jogad
Hello,

My problem is always pending and I get mad with it. :twisted:
Of course the little script above is not important but I plan to use this possibility in my diaporama plugin.

Vincent wrote:I've left the script running for almost 10 mn with all other plugins enabled.
I couldn't experience any crash, though.
Ten minutes are not enough. Time may be longer than that. On my system in happens generally between 15mn and 1/2 hour with display time set to 3 seconds.

Now I am sure that the the conflicting plugin is the compassBox.
If I deactivate it, the script may run for hours without problem.
... and no problem with other plugins.

Investigating I found this error with the lua_edu_tools version of compassBox

errCompass.jpg

This has nothing to do with the bug I encounter (in the lua plug-in version) but I report it anyway. :!: