Observer - splitview problems in celx scripts

All about writing scripts for Celestia in Lua and the .cel system
Topic author
maxim
Posts: 1036
Joined: 13.11.2003
With us: 21 years
Location: N?rnberg, Germany

Observer - splitview problems in celx scripts

Post #1by maxim » 17.01.2005, 16:58

I don't get along with this observers and multiple views in celx.

When I create a second view via 'splitview' and want to erase it again later I either get the first view deleted instead or I lose all my observer-objects validity. This even doesn't get restored when the script is canceled and restartet again.

observer1:splitview() results in observer1 being assigned to the newly created view.
observer2 = celestia:getobserver() creates an object identical to observer1.
observer1:singleview() OR
observer2:singleview() results in the first view beeing deleted.
observer1:deleteview() results in observer1 AND observer2 being invalid.
observer1 = celestia:getobserver() called again doesn't make observer1 valid again!

How can I change the actual view from within the script ??????

allobservers = celestia:getobservers()
allobservers[1]:singleview() results in view 1 being deleted.
allobservers[2]:singleview() results in all other observers becoming invalid and view 2 set to a random position! (????????)
observer1 = allobservers[2] doesn't restore anything.

So what???

maxim

Harry
Posts: 559
Joined: 05.09.2003
With us: 21 years 2 months
Location: Germany

Re: Observer - splitview problems in celx scripts

Post #2by Harry » 17.01.2005, 17:53

maxim wrote:observer1:splitview() results in observer1 being assigned to the newly created view.
Not really. observer1 is still the same "view", it just was reduced the half the size.
observer2 = celestia:getobserver() creates an object identical to observer1.
Calling celestia:getobserver() will return the active view/observer. This may be the same as observer1, but not necessarily so.
observer1:singleview() OR
observer2:singleview() results in the first view beeing deleted.
observer1:deleteview() results in observer1 AND observer2 being invalid.
So probably both refer to the same view.
observer1 = celestia:getobserver() called again doesn't make observer1 valid again!
Not sure what exactly happened there...

How can I change the actual view from within the script ??????
Can you clarify what exactly you are trying to do?

allobservers = celestia:getobservers()
allobservers[1]:singleview() results in view 1 being deleted.
allobservers[2]:singleview() results in all other observers becoming invalid and view 2 set to a random position! (????????)

Hm, there seems to be a bug in the code for singleview... I think I know what it is, but can't test it at the moment.

Harald

Topic author
maxim
Posts: 1036
Joined: 13.11.2003
With us: 21 years
Location: N?rnberg, Germany

Re: Observer - splitview problems in celx scripts

Post #3by maxim » 17.01.2005, 18:50

Harry wrote:Can you clarify what exactly you are trying to do?

As I said, creating a view pane (25% at bottom of window) and then destroying it again after some time.

The code above may be regarded as ONE code snipet. All comments are implying that the former commands had already been executed.

Also once the oberver1 and 2 became invalid a cancel and restart of the script result in an runtime error 'invalid object' on a line BEFORE the shown code snipet (actual the first line where the object is used, just after the getobserver() call)

maxim

Harry
Posts: 559
Joined: 05.09.2003
With us: 21 years 2 months
Location: Germany

Re: Observer - splitview problems in celx scripts

Post #4by Harry » 17.01.2005, 21:46

There is a bug, which AFAICS affects celestia:singleview and may even result in a crash of Celestia. But apart from that the following code should give you an idea of what should work (not tested):

Code: Select all

celestia:getobserver():splitview('h')
allobservers = celestia:getobservers()
observer1 = allobservers[1]
observer2 = allobservers[2]
... do stuff with observer1 & observer 2 ...
observer2.deleteview()


Harald

Topic author
maxim
Posts: 1036
Joined: 13.11.2003
With us: 21 years
Location: N?rnberg, Germany

Post #5by maxim » 18.01.2005, 09:37

I'll give it a try.

maxim

Topic author
maxim
Posts: 1036
Joined: 13.11.2003
With us: 21 years
Location: N?rnberg, Germany

Post #6by maxim » 18.01.2005, 23:49

Ok, I got it working as you proposed - and I found my error.
I was just tweaked by the thought that the bottom view is the new one, but it's always the top one that is new. Thus I confused the index numbers and got confused myself.

The sequence of the created views (vertical and horizontal) would be a good canditate to be documented.

maxim

Harry
Posts: 559
Joined: 05.09.2003
With us: 21 years 2 months
Location: Germany

Post #7by Harry » 21.01.2005, 16:46

I just checked in a bugfix for singleview. With this fix it should now work as expected in all coming versions.

Harald


Return to “Scripting”