"dso:getinfo().hubbleType" doesn't work in r4473

All about writing scripts for Celestia in Lua and the .cel system
Topic author
SU(3)xSU(2)xU(1)
Posts: 59
Joined: 05.05.2008
With us: 16 years 7 months

"dso:getinfo().hubbleType" doesn't work in r4473

Post #1by SU(3)xSU(2)xU(1) » 02.10.2008, 08:41

I have written a simple celx script, which works perfectly in celestia 1.5.1:

Code: Select all

M31 = celestia:find("M 31")
ht = M31:getinfo().hubbleType
celestia:print(ht, 10, -1, 1, 6, -8)


This script doesn't work anymore in celestia r4473. I think that "M31:getinfo().hubbleType" returns a nil value in r4473. I initialy thought, that there have been some changes, like changing the name "hubbleType" to something else. Unfortunately, I haven't found any information about such changes (I was looking for it on Wikibooks and on this forum).

Could anyone explain what has happened?

Paul
"Physicists know what's important, but they don't know what is true. Mathematicians know what's true, but they don't know what is important."

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

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #2by Vincent » 02.10.2008, 11:07

Paul,

Your script works fine for me with revision 4479.
It correctly displays Hubble Type 'Sb' for M31.
And no change was made on this side since r4473.

If you don't compile from SVN, make sure you
correctly replaced deepsky.dsc with galaxies.dsc
(and globulars.dsc). Fridger's new globular code
indeed uses these two new separate catalog files.
@+
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

Topic author
SU(3)xSU(2)xU(1)
Posts: 59
Joined: 05.05.2008
With us: 16 years 7 months

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #3by SU(3)xSU(2)xU(1) » 02.10.2008, 13:55

Vincent,

Thank you for the response.

Vincent wrote:If you don't compile from SVN, make sure you
correctly replaced deepsky.dsc with galaxies.dsc
(and globulars.dsc). Fridger's new globular code
indeed uses these two new separate catalog files.

I correctly replaced deepsky.dsc with galaxies.dsc and globulars.dsc. I have also updated celestia.cfg (I used cartrite's built).
I don't have any other problems with galaxies, so the source of my problem is somewhere else.

After running the script, I get an error message:

Code: Select all

In line 3: First argument to celestia:print must be a string


Paul
"Physicists know what's important, but they don't know what is true. Mathematicians know what's true, but they don't know what is important."

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

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #4by Vincent » 02.10.2008, 15:11

SU(3)xSU(2)xU(1) wrote:After running the script, I get an error message:

Code: Select all

In line 3: First argument to celestia:print must be a string
It looks like you're getting a nil value for M31 Hubble type.
You can make sure about this by replacing line 3 with:

Code: Select all

celestia:print(tostring(ht), 10, -1, 1, 6, -8)

What happens when you select M31 from the search console?
Do you have the correct selection information text in the upper
left overlay. Also, you can use the following script to check out
if this issue happens with some other galaxies...

Code: Select all

-- Title: Display Galaxy Hubble type

while true do
   sel = celestia:getselection()
   if sel:type() == "galaxy" then
      hubbleType = sel:getinfo().hubbleType
      celestia:print(tostring(hubbleType))
   end
   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

Topic author
SU(3)xSU(2)xU(1)
Posts: 59
Joined: 05.05.2008
With us: 16 years 7 months

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #5by SU(3)xSU(2)xU(1) » 03.10.2008, 10:49

Vincent,

Vincent wrote:It looks like you're getting a nil value for M31 Hubble type.
You can make sure about this by replacing line 3 with:

Code: Select all
celestia:print(tostring(ht), 10, -1, 1, 6, -8)

I've replaced the third line with this code and the script indeed flashes "nil".

Vincent wrote:What happens when you select M31 from the search console?
Do you have the correct selection information text in the upper
left overlay. Also, you can use the following script to check out
if this issue happens with some other galaxies...

Code: Select all
-- Title: Display Galaxy Hubble type

while true do
sel = celestia:getselection()
if sel:type() == "galaxy" then
hubbleType = sel:getinfo().hubbleType
celestia:print(tostring(hubbleType))
end
wait(0)
end

I don't have any other problem with M31 (I have correct selection information text). Moreover, my problem probably refers to all galaxies. The script, that I've posted, is only a test-script and I've written it only to show my problem explicitly. My original script (in which I detected the problem) is much more complicated an can refer to any galaxies.

So, there is nothing special in M31. It was only an example. I don't have any other problem with any galaxies.

I much appreciate, that you're trying to help me.

Paul
"Physicists know what's important, but they don't know what is true. Mathematicians know what's true, but they don't know what is important."

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

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #6by Vincent » 03.10.2008, 16:23

Paul,

I'm able to reproduce this issue when I simply replace my celestia.exe
file (SVN r4480) with Cartrite's r4473 build. So the problem doesn't
come from your installation. What is strange is that all other getinfo
fields are correctly returned... And I can reproduce this issue neither
with my Windows nor with my Qt4 builds of r4480.

So I would suggest to wait for Cartrite's next build. Then, I'll have a
deeper look at this issue if the problem is still present.
@+
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

Topic author
SU(3)xSU(2)xU(1)
Posts: 59
Joined: 05.05.2008
With us: 16 years 7 months

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #7by SU(3)xSU(2)xU(1) » 03.10.2008, 17:09

Vincent wrote:Paul,

I'm able to reproduce this issue when I simply replace my celestia.exe
file (SVN r4480) with Cartrite's r4473 build. So the problem doesn't
come from your installation. What is strange is that all other getinfo
fields are correctly returned... And I can reproduce this issue neither
with my Windows nor with my Qt4 builds of r4480.

So I would suggest to wait for Cartrite's next build. Then, I'll have a
deeper look at this issue if the problem is still present.

Vincent,

Thank you very much. I will just wait.

Paul
"Physicists know what's important, but they don't know what is true. Mathematicians know what's true, but they don't know what is important."

Topic author
SU(3)xSU(2)xU(1)
Posts: 59
Joined: 05.05.2008
With us: 16 years 7 months

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #8by SU(3)xSU(2)xU(1) » 04.10.2008, 16:12

I've updated to r4482 (Thank you Cartrite :) ).

Unfortunately, the problem is still present :( .

Paul
"Physicists know what's important, but they don't know what is true. Mathematicians know what's true, but they don't know what is important."

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

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #9by selden » 04.10.2008, 17:12

I just tested the script on my Windows system.

It fails with v1.5.1 + celestia.exe built from svn.
It works when used in a directory tree containing a complete download of Celestia from SourceForge.

My conclusion is that the problem is related to Celestia's revised catalog and configuration files. i.e. you need to have them all.
Selden

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

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #10by Vincent » 04.10.2008, 17:55

selden wrote:My conclusion is that the problem is related to Celestia's revised catalog and configuration files. i.e. you need to have them all.
Selden,

I'm not sure about that...
The hubbleType field doesn't work either using Cartrite's r4482 build and my SVN installation.
@+
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
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 3 months
Location: NY, USA

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #11by selden » 04.10.2008, 18:14

Vincent,

As I wrote, it works fine for me. It displays "Sb" in the upper left portion of Celestia's window.

I'm sure you're aware of this, but don't forget that you have to start the correct copy of Celestia by double-clicking on its icon *before* you select the script's icon. Otherwise the script will run the "installed" version of Celestia and fail because it's accessing the wrong set of catalog and configuration files. If that's not your problem, then I can only guess that your svn directory isn't actually up to date for some reason (maybe you've edited one of the critical files, for example, so svn can't update it correctly). You might try deleting the svn directory tree and re-download everything from scratch.
Selden

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

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #12by Vincent » 04.10.2008, 22:57

selden wrote:As I wrote, it works fine for me. It displays "Sb" in the upper left portion of Celestia's window.
Are you saying that it works for you using Cartrite's r4482 along with all other SVN files?

selden wrote:I'm sure you're aware of this, but don't forget that you have to start the correct copy of Celestia by double-clicking on its icon *before* you select the script's icon. Otherwise the script will run the "installed" version of Celestia and fail because it's accessing the wrong set of catalog and configuration files.
I always run scripts from the Celestia 'scripts' menu.

selden wrote:If that's not your problem, then I can only guess that your svn directory isn't actually up to date for some reason (maybe you've edited one of the critical files, for example, so svn can't update it correctly). You might try deleting the svn directory tree and re-download everything from scratch.
I just tested with a fresh SVN checkout and Cartrite's r4482, and I still have the same issue reported by Paul...
@+
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: 22 years 10 months
Location: Seattle, Washington, USA

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #13by chris » 04.10.2008, 23:01

It's working fine for me with the latest SVN code. This is very odd indeed. :S

--Chris

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

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #14by Vincent » 05.10.2008, 08:48

chris wrote:It's working fine for me with the latest SVN code. This is very odd indeed. :S
Chris,

It has always been working great for me too with the SVN code.
I have the issue reported by Paul when I replace my own compiled
celestia.exe file (SVN r4482) with Cartrite's r4482 celestia.exe. All
other SVN files are up-to-date and comes from a fresh SVN checkout.

Chris, Selden, could you please check out if you get the hubbletype
issue when simply replacing your celestia.exe with Cartrite's celestia.exe?
http://cartrite.myhosting247.com/index.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

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

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #15by chris » 05.10.2008, 22:18

Vincent wrote:Chris, Selden, could you please check out if you get the hubbletype
issue when simply replacing your celestia.exe with Cartrite's celestia.exe?
http://cartrite.myhosting247.com/index.html

When I use Cartrite's celestia.exe, hubbleType no longer works. And I figured out exactly what's going wrong. He's building Celestia with a different compiler (or compiler options) that makes the test in this code fragment return false:

Code: Select all

if (objTypeName == "galaxy")
    celx.setTable("hubbleType", deepsky->getType());


objTypeName is a char pointer, so the comparison needs to be done with strcmp, not the equality operator. The equality operator only returns true if objTypeName points to exactly the same location in memory as the constant value "galaxy" Some compilers uniquify string constant so that there will be only one instance of "galaxy" in the whole program. Other compilers don't do this. The code is wrong in any case. It should be:

Code: Select all

if (!strcmp(objTypeName, "galaxy"))
    celx.setTable("hubbleType", deepsky->getType());


Or we could use dynamic type information to find out whether the object is a galaxy:

Code: Select all

if (dynamic_cast<Galaxy*>(deepsky) != NULL)
    celx.setTable("hubbleType", deepsky->getType());


--Chris

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

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #16by Vincent » 06.10.2008, 15:47

Chris,

Thanks a lot. The fix is in SVN now.
@+
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

Topic author
SU(3)xSU(2)xU(1)
Posts: 59
Joined: 05.05.2008
With us: 16 years 7 months

Re: "dso:getinfo().hubbleType" doesn't work in r4473

Post #17by SU(3)xSU(2)xU(1) » 10.10.2008, 11:59

Vincent wrote:The fix is in SVN now.

I've updated to r4493 and the problem is gone :D

Chris, Vincent, Selden,

Thank you very much for all your help and for the fix.

Paul
"Physicists know what's important, but they don't know what is true. Mathematicians know what's true, but they don't know what is important."


Return to “Scripting”