Page 1 of 1

URLs through scripts

Posted: 02.09.2003, 23:13
by Paolo
I was thinking about the current multiview and script capabilities of Celestia and some ideas came in my mind.

Actually (please someone correct me if I’m wrong) it is not possibile to define an URL with multiview. So it is not possibile to click over an Hyperlink in an HTML document and open Celestia with 3-4 (or even more) different views.

I was asking me if should be very difficult to implement a different kind of celestia URL. Instead of a url in semi-binary format

Code: Select all

cel://Follow/Sol:Mercury/2003-08-01T13:15:51.15898?x=AMBAWebCUuPkDA&y=Cpuhlugs9C4e&z=VQr63TfoNIgc&ow=0.863894&ox=0.258879&oy=-0.420347&oz=-0.099883&select=HD%2075318&fov=45.000000&ts=0.000000&rf=40375&lm=1244162

a simple reference to a CEL script.

Using URL CEL script commands should be somewhat easy to operate with Celestia URLs.

The HTML code should be something like this:

Code: Select all

<a href="cel://http://www.myweb.com/myfolder/myURLScript.cel">CEL-URL example</a>


The script file called in the url is saved in a web site. To allow this mechanism Celestia should have some kind of internet browsing capabilities, so this is the source of my implementation dubts.

Some new script commands should be required like:

Code: Select all

SelectPane {ID n} #n=number
SplitHorizontal {ID n Size p} #p = percentage of the higher resulting pane
SplitVertical {ID n Size p} #p = percentage of the left resulting pane
CallScript {name "na"} #na = name
SetPath {name "na"} #na = name
SwitchPane {p1 n1 p2 n2}  #p1,P2 = Pane IDs


Obviously the current URL capture mechanism is very very handy. It is not suitable that Users creates a script from scratch to configure all the things. Instead Celestia should create a script with all the current view settings, included.
So instead of an URL in Semi-Binary format, a plain text script file should be generated and prompted for saving by Celestia. Something like the Don’s standard startup CEL Script plus a Gotolonglat and a Time script commands.

So the final script called by "<a href=cel://" should be something like this

Code: Select all

#set the subscripts folder
SetPath {name "http://www.myweb.com/myfolder/URL1"}
#call the sub script for initial settings
CallScript {name "../generalscripts/InitialSettings.cel"}
#Split the main view. The higher resuting pane conserves its ID (1) pane and har the 30% of the initial pane height.
#make other splits
SplitHorizontal {ID 1 Size 0.33}
Splitvertical {ID 1 Size 0,67}
SplitVertical {ID 1 Size 0.5
SplitHorizontal {ID 2 Size 0,67}
SplitHorizontal {ID 2 Size 0,5}

# The current result should be
#+-------------+------------+-----------+
#|1            |4           |2          |
#|             |            |           |
#|             |            |           |
#|             |            |           |
#+-------------+------------+-----------+
#|3                         |6          |
#|                          |           |
#|                          |           |
#|                          |           |
#|                          |-----------|
#|                          |5          |
#|                          |           |
#|                          |           |
#|                          |           |
#+--------------------------------------+


#reorder panes
Switchpane { p1 3  p2 1}
Switchpane { p1 3  p2 2}
Switchpane { p1 4  p2 3}
Switchpane { p1 6  p2 5}

# The final result should be
#+-------------+------------+-----------+
#|2            |3           |4          |
#|             |            |           |
#|             |            |           |
#|             |            |           |
#+-------------+------------+-----------+
#|1                         |5          |
#|                          |           |
#|                          |           |
#|                          |           |
#|                          |-----------|
#|                          |6          |
#|                          |           |
#|                          |           |
#|                          |           |
#+--------------------------------------+

#Call sub scripts to set the views in the various panes.
CallScript {name "pane1.cel"}
CallScript {name "pane2.cel"}
CallScript {name "pane3.cel"}
CallScript {name "pane4.cel"}
CallScript {name "pane5.cel"}
CallScript {name "pane6.cel"}

#set active pane
SelectPane {ID 1}



For instalnce one of the sub scripts captured directly by Celstia should be:

Code: Select all

#pane 1

#initial settings and preferences

select {object "Mars" }
time { jd 2452862.89542 }
gotolonglat { time 5 distance 4 longitude -122 latitude 47 }

#set final preferences
...
#etc


I think that porting the URL cel scripts in celx Lua script format should be surely easy.

What do you think?
Is it practically feasible?

Bye - Paolo

Posted: 04.09.2003, 11:07
by don
Hi Paolo,

> Actually (please someone correct me if I’m wrong) it is not possibile to define an URL with multiview.

Correct. Celestia's Cell://URL function retains only the *active* viewpane.

Wow, it looks like you put a lot of thought into this idea!

A few weeks ago, Chris was considering adding Cell://URLs to .cel scripting (because it would likely be similar or the same code for celx scripting), but I'm not sure if he actually decided to do it or not.

What you are describing would certainly be a major addition to scripting. I'm not sure if Chris is considering modifying the Cell://URL format to include milti-view displays or not? Maybe he will pop in and let us know?

-Don G.

Re: URLs through scripts

Posted: 04.09.2003, 15:18
by Christophe
Paolo wrote:Actually (please someone correct me if I’m wrong) it is not possibile to define an URL with multiview. So it is not possibile to click over an Hyperlink in an HTML document and open Celestia with 3-4 (or even more) different views.

That's correct, the problem is a bit more complex than it may seem. It's probably not impossible either but I'm wondering if it's worth the time and effort.

Paolo wrote:Using URL CEL script commands should be somewhat easy to operate with Celestia URLs.

The HTML code should be something like this:

Code: Select all

<a href="cel://http://www.myweb.com/myfolder/myURLScript.cel">CEL-URL example</a>


What you're asking is for Celestia to implement its own HTTP client library. The browser sees a cel:// URL, passes it on to Celestia which then requests the script file via HTTP.

There is actually no reason to do this, the following works better and is already working:

Code: Select all

<a href="http://www.myweb.com/myfolder/myURLScript.cel">CEL-URL example</a>


The browser retreives the script file itself, identifies it as a text/x-celestia-script file (from its extension) and passes it on to Celestia. No need for Celestia to do the download itself and as an added benefit that works for all protocols supported by your browser, not just HTTP.

Paolo wrote:Some new script commands should be required like:

Code: Select all

SelectPane {ID n} #n=number
SplitHorizontal {ID n Size p} #p = percentage of the higher resulting pane
SplitVertical {ID n Size p} #p = percentage of the left resulting pane
CallScript {name "na"} #na = name
SetPath {name "na"} #na = name
SwitchPane {p1 n1 p2 n2}  #p1,P2 = Pane IDs


These new commands are a good idea.

Paolo wrote:Obviously the current URL capture mechanism is very very handy. It is not suitable that Users creates a script from scratch to configure all the things. Instead Celestia should create a script with all the current view settings, included.
So instead of an URL in Semi-Binary format, a plain text script file should be generated and prompted for saving by Celestia. Something like the Don’s standard startup CEL Script plus a Gotolonglat and a Time script commands.


The main difference between using scripts and URLs is that with scripts you need access to a Web server to make it available to others, URLs can be more easily used on online forums.

The amount of work that needs to be done for Celestia to be able to generate such scripts automatically is about the same as what is needed to get URLs to handle multiview directly. So I'd rather do the latter, but the new script commands are worth implementing anyway.

Posted: 06.09.2003, 14:58
by Paolo
To Christophe

I'm glad that you've found my suggestions useful. :)

I'll wait for the implementation.

BTW another command like DeletePane {ID n} should be useful.

Bye - Paolo

Posted: 06.09.2003, 18:30
by chris
Paolo,

Loading URLs with a script command is a very useful feature, and high on my priority list when I (or Christophe) get back to work on scripting.

I wanted to point out that multiview commands will probably only appear in Lua scripting, not in the old style scripting. I'd like to put them both places, but I don't think time will permit it.

--Chris

Posted: 06.09.2003, 20:09
by don
chris wrote:I'd like to put them both places, but I don't think time will permit it.

--Chris

Hi Chris and Christophe,

A thought just came to mind ...

What about adding a "run script" function in cel scripting that would allow a celx script to be run (with? / without? parameter passing), much like a function call but without having to know how to write the function code itself. :)

The thought behind this is that "programmers" could write Lua/celx scripts that could then be called by "novice" cel script writers, thus giving cel scripting the ability to access any new functions added to celx scripting.

Is this feasible?

-Don G.

Posted: 06.09.2003, 20:38
by Christophe
Lua already supports something like this through the require() function which loads a package.

All we need now is package writters ;-)

Posted: 06.09.2003, 20:49
by don
Christophe wrote:All we need now is package writters ;-)

I can wrap packages all day long, but I don't know about writing a package. :lol:

Posted: 06.09.2003, 20:55
by don
Christophe wrote:Lua already supports something like this through the require() function which loads a package.

It's too bad the Lua 5.0 Reference Manual says nothing about what a package is, how to create one, how to pass parameters, or anything else. :(

Posted: 06.09.2003, 21:12
by Christophe
I haven't spent too much time studying Lua, but I think a package is just a script file where you can define functions, once required these functions are available to your script.

Posted: 07.09.2003, 03:32
by don
Christophe wrote:I haven't spent too much time studying Lua, but I think a package is just a script file where you can define functions, once required these functions are available to your script.

Don't feel too bad, I have spent zero time "studying" Lua, but I have looked through the manual and it's easy to search through.

The require (packagename) function has this to say about a package: "The [require] function stops the search as soon as it can load a [package] file, and then it runs the file. After that, it associates, in table _LOADED, the package name with the value that the package returned, and returns that value. ... The package being loaded always runs within the global environment."

If Lua is using require as a subroutine caller, it is indeed a very strange language. I thought require was something normally associated with including a code section from a different file at the top of the current program code, like include. But this is not the way it's described in the Lua manual <sigh>.

Very strange.

Posted: 07.09.2003, 05:33
by chris
don wrote:If Lua is using require as a subroutine caller, it is indeed a very strange language. I thought require was something normally associated with including a code section from a different file at the top of the current program code, like include. But this is not the way it's described in the Lua manual <sigh>.


It is very much like an include, but you have to remember that Lua is an interpreted language so in order to define a set of functions, the file with the definitions must be executed. If the file contains code other than function and variable definitions, those will also be run--useful for complex initialization or annoying if the package author has dropped an infinite loop into the code.

--Chris

Posted: 07.09.2003, 05:49
by don
chris wrote:It is very much like an include, but you have to remember that Lua is an interpreted language ...

Oh yeah ... duhhhhh :roll: Thanks for reminding me Chris. :)

-Don G.