start.cel -> start.celx with "layers"

All about writing scripts for Celestia in Lua and the .cel system
Avatar
Topic author
Cham M
Posts: 4324
Joined: 14.01.2004
Age: 60
With us: 21 years
Location: Montreal

Re: start.cel -> start.celx with "layers"

Post #21by Cham » 03.08.2008, 17:14

Vincent wrote:The Ctrl key event is not working for me. I tried with Ctrl+1, Ctrl+a, Ctrl+A, but had success with none of these combinations.
I'm not sure whether this issue is related to the Windows version or my french AZERTY keyboard...

Chris should make some comment here. He told me by email that the Windows version needs an adjustement. I can't tell if it's related (I suspect it is).
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"

Avatar
Topic author
Cham M
Posts: 4324
Joined: 14.01.2004
Age: 60
With us: 21 years
Location: Montreal

Re: start.cel -> start.celx with "layers"

Post #22by Cham » 03.08.2008, 17:24

Here's another version of the CELX script with "layers" (thanks Vincent!). I'm now just wondering about the formatting (presentation, lines, etc). Any suggestions to improve the presentation ?

Code: Select all

---------------------------------------------------------------
---------------------------------------------------------------
objects_t = {}
---------------------------------------------------------------
-------- Layers definitions (to be filled by the user) --------

objects_t[1] = {
      
   }

objects_t[2] = {
      
   }

objects_t[3] = {
      
   }

objects_t[4] = {
      
   }

objects_t[5] = {
      
   }

objects_t[6]= {
      
   }

objects_t[7] = {
      
   }

objects_t[8] = {
      
   }

objects_t[9] = {
      
   }

objects_t[0] = {
      
   }

--------------------------------------------------------------
--------------------------------------------------------------
for n = 0, 9 do
   for k, object in pairs(objects_t[n]) do
      obj = celestia:find(object)
      obj:setvisible(false)
   end
end
--------------------------------------------------------------
-- Layer 1 ---------------------------------------------------
function toggleObj1()
  for k, object in pairs(objects_t[1]) do
    obj1 = celestia:find(object)
    obj1:setvisible(not obj1:visible())

   if obj1:visible() then
      celestia:print(" ", 2)
   else
      celestia:print(" ", 2)
   end
  end
end

-- Layer 2 ---------------------------------------------------
function toggleObj2()
  for k, object in pairs(objects_t[2]) do
    obj2 = celestia:find(object)
    obj2:setvisible(not obj2:visible())
   if obj2:visible() then
      celestia:print(" ", 5)
   else
      celestia:print(" ", 2)
   end
  end
end

-- Layer 3 ---------------------------------------------------
function toggleObj3()
  for k, object in pairs(objects_t[3]) do
    obj3 = celestia:find(object)
    obj3:setvisible(not obj3:visible())
   if obj3:visible() then
      celestia:print(" ", 5)
   else
      celestia:print(" ", 2)
   end
  end
end

-- Layer 4 ---------------------------------------------------
function toggleObj4()
  for k, object in pairs(objects_t[4]) do
    obj4 = celestia:find(object)
    obj4:setvisible(not obj4:visible())
   if obj4:visible() then
      celestia:print(" ", 5)
   else
      celestia:print(" ", 2)
   end
  end
end

-- Layer 5 ---------------------------------------------------
function toggleObj5()
  for k, object in pairs(objects_t[5]) do
    obj5 = celestia:find(object)
    obj5:setvisible(not obj5:visible())
   if obj5:visible() then
      celestia:print(" ", 3)
   else
      celestia:print(" ", 2)
   end
  end
end

-- Layer 6 ---------------------------------------------------
function toggleObj6()
  for k, object in pairs(objects_t[6]) do
    obj6 = celestia:find(object)
    obj6:setvisible(not obj6:visible())
   if obj6:visible() then
      celestia:print(" ", 5)
   else
      celestia:print(" ", 2)
   end
  end
end

-- Layer 7 ---------------------------------------------------
function toggleObj7()
  for k, object in pairs(objects_t[7]) do
    obj7 = celestia:find(object)
    obj7:setvisible(not obj7:visible())
   if obj7:visible() then
      celestia:print(" ", 5)
   else
      celestia:print(" ", 2)
   end
  end
end

-- Layer 8 ---------------------------------------------------
function toggleObj8()
  for k, object in pairs(objects_t[8]) do
    obj8 = celestia:find(object)
    obj8:setvisible(not obj8:visible())
   if obj8:visible() then
      celestia:print(" ", 5)
   else
      celestia:print(" ", 2)
   end
  end
end

-- Layer 9 ---------------------------------------------------
function toggleObj9()
  for k, object in pairs(objects_t[9]) do
    obj9 = celestia:find(object)
    obj9:setvisible(not obj9:visible())
   if obj9:visible() then
      celestia:print(" ", 2)
   else
      celestia:print(" ", 2)
   end
  end
end

-- Layer 0 ---------------------------------------------------
function toggleObj0()
  for k, object in pairs(objects_t[0]) do
    obj0 = celestia:find(object)
    obj0:setvisible(not obj0:visible())
   if obj0:visible() then
      celestia:print(" ", 2)
   else
      celestia:print(" ", 2)
   end
  end
end

---------------------------------------------------------------
---------------------------------------------------------------
function fastgoto()
    sel = celestia:getselection()
    obs = celestia:getobserver()
    if sel and obs then
        obs:goto(sel, 0.001)
    end
end
---------------------------------------------------------------
---------------------------------------------------------------
keyhandlers =
{
         G = fastgoto,
   ["C-1"] = toggleObj1,
   ["C-2"] = toggleObj2,
   ["C-3"] = toggleObj3,
   ["C-4"] = toggleObj4,
   ["C-5"] = toggleObj5,
   ["C-6"] = toggleObj6,
   ["C-7"] = toggleObj7,
   ["C-8"] = toggleObj8,
   ["C-9"] = toggleObj9,
   ["C-0"] = toggleObj0
}

function handlekey(k)
    handler = keyhandlers[k.char]
    if (handler ~= nil) then
        handler()
        return true
    else
        return false
    end
end

celestia:registereventhandler("key", handlekey)
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 11 months

Re: start.cel -> start.celx with "layers"

Post #23by ElChristou » 03.08.2008, 17:36

Cham wrote:Here's another version of the CELX script with "layers" (thanks Vincent!).
The changes are just cosmetic compared to the first script?
Image

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 20 years
Location: Nancy, France

Re: start.cel -> start.celx with "layers"

Post #24by Vincent » 03.08.2008, 17:45

ElChristou wrote:
Cham wrote:Here's another version of the CELX script with "layers" (thanks Vincent!).
The changes are just cosmetic compared to the first script?
Well, I'd rather say that this version is more elegant and more efficient. :wink:
@+
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

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

Re: start.cel -> start.celx with "layers"

Post #25by chris » 03.08.2008, 23:33

Cham wrote:
Vincent wrote:The Ctrl key event is not working for me. I tried with Ctrl+1, Ctrl+a, Ctrl+A, but had success with none of these combinations.
I'm not sure whether this issue is related to the Windows version or my french AZERTY keyboard...

Chris should make some comment here. He told me by email that the Windows version needs an adjustement. I can't tell if it's related (I suspect it is).

Strange . . . I don't expect the Ctrl+number keys to work on Windows (yet), but the Ctrl+letter combinations should be fine. I'll test again on my Windows system.

--Chris

symaski62
Posts: 610
Joined: 01.05.2004
Age: 41
With us: 20 years 9 months
Location: france, divion

Re: start.cel -> start.celx with "layers"

Post #26by symaski62 » 03.08.2008, 23:52

chris wrote:
Cham wrote:
Vincent wrote:The Ctrl key event is not working for me. I tried with Ctrl+1, Ctrl+a, Ctrl+A, but had success with none of these combinations.
I'm not sure whether this issue is related to the Windows version or my french AZERTY keyboard...

Chris should make some comment here. He told me by email that the Windows version needs an adjustement. I can't tell if it's related (I suspect it is).

Strange . . . I don't expect the Ctrl+number keys to work on Windows (yet), but the Ctrl+letter combinations should be fine. I'll test again on my Windows system.

--Chris

:mrgreen: LOL ALT + MAJ => AZERTY charge QWERTY

:wink:
windows 10 directX 12 version
celestia 1.7.0 64 bits
with a general handicap of 80% and it makes much d' efforts for the community and s' expimer, thank you d' to be understanding.

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 11 months

Re: start.cel -> start.celx with "layers"

Post #27by ElChristou » 04.08.2008, 07:57

chris wrote:Strange . . . I don't expect the Ctrl+number keys to work on Windows (yet), but the Ctrl+letter combinations should be fine. I'll test again on my Windows system...

Ahhh computers are really cheeky those day! :lol:
Image

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 20 years
Location: Nancy, France

Re: start.cel -> start.celx with "layers"

Post #28by Vincent » 04.08.2008, 10:17

chris wrote:
Vincent wrote:The Ctrl key event is not working for me. I tried with Ctrl+1, Ctrl+a, Ctrl+A, but had success with none of these combinations.
I'm not sure whether this issue is related to the Windows version or my french AZERTY keyboard...
Strange . . . I don't expect the Ctrl+number keys to work on Windows (yet), but the Ctrl+letter combinations should be fine. I'll test again on my Windows system.
Chris,

I did some further testing, and actually, the Ctrl+letter combination works,
except with the following letters: Ctrl+A, Ctrl+E, Ctrl+Y, Ctrl+Q, Ctrl+L, Ctrl+C.
It looks like the corresponding standard commands can't be overridden:
    Ctrl+A : Toggle atmospheres
    Ctrl+E : Toggle eclipse shadow rendering
    Ctrl+Y : Toggle autoMag
    Ctrl+Q : Quit
    Ctrl+L : Toggle night side planet maps
    Ctrl+C : Copy location URL to clipboard

Some other commands associated to a Ctrl+letter combination can be overridden, though:
    Ctrl+B : Toggle constellation boundaries
    Ctrl+K : Toggle display of markers
    Ctrl+P : Mark selected object
    Ctrl+S : Cycle the star style between fuzzy discs, points, and scaled discs
    Ctrl+V : Cycle between supported OpenGL render paths
    Ctrl+W : Toggle wireframe mode
    Ctrl+X : Toggle antialias lines
    Ctrl+T : Toggle rendering of comet tails
    etc
@+
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

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

Re: start.cel -> start.celx with "layers"

Post #29by chris » 04.08.2008, 17:01

Vincent wrote:
chris wrote:
Vincent wrote:The Ctrl key event is not working for me. I tried with Ctrl+1, Ctrl+a, Ctrl+A, but had success with none of these combinations.
I'm not sure whether this issue is related to the Windows version or my french AZERTY keyboard...
Strange . . . I don't expect the Ctrl+number keys to work on Windows (yet), but the Ctrl+letter combinations should be fine. I'll test again on my Windows system.
Chris,

I did some further testing, and actually, the Ctrl+letter combination works,
except with the following letters: Ctrl+A, Ctrl+E, Ctrl+Y, Ctrl+Q, Ctrl+L, Ctrl+C.
It looks like the corresponding standard commands can't be overridden:

Code: Select all

Ctrl+A : Toggle atmospheres
Ctrl+E : Toggle eclipse shadow rendering
Ctrl+Y : Toggle autoMag
Ctrl+Q : Quit
Ctrl+L : Toggle night side planet maps
Ctrl+C : Copy location URL to clipboard[/list]


I think the difference is that these keys are registered as Windows menu shortcuts. Basically, Windows converts the keystroke into a menu command before Celestia ever has a chance to handle it. I'm not sure what the appropriate workaround for this is :S

--Chris

Avatar
Topic author
Cham M
Posts: 4324
Joined: 14.01.2004
Age: 60
With us: 21 years
Location: Montreal

Re: start.cel -> start.celx with "layers"

Post #30by Cham » 04.08.2008, 17:13

...and what about the ctrl-number combos in Windows ?

Also, alt-number may be usefull too.
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"

BobHegwood
Posts: 1803
Joined: 12.10.2007
With us: 17 years 3 months

Re: start.cel -> start.celx with "layers"

Post #31by BobHegwood » 15.08.2008, 04:50

Cham?

Would it be possible for you to post a link here to the complete start.celx script you are currently using?
I have played with this stuff for the last three hours, and I'm afraid that I am simply confusing myself
beyond hope with the instructions you have provided above.

I simply do NOT understand what the differences are in the two start.celx scripts, nor do I understand
how to add the layers as instructed elsewhere here. Believe me, I have tried, but I'm afraid that my old
drug-affected brain cells simply cannot process the information you are trying to provide here.

Very sorry to ask, but I'm afraid that I simply cannot put together a start.celx file which executes correctly. :roll:

Many thanks, Brain-Dead

EDIT: Sorry, I mean the start.celx file which contains everything you need to view all of the layers you are using.
Brain-Dead Geezer Bob is now using...
Windows Vista Home Premium, 64-bit on a
Gateway Pentium Dual-Core CPU E5200, 2.5GHz
7 GB RAM, 500 GB hard disk, Nvidia GeForce 7100
Nvidia nForce 630i, 1680x1050 screen, Latest SVN

Avatar
Topic author
Cham M
Posts: 4324
Joined: 14.01.2004
Age: 60
With us: 21 years
Location: Montreal

Re: start.cel -> start.celx with "layers"

Post #32by Cham » 15.08.2008, 11:28

Bob,

here's my complete start.celx script, with personal customization (colors, marked objects, etc). Edit it as you want.

Don't forget to open it as UTF-8, since I'm using lots of French accents in the layers :
start.celx.zip
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"

BobHegwood
Posts: 1803
Joined: 12.10.2007
With us: 17 years 3 months

Re: start.cel -> start.celx with "layers"

Post #33by BobHegwood » 15.08.2008, 12:11

Cham wrote:Bob,

here's my complete start.celx script, with personal customization (colors, marked objects, etc). Edit it as you want.

Don't forget to open it as UTF-8, since I'm using lots of French accents in the layers :
start.celx.zip
Thanks a lot my friend. I simply could NOT figure out how to place the different levels within the main script, so I'll study your version, and
hopefully learn what the heck I'm doing here. :wink:
Brain-Dead Geezer Bob is now using...
Windows Vista Home Premium, 64-bit on a
Gateway Pentium Dual-Core CPU E5200, 2.5GHz
7 GB RAM, 500 GB hard disk, Nvidia GeForce 7100
Nvidia nForce 630i, 1680x1050 screen, Latest SVN

BobHegwood
Posts: 1803
Joined: 12.10.2007
With us: 17 years 3 months

Re: start.cel -> start.celx with "layers"

Post #34by BobHegwood » 16.08.2008, 05:21

Just wanted to let you know that I now have my tortured brain headed into at least the right direction now.

I took apart your start.celx file and rebuilt it the way I expected it to work on my system (using the latest release of Celestia, 4407) and I
finally understand it enough to get three features working. I have the Plate Tectonics, Political Borders, and Craters working now and I am very
happy with what you have accomplished with this new start script. The only downside is that it is way too complex (at least to me, and probably others)
but I really think that this is the way to go with future versions of Celestia. Perhaps this could be an option when Celestia is installed?

Dunno, but after I banged my stupid head against the wall for about 14 hours, I finally understood enough of what was going on in order to get
the script set up the way I like it.

Again, thanks VERY much for this capability to add layers to the basic installation. Is very nice. :)
I will be adding others too after I go drink a bottle of Jack... Oh wait, I can't do that anymore. Damned shame because my head hurts. :wink:
Brain-Dead Geezer Bob is now using...
Windows Vista Home Premium, 64-bit on a
Gateway Pentium Dual-Core CPU E5200, 2.5GHz
7 GB RAM, 500 GB hard disk, Nvidia GeForce 7100
Nvidia nForce 630i, 1680x1050 screen, Latest SVN

Avatar
Topic author
Cham M
Posts: 4324
Joined: 14.01.2004
Age: 60
With us: 21 years
Location: Montreal

Re: start.cel -> start.celx with "layers"

Post #35by Cham » 17.08.2008, 00:30

Here's an alternate celx script to toggle ON/OFF any layer, without using the keyboard. Just place the following script into your scripts folder, so you'll have access to it very easily in your scripts menu (you may create a "layers" sub-folder inside your scripts folder, for all your layers). Of course, you have to edit the code below to adapt it to your needs :

Code: Select all

-- Title: Activate/Desactive a layer

layer_t = {
      "Nebula1",
      "Nebula2",
      "Sol/SSC_object1"
}

  for k, object in pairs(layer_t) do
    layer = celestia:find(object)
    layer:setvisible(not layer:visible())

   if layer:visible() then
      celestia:print("Layer activated", 2)
   else
      celestia:print("Layer desactivated", 2)
   end
end


If you replace the objects "Nebula1", "Nebula2", "Sol/SSC_object1", etc..., with your personal objects (any nebula, any SSC object, etc), you'll be able to turn them all ON/OFF on the fly in Celestia, using this script only. Duplicate the script as many times as you want to define independent layers.

There's simply no end to what you can do now, using layers. :D

In my opinion, scripts like this should be included in the official distribution (with some explanations notice), so everybody could define easily their own layer.
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"

BobHegwood
Posts: 1803
Joined: 12.10.2007
With us: 17 years 3 months

Re: start.cel -> start.celx with "layers"

Post #36by BobHegwood » 17.08.2008, 05:41

Cham wrote:In my opinion, scripts like this should be included in the official distribution (with some explanations notice), so everybody could define easily their own layer.

For whatever it is worth here, I agree. :wink:
Now, I have another request though... On my own peculiar PC, I simply cannot get the CTRL-0-9 keys to work. I am having to use P for Political Borders, T for Tectonic Plates, and S for Surface Features. I am also using the G for Fast Goto.

I have tried a few different combinations for use of the CTRL keys, but nothing seems to work for me. Is there some resource I should know about here in order to use the CTRL keys properly?
Thanks again, Brain-Dead
Brain-Dead Geezer Bob is now using...
Windows Vista Home Premium, 64-bit on a
Gateway Pentium Dual-Core CPU E5200, 2.5GHz
7 GB RAM, 500 GB hard disk, Nvidia GeForce 7100
Nvidia nForce 630i, 1680x1050 screen, Latest SVN

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 11 months

Re: start.cel -> start.celx with "layers"

Post #37by ElChristou » 17.08.2008, 07:35

Cham wrote:In my opinion, scripts like this should be included in the official distribution (with some explanations notice), so everybody could define easily their own layer.

Despite being tempting, IMHO this stuff is too cumbersome to be by default. A bad edition of the start.celx and you can have Celestia crashing at start. Really too problematic for a normal use... :|
Image

Avatar
Topic author
Cham M
Posts: 4324
Joined: 14.01.2004
Age: 60
With us: 21 years
Location: Montreal

Re: start.cel -> start.celx with "layers"

Post #38by Cham » 17.08.2008, 12:17

ElChristou wrote:
Cham wrote:In my opinion, scripts like this should be included in the official distribution (with some explanations notice), so everybody could define easily their own layer.

Despite being tempting, IMHO this stuff is too cumbersome to be by default. A bad edition of the start.celx and you can have Celestia crashing at start. Really too problematic for a normal use... :|

ElChristou, the previous script isn't to be included in the start script at all. It's an independent script file to be included in the scripts menu. And there is no keyboard "switch" associated to it. It's a much simpler script. It can't crash Celestia.

Bob,

I think Chris didn't made the code correction for Windows yet, about the ctrl-number in celx scripts.
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"

BobHegwood
Posts: 1803
Joined: 12.10.2007
With us: 17 years 3 months

Re: start.cel -> start.celx with "layers"

Post #39by BobHegwood » 17.08.2008, 13:44

Cham wrote:I think Chris didn't made the code correction for Windows yet, about the ctrl-number in celx scripts.
Okay, thanks for the tip. Just wanted to make certain that I wasn't doing something stupid again. :wink:
I really do like this approach to the layers though. One has a very useful way to customize Celestia to one's own tastes. Great stuff in my opinion.
Brain-Dead Geezer Bob is now using...
Windows Vista Home Premium, 64-bit on a
Gateway Pentium Dual-Core CPU E5200, 2.5GHz
7 GB RAM, 500 GB hard disk, Nvidia GeForce 7100
Nvidia nForce 630i, 1680x1050 screen, Latest SVN


Return to “Scripting”