Page 1 of 1

Observer - splitview problems in celx scripts

Posted: 17.01.2005, 16:58
by maxim
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

Re: Observer - splitview problems in celx scripts

Posted: 17.01.2005, 17:53
by Harry
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

Re: Observer - splitview problems in celx scripts

Posted: 17.01.2005, 18:50
by maxim
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

Re: Observer - splitview problems in celx scripts

Posted: 17.01.2005, 21:46
by Harry
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

Posted: 18.01.2005, 09:37
by maxim
I'll give it a try.

maxim

Posted: 18.01.2005, 23:49
by maxim
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

Posted: 21.01.2005, 16:46
by Harry
I just checked in a bugfix for singleview. With this fix it should now work as expected in all coming versions.

Harald