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
Observer - splitview problems in celx scripts
Re: Observer - splitview problems in celx scripts
Not really. observer1 is still the same "view", it just was reduced the half the size.maxim wrote:observer1:splitview() results in observer1 being assigned to the newly created view.
Calling celestia:getobserver() will return the active view/observer. This may be the same as observer1, but not necessarily so.observer2 = celestia:getobserver() creates an object identical to observer1.
So probably both refer to the same view.observer1:singleview() OR
observer2:singleview() results in the first view beeing deleted.
observer1:deleteview() results in observer1 AND observer2 being invalid.
Not sure what exactly happened there...observer1 = celestia:getobserver() called again doesn't make observer1 valid again!
Can you clarify what exactly you are trying to do?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! (????????)
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
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
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):
Harald
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
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
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