One button for showing constellation scheme and name
One button for showing constellation scheme and name
Hello,
Would not be interesting having cycle buttons for showing constellation schemes and constellation names?
For instance, I press a first time '/' button from keyboard, and then constellation schemes become visible, I press a second time and then is added the names of these constellations, a third press for showing only names and the last one to hide names and schemes of constellation, and you restart...
It would be quicker than always playing with panels. It may free also some letters for other functions. What do you think about that?
Thanks in advance.
Would not be interesting having cycle buttons for showing constellation schemes and constellation names?
For instance, I press a first time '/' button from keyboard, and then constellation schemes become visible, I press a second time and then is added the names of these constellations, a third press for showing only names and the last one to hide names and schemes of constellation, and you restart...
It would be quicker than always playing with panels. It may free also some letters for other functions. What do you think about that?
Thanks in advance.
-
- Developer
- Posts: 3776
- Joined: 04.02.2005
- With us: 19 years 9 months
I post a piece of script to test yourself how cycle commands could be. This is about only constellations. Pay attention, it seems (i don't know why ) that keypresses callback function doesn't allow to continue to use normal keymap...
I've tried to extend the principle for showing names and orbits of different objects as planets (p button), moons (m), asteroids(a), spacecraft(s). I'm quite a beginner in celestia scripting and this next piece of script doesn't run totally (specially for orbits ) :
Code: Select all
CommandCycleIndexConst=0
-- Callback for keypresses (name is hardcoded in celestia)
function celestia_keyboard_callback(str)
--About constellations
if str == "\047" then
CommandCycleIndexConst=CommandCycleIndexConst+1
if CommandCycleIndexConst>4 then
CommandCycleIndexConst=1
end
if CommandCycleIndexConst==1 then
celestia:show("constellations")
celestia:hidelabel("constellations")
elseif CommandCycleIndexConst==2 then
celestia:show("constellations")
celestia:showlabel("constellations")
elseif CommandCycleIndexConst==3 then
celestia:hide("constellations")
celestia:showlabel("constellations")
elseif CommandCycleIndexConst==4 then
celestia:hide("constellations")
celestia:hidelabel("constellations")
end
return true
end
-- enable keyboard-callback:
celestia:requestkeyboard(true)
celestia:flash("Command cycle example start")
-- and do nothing...
while true do
wait(0)
end
I've tried to extend the principle for showing names and orbits of different objects as planets (p button), moons (m), asteroids(a), spacecraft(s). I'm quite a beginner in celestia scripting and this next piece of script doesn't run totally (specially for orbits ) :
Code: Select all
CommandCycleIndexConst=0
CommandCycleIndexPlanet=0
CommandCycleIndexAster=0
CommandCycleIndexMoon=0
CommandCycleIndexSpc=0
-- Callback for keypresses (name is hardcoded in celestia)
function celestia_keyboard_callback(str)
--About constellations
if str == "\047" then
CommandCycleIndexConst=CommandCycleIndexConst+1
if CommandCycleIndexConst>4 then
CommandCycleIndexConst=1
end
if CommandCycleIndexConst==1 then
celestia:show("constellations")
celestia:hidelabel("constellations")
elseif CommandCycleIndexConst==2 then
celestia:show("constellations")
celestia:showlabel("constellations")
elseif CommandCycleIndexConst==3 then
celestia:hide("constellations")
celestia:showlabel("constellations")
elseif CommandCycleIndexConst==4 then
celestia:hide("constellations")
celestia:hidelabel("constellations")
end
--About planets
elseif str == "\112" then
CommandCycleIndexPlanet=CommandCycleIndexPlanet+1
if CommandCycleIndexPlanet>4 then
CommandCycleIndexPlanet=1
end
if CommandCycleIndexPlanet==1 then
celestia:setorbitflags {planet=true}
celestia:hidelabel("planets")
elseif CommandCycleIndexPlanet==2 then
celestia:setorbitflags {planet=true}
celestia:showlabel("planets")
elseif CommandCycleIndexPlanet==3 then
celestia:setorbitflags {planet=false}
celestia:showlabel("planets")
elseif CommandCycleIndexPlanet==4 then
celestia:setorbitflags {planet=false}
celestia:hidelabel("planets")
end
--About asteroids
elseif str == "\97" then
CommandCycleIndexAster=CommandCycleIndexAster+1
if CommandCycleIndexAster>4 then
CommandCycleIndexAster=1
end
if CommandCycleIndexAster==1 then
celestia:setorbitflags {Asteroids=true}
celestia:hidelabel("asteroids")
elseif CommandCycleIndexAster==2 then
celestia:setorbitflags {Asteroid=true}
celestia:showlabel("asteroids")
elseif CommandCycleIndexAster==3 then
celestia:setorbitflags {Asteroid=false}
celestia:showlabel("asteroids")
elseif CommandCycleIndexAster==4 then
celestia:setorbitflags {Asteroid=false}
celestia:hidelabel("asteroids")
end
--About moons
elseif str == "\109" then
CommandCycleIndexMoon=CommandCycleIndexMoon+1
if CommandCycleIndexMoon>4 then
CommandCycleIndexMoon=1
end
if CommandCycleIndexMoon==1 then
celestia:setorbitflags {Moon=true}
celestia:hidelabel("Moons")
elseif CommandCycleIndexMoon==2 then
celestia:setorbitflags {Moon=true}
celestia:showlabel("Moons")
elseif CommandCycleIndexMoon==3 then
celestia:setorbitflags {Moon=false}
celestia:showlabel("Moons")
elseif CommandCycleIndexMoon==4 then
celestia:setorbitflags {Moon=false}
celestia:hidelabel("Moons")
end
--About spacecrafts
elseif str == "\115" then
CommandCycleIndexSpc=CommandCycleIndexSpc+1
if CommandCycleIndexSpc>4 then
CommandCycleIndexSpc=1
end
if CommandCycleIndexSpc==1 then
celestia:setorbitflags {Spacecraft=true}
celestia:hidelabel("spacecrafts")
elseif CommandCycleIndexSpc==2 then
celestia:setorbitflags {Spacecraft=true}
celestia:showlabel("spacecrafts")
elseif CommandCycleIndexSpc==3 then
celestia:setorbitflags {Spacecraft=false}
celestia:showlabel("spacecrafts")
elseif CommandCycleIndexSpc==4 then
celestia:setorbitflags {Spacecraft=false}
celestia:hidelabel("spacecrafts")
end
end
return true
end
-- enable keyboard-callback:
celestia:requestkeyboard(true)
celestia:flash("Command cycle example start")
-- and do nothing...
while true do
wait(0)
end
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
Imy wrote:I don't why setorbitflags don't show orbits altough I turn the value on true?
Have you also set orbits renderflag to true ?
Code: Select all
celestia:setrenderflags { orbits = true }
@+
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
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
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
Imy wrote:What does mean exactly setrenderflags and setorbitflag? What is the difference please?
You may want to have a look at Harald Schmidt celx page:
http://celestia.h-schmidt.net/celx-summary-latest.html
@+
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
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
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
Yep, that's it.Imy wrote:Thanks for the link. Setrenderflag allows orbits and setorbitflag selects objects whose orbit is wanted to be shown, doesn't it?
Imy wrote:But this doesn't explain why i can show asteroid orbits im my last script and planet orbits are still hidden...
Object class names in get/setorbitlflags methods must be capitalized.
So the issue should be fixed by replacing (in the 'Planets' block):
Code: Select all
if CommandCycleIndexPlanet==1 then
celestia:setorbitflags {planet=true}
with
Code: Select all
if CommandCycleIndexPlanet==1 then
celestia:setorbitflags {Planet=true}
@+
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
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
Hummm... I capitalized words in setorbitflags function and I don't in showlabel and hidelabel function. It runs better surely. However, I still have troubles!
When I use setorbitflags for planet, it seems that selected orbit is still visible although I've decided to hide them...
In Spacecraft Hidelabel and Showlabel function I have had to write in singular spacecraft word although for the others (like planet or moon) plural form run correctly.
I've still problems with spacecraft. All is hidden at the beginning of the script except spacecraft labels, why?
I post a second version of the script where all seems to be good except for spacecraft. I initialise in hidding objects at the beginning:
[/code]
When I use setorbitflags for planet, it seems that selected orbit is still visible although I've decided to hide them...
In Spacecraft Hidelabel and Showlabel function I have had to write in singular spacecraft word although for the others (like planet or moon) plural form run correctly.
I've still problems with spacecraft. All is hidden at the beginning of the script except spacecraft labels, why?
I post a second version of the script where all seems to be good except for spacecraft. I initialise in hidding objects at the beginning:
Code: Select all
celestia:setrenderflags {orbits =false, labels=false, constellations=false}
CommandCycleIndexConst=0
CommandCycleIndexPlanet=0
CommandCycleIndexAster=0
CommandCycleIndexMoon=0
CommandCycleIndexSpc=0
-- Callback for keypresses (name is hardcoded in celestia)
function celestia_keyboard_callback(str)
celestia:setrenderflags {orbits =true, labels=true}
--About constellations
if str == "\047" then
CommandCycleIndexConst=CommandCycleIndexConst+1
if CommandCycleIndexConst>4 then
CommandCycleIndexConst=1
end
if CommandCycleIndexConst==1 then
celestia:show("constellations")
celestia:hidelabel("constellations")
elseif CommandCycleIndexConst==2 then
celestia:show("constellations")
celestia:showlabel("constellations")
elseif CommandCycleIndexConst==3 then
celestia:hide("constellations")
celestia:showlabel("constellations")
elseif CommandCycleIndexConst==4 then
celestia:hide("constellations")
celestia:hidelabel("constellations")
end
--About planets
elseif str == "\112" then
CommandCycleIndexPlanet=CommandCycleIndexPlanet+1
if CommandCycleIndexPlanet>4 then
CommandCycleIndexPlanet=1
end
if CommandCycleIndexPlanet==1 then
celestia:setorbitflags {Planet=true}
celestia:hidelabel("planets")
elseif CommandCycleIndexPlanet==2 then
celestia:setorbitflags {Planet=true}
celestia:showlabel("planets")
elseif CommandCycleIndexPlanet==3 then
celestia:setorbitflags {Planet=false}
celestia:showlabel("planets")
elseif CommandCycleIndexPlanet==4 then
celestia:setorbitflags {Planet=false}
celestia:hidelabel("planets")
end
--About asteroids
elseif str == "\97" then
CommandCycleIndexAster=CommandCycleIndexAster+1
if CommandCycleIndexAster>4 then
CommandCycleIndexAster=1
end
if CommandCycleIndexAster==1 then
celestia:setorbitflags {Asteroid=true}
celestia:hidelabel("asteroids")
elseif CommandCycleIndexAster==2 then
celestia:setorbitflags {Asteroid=true}
celestia:showlabel("asteroids")
elseif CommandCycleIndexAster==3 then
celestia:setorbitflags {Asteroid=false}
celestia:showlabel("asteroids")
elseif CommandCycleIndexAster==4 then
celestia:setorbitflags {Asteroid=false}
celestia:hidelabel("asteroids")
end
--About moons
elseif str == "\109" then
CommandCycleIndexMoon=CommandCycleIndexMoon+1
if CommandCycleIndexMoon>4 then
CommandCycleIndexMoon=1
end
if CommandCycleIndexMoon==1 then
celestia:setorbitflags {Moon=true}
celestia:hidelabel("moons")
elseif CommandCycleIndexMoon==2 then
celestia:setorbitflags {Moon=true}
celestia:showlabel("moons")
elseif CommandCycleIndexMoon==3 then
celestia:setorbitflags {Moon=false}
celestia:showlabel("moons")
elseif CommandCycleIndexMoon==4 then
celestia:setorbitflags {Moon=false}
celestia:hidelabel("moons")
end
--About spacecrafts
elseif str == "\115" then
CommandCycleIndexSpc=CommandCycleIndexSpc+1
if CommandCycleIndexSpc>4 then
CommandCycleIndexSpc=1
end
if CommandCycleIndexSpc==1 then
celestia:setorbitflags {Spacecraft=true}
celestia:hidelabel("spacecraft")
elseif CommandCycleIndexSpc==2 then
celestia:setorbitflags {Spacecraft=true}
celestia:showlabel("spacecraft")
elseif CommandCycleIndexSpc==3 then
celestia:setorbitflags {Spacecraft=false}
celestia:showlabel("spacecraft")
elseif CommandCycleIndexSpc==4 then
celestia:setorbitflags {Spacecraft=false}
celestia:hidelabel("spacecraft")
end
end
return true
end
-- enable keyboard-callback:
celestia:requestkeyboard(true)
celestia:flash("Command cycle example start")
-- and do nothing...
while true do
wait(0)
end
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
This is the expected behaviour. The current selection's orbit is always displayed unless you disable orbits rendeflag.Imy wrote:When I use setorbitflags for planet, it seems that selected orbit is still visible although I've decided to hide them...
This is because the plural for 'spacecraft' is... 'spacecraft'.Imy wrote:In Spacecraft Hidelabel and Showlabel function I have had to write in singular spacecraft word although for the others (like planet or moon) plural form run correctly.
Imy wrote:I've still problems with spacecraft. All is hidden at the beginning of the script except spacecraft labels, why?
I think that this is simply because you have spacecraft labels enabled before running the script. Your script works fine for me.
@+
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
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
Thanks. Finally Shall I change all setorbitflags by setrenderflag about orbit? Is not easier?
But I ask to hide all labels at the beginning of the script. Spacecraft labels are included also, aren't they?
I'm beginning to wonder if it would not be interesting to use a special shift button too. When you've selected Earth, if you play with P button in my script, well all orbits disapear ; but if you press SHIFT + P, only Earth orbit would be hidden. This could be useful to select orbits, to show for example, only mercury and earth orbit to compare them... or to show only spacecraft orbiting around earth...
But Celestia can do that? First how to say SHIFT+P? And Above all, can we show orbits for one object and not for a class of object?
I didn't search in this way why spacecraft option didn't run as they would...This is because the plural for 'spacecraft' is... 'spacecraft'.
Imy wrote:
I've still problems with spacecraft. All is hidden at the beginning of the script except spacecraft labels, why?
I think that this is simply because you have spacecraft labels enabled before running the script. Your script works fine for me.
But I ask to hide all labels at the beginning of the script. Spacecraft labels are included also, aren't they?
I'm beginning to wonder if it would not be interesting to use a special shift button too. When you've selected Earth, if you play with P button in my script, well all orbits disapear ; but if you press SHIFT + P, only Earth orbit would be hidden. This could be useful to select orbits, to show for example, only mercury and earth orbit to compare them... or to show only spacecraft orbiting around earth...
But Celestia can do that? First how to say SHIFT+P? And Above all, can we show orbits for one object and not for a class of object?
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
'labels' is not a valid renderflag. You must disable all labels using celestia:setlabelflags.Imy wrote:But I ask to hide all labels at the beginning of the script. Spacecraft labels are included also, aren't they?
You can also write your own function that enable/disable all labels:
Code: Select all
setLabelRenderflag = function (b)
t = celestia:getlabelflags()
for class, flag in pairs(t) do
t[class] = b
celestia:setlabelflags(t)
end
end
Then, just call:
Code: Select all
setLabelRenderflag(true)
Code: Select all
setLabelRenderflag(false)
Imy wrote:First how to say SHIFT+P?
Code: Select all
if str == "P"
Imy wrote:And Above all, can we show orbits for one object and not for a class of object?
No, this is not possible, yet.
@+
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
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
What does that mean exactly? Is a bugged function?'labels' is not a valid renderflag
Imy wrote:
And Above all, can we show orbits for one object and not for a class of object?
No, this is not possible, yet.
So my selective option will be for a next time ...
Why keypress callback function doesn't continue to use the basic keymap? When I execute my script, enter or g buttons don't run although I haven't used them in the function.
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
It's not a bug. The labels renderflag doesn't exist. Each label must be turned on/off separately with the 'setlabelflags' method.Imy wrote:What does that mean exactly? Is a bugged function?'labels' is not a valid renderflag
Imy wrote:Why keypress callback function doesn't continue to use the basic keymap? When I execute my script, enter or g buttons don't run although I haven't used them in the function.
Just tell your celestia_keyboard_callback function to return false instead of true.
One small suggestion: you should add comments to precise to which char corresponds each ASCII code you're using in your script. Not everybody knows that '\047' corresponds to '/', '\112' to 'p', 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
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
if CommandCycleIndexMoon==1 then
celestia:setorbitflags {Moon=true}
celestia:hidelabel("Moons")
elseif CommandCycleIndexMoon==2 then
celestia:setorbitflags {Moon=true}
celestia:showlabel("Moons")
elseif CommandCycleIndexMoon==3 then
celestia:setorbitflags {Moon=false}
celestia:showlabel("Moons")
elseif CommandCycleIndexMoon==4 then
celestia:setorbitflags {Moon=false}
celestia:hidelabel("Moons")
end
I was improving code in including a more general function and I found that my variable CommandCycleIndexMoon (and probably others) hasn't done what I ordered : when the variable is 1 then, 2 is done, when it is 2 this is 1, 3 for 4 and 4 for 3:evil: !! What's the problem? From me or a subtility from celestia scripting?
-
- Developer
- Posts: 1356
- Joined: 07.01.2005
- With us: 19 years 10 months
- Location: Nancy, France
The problem is not related to the use of braces; braces must be used here since orbitflags are defined as a table; as for parentheses, they would be superfluous here.
The problem is that since we told the callback function to return false, the 'M' key is still toggling the Moons labels. So, you can solve this issue by adding a return true at the end of the 'm' char test (and also at the end of all char tests) to block the default 'M' key function:
The problem is that since we told the callback function to return false, the 'M' key is still toggling the Moons labels. So, you can solve this issue by adding a return true at the end of the 'm' char test (and also at the end of all char tests) to block the default 'M' key function:
Code: Select all
--About moons
elseif str == "\109" then
CommandCycleIndexMoon=CommandCycleIndexMoon+1
if CommandCycleIndexMoon>4 then
CommandCycleIndexMoon=1
end
if CommandCycleIndexMoon==1 then
celestia:setorbitflags {Moon=true}
celestia:hidelabel("moons")
elseif CommandCycleIndexMoon==2 then
celestia:setorbitflags {Moon=true}
celestia:showlabel("moons")
elseif CommandCycleIndexMoon==3 then
celestia:setorbitflags {Moon=false}
celestia:showlabel("moons")
elseif CommandCycleIndexMoon==4 then
celestia:setorbitflags {Moon=false}
celestia:hidelabel("moons")
end
return true
--About spacecrafts
elseif str == "\115" then
@+
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
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
I've still problems please:? :
-How to desactivate keypress callback when enter panel is shown (where you tape your destination)
-What about setlabelflags? I've changed hidelabel and showlabel functions with setlabelflags as suggested so that I can use table instead of strings in its parameters. But when I've written celestia:setlabelflags {Planet=true}, well nothing, no planet labels although these ones can be shown with classic showlabel...
-I'm often coding with VB language: in this you have lcase/ucase function, i suppose these kind of functions exists also in Lua. These functions change case of a string : you have "HeLLo", and then this string with lcase become "hello". What is the equivalent in lua language please?
-How to desactivate keypress callback when enter panel is shown (where you tape your destination)
-What about setlabelflags? I've changed hidelabel and showlabel functions with setlabelflags as suggested so that I can use table instead of strings in its parameters. But when I've written celestia:setlabelflags {Planet=true}, well nothing, no planet labels although these ones can be shown with classic showlabel...
-I'm often coding with VB language: in this you have lcase/ucase function, i suppose these kind of functions exists also in Lua. These functions change case of a string : you have "HeLLo", and then this string with lcase become "hello". What is the equivalent in lua language please?