.CelX equivalent to the Goto URL in .CEL ?

All about writing scripts for Celestia in Lua and the .cel system
Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

.CelX equivalent to the Goto URL in .CEL ?

Post #1by Chuft-Captain » 09.04.2009, 21:22

In CEL scripts you can goto a URL by pasting the copied URL straight from Celestia into a "goto URL" command in your CEL script.

I can't find an obvious equivalent in CELX.
(ie. There should be an appropriate "observer" method IMO)

Can anyone point me in the right direction please.

Cheers
CC
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Re: .CelX equivalent to the Goto URL in .CEL ?

Post #2by selden » 10.04.2009, 00:09

I don't think there is a Method in CELX which invokes a URL.

However, it's a hack, but you can incorporate a .CEL script in a .CELX script.
Selden

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Re: .CelX equivalent to the Goto URL in .CEL ?

Post #3by Chuft-Captain » 10.04.2009, 02:01

selden wrote:I don't think there is a Method in CELX which invokes a URL.
Hmm... damned annoying! :x

selden wrote:However, it's a hack, but you can incorporate a .CEL script in a .CELX script.
Yep, I've never been too keen on that hack. It should work, but probably not with the speed I need.

There are some methods for position:
http://en.wikibooks.org/wiki/Celestia/Celx_Scripting/CELX_Lua_Methods#position
but there seems to be "get" methods only, no "set" methods.

Even if there were, then there's still orientation, frame, etc.. to set as well.

Cheers
CC
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: .CelX equivalent to the Goto URL in .CEL ?

Post #4by chris » 10.04.2009, 02:20

I think that this is an unfortunate omission from celx scripting. It shouldn't be hard to fix.

--Chris

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Re: .CelX equivalent to the Goto URL in .CEL ?

Post #5by Chuft-Captain » 10.04.2009, 03:02

chris wrote:I think that this is an unfortunate omission from celx scripting. It shouldn't be hard to fix.

--Chris
I'll look forward to that. Thanks.
(pls. let me know when fixed and I'll test)

CC

PS. Sent you a PM on another matter (infoURL's)
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Re: .CelX equivalent to the Goto URL in .CEL ?

Post #6by Vincent » 10.04.2009, 09:18

CC,

Here's an example that shows how to set celURL parameters using a celx script:

Code: Select all

--"cel://SyncOrbit/Sol:Earth/2008-06-21T13:21:05.18439?x=fbeWQgCMEQ&y=fg7E0iILKA&z=PMj5mKdiBg
-- &ow=-0.573595&ox=-5.80523e-006&oy=-0.819139&oz=-3.23302e-006
-- &select=Sol:Earth&fov=60&ts=0&ltd=0&p=0&rf=18470279&lm=2017986560&tsrc=0&ver=3"

obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")

-- Define Geocentric frame of reference
e_frame = celestia:newframe("planetographic", earth)

-- Define position and orientation using cel-style URL.
u_pos = celestia:newposition("fbeWQgCMEQ", "fg7E0iILKA", "PMj5mKdiBg")
u_rot = celestia:newrotation(-0.573595, -5.80523e-006, -0.819139, -3.23302e-006)

-- Convert position and orientation from Universal to Geocentric coordinates.
e_pos = e_frame:from(u_pos)
e_rot = e_frame:from(u_rot)

obs:setposition(e_pos)
obs:setorientation(e_rot)

-- Set frame of reference
obs:synchronous(earth)

-- Set time
t = celestia:utctotdb(2008, 6, 21, 3, 21, 5.18439)
celestia:settime(t)

-- Set fov
obs:setfov(math.rad(60))

-- Set timescale
celestia:settimescale(0)


However, I agree that using a celestia:seturl function would be handier.
Another issue is that celURLs include some rendering options that can't be
"decoded" by the user to be used in the script.

So, if you can compile your own version of celestia, you can try to apply
the following short patch that adds the celestia:seturl function to celx scripting:

Code: Select all

Index: celx.cpp
===================================================================
--- celx.cpp   (revision 4698)
+++ celx.cpp   (working copy)
@@ -3303,7 +3303,18 @@
     return 0;
 }
 
+static int celestia_seturl(lua_State* l)
+{
+    Celx_CheckArgs(l, 2, 2, "One argument expected for celestia:seturl()");
+    CelestiaCore* appCore = this_celestia(l);
 
+    string url = Celx_SafeGetString(l, 2, AllErrors, "Argument to celestia:seturl() must be a string");
+    appCore->goToUrl(url);
+
+    return 0;
+}
+
+
 static void CreateCelestiaMetaTable(lua_State* l)
 {
     Celx_CreateClassMetatable(l, Celx_Celestia);
@@ -3388,6 +3399,7 @@
     Celx_RegisterMethod(l, "dsos", celestia_dsos);
     Celx_RegisterMethod(l, "windowbordersvisible", celestia_windowbordersvisible);
     Celx_RegisterMethod(l, "setwindowbordersvisible", celestia_setwindowbordersvisible);
+    Celx_RegisterMethod(l, "seturl", celestia_seturl);
 
     lua_pop(l, 1);
 }
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Re: .CelX equivalent to the Goto URL in .CEL ?

Post #7by Chuft-Captain » 11.04.2009, 00:20

Thanks for the example Vincent.

That's saved me quite a bit of time. See here: http://shatters.net/forum/viewtopic.php?f=2&t=13666

CC
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Re: .CelX equivalent to the Goto URL in .CEL ?

Post #8by selden » 11.04.2009, 01:07

Vincent,

I just now tested Celestia after applying your patch, and the Celx code

celestia:seturl

works great!

(Of course celestia:geturl would be helpful, too, so one could script their capture.)
Selden

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Re: .CelX equivalent to the Goto URL in .CEL ?

Post #9by Vincent » 11.04.2009, 09:28

Chuft-Captain wrote:Thanks for the example Vincent.

That's saved me quite a bit of time. See here: http://shatters.net/forum/viewtopic.php?f=2&t=13666
CC,
You're welcome. And that's a great video ! :)


selden wrote:I just now tested Celestia after applying your patch, and the Celx code

celestia:seturl

works great!
Selden,
Once again, thanks for testing the patch.

selden wrote:(Of course celestia:geturl would be helpful, too, so one could script their capture.)
Yes, that would be indeed a useful feature.
However, copying an URL to clipboard is a platform dependant process, so I'd suggest to
wait for the Qt cross-platform version before adding the celestia:geturl function to celx.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 10 months
Location: Nancy, France

Re: .CelX equivalent to the Goto URL in .CEL ?

Post #10by Vincent » 18.07.2009, 09:45

The seturl/geturl and synchronizetime/istimesynchronized methods have been added to the celestia object in celx scripting.
This concerns the current development versions, i.e., both the trunk and the 1.6.1 branch in SVN.

More information about how to use these commands can be found here:
http://en.wikibooks.org/wiki/Celestia/C ... tia#seturl

The following celx script gives an example about how to use these commands.
It shows the day/night length in Paris on the equinoxes and solstices.

Code: Select all

-- Title: Show day/night length in Paris on equinoxes and solstices
-- Author: Vincent <vince.gian@free.fr>

obs = celestia:getobserver()
obs:singleview()
wait(1)
obs:splitview("h", 0.5)
obs:splitview("v", 0.5)
obs = celestia:getobservers()
obs[2]:splitview("v", 0.5)

celestia:synchronizetime(false)
celestia:unmarkall()

sol = celestia:find("Sol")
earth = celestia:find("Sol/Earth")
loc = celestia:find("Sol/Earth/Paris")

earth:addreferencemark{type = "visible region", color = "yellow", opacity = 0.5, tag = "terminator", target = sol}
loc:mark("red", "disk", 10, 0.8, "", false)

-- Autumn Equinox
url1 = "cel://Follow/Sol:Earth/2009-09-22T11:00:0?x=mH9RlBJa&y=NzOFNqGfVQE&z=J9A3FXnja////////////w&ow=0.388908&ox=0.591889&oy=-0.590386&oz=-0.387121&select=Sol:Earth:Paris&fov=16.0765&ts=1000&ltd=0&p=0&rf=1693063&lm=2017986688&tsrc=0&ver=3"

-- Spring Equinox
url2 = "cel://Follow/Sol:Earth/2009-03-20T11:00:0?x=0/pVMFtV&y=wLI7PKGfVQE&z=+ARbV3bja////////////w&ow=0.389986&ox=0.593566&oy=-0.5887&oz=-0.386035&select=Sol:Earth:Paris&fov=16.0765&ts=1000&ltd=0&p=0&rf=1693063&lm=2017986688&tsrc=0&ver=3"

-- Winter Solstice
url3 = "cel://Follow/Sol:Earth/2009-12-21T11:00:0?x=Dn3js1lc&y=sE1o0KCfVQE&z=WObLkHnja////////////w&ow=0.393271&ox=0.598528&oy=-0.583654&oz=-0.382688&select=Sol:Earth:Paris&fov=16.0765&ts=1000&ltd=0&p=0&rf=1693063&lm=2017986688&tsrc=0&ver=3"

-- Summer Solstice
url4 = "cel://Follow/Sol:Earth/2009-06-21T11:00:0?x=4tT717VX&y=ILGVqKGfVQE&z=IIpesXjja////////////w&ow=0.390284&ox=0.594004&oy=-0.588258&oz=-0.385734&select=Sol:Earth:Paris&fov=16.0765&ts=1000&ltd=0&p=0&rf=1693063&lm=2017986688&tsrc=0&ver=3"

obs = celestia:getobservers()
celestia:seturl(url1, obs[1])
celestia:seturl(url2, obs[2])
celestia:seturl(url3, obs[3])
celestia:seturl(url4, obs[4])

text = [[
 Spring Equinox      Summer Solstice


Autumn Equinox     Winter Solstice
]]

while true do
    celestia:print(text, 1, 0.5, 0.5, -11, 1)
    wait(0)
end
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Re: .CelX equivalent to the Goto URL in .CEL ?

Post #11by Chuft-Captain » 18.07.2009, 12:53

Vincent,

Did these make it into 1.6.0 final? ... or just miss?

CC

EDIT: OK, I just gave it a try and it looks like it didn't make it into 1.6.0.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: .CelX equivalent to the Goto URL in .CEL ?

Post #12by chris » 25.07.2009, 14:07

Chuft-Captain wrote:Vincent,

Did these make it into 1.6.0 final? ... or just miss?

CC

EDIT: OK, I just gave it a try and it looks like it didn't make it into 1.6.0.

The changes are already in the 1.6.1 branch, so you won't have to wait too long...

--Chris

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 11 months

Re: .CelX equivalent to the Goto URL in .CEL ?

Post #13by Chuft-Captain » 26.07.2009, 04:14

chris wrote:
Chuft-Captain wrote:Vincent,

Did these make it into 1.6.0 final? ... or just miss?

CC

EDIT: OK, I just gave it a try and it looks like it didn't make it into 1.6.0.

The changes are already in the 1.6.1 branch, so you won't have to wait too long...

--Chris
In fact, I don't have to wait at all! (I have finally installed the IDE and Tortoise :wink: )

SetURL confirmed working in svn 4814: Wormhole Travel
... and it looks like either yourself or Vincent has also fixed an orientation problem which was causing an approx 90deg rotation when capturing URL's. :)

Cheers
CC
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS


Return to “Scripting”