Page 1 of 1

local planetinfo overrides

Posted: Wed Dec 14, 2011 4:24 am
by Wildeblood
Generally, how to amend information on the F7 screen, but prevent Oolite from storing the amendments in the local_planetinfo_overrides section of the player's saved game?

Specifically, for Explorers' Club, how to check the system displayed on the F7 screen against the array of visited systems, and append either "You have visited this system before." or "You have never visited this system." to the displayed systeminfo description, without that change being permanently added to local planetinfo overrides?

Any suggestions would be much appreciated.

Re: local planetinfo overrides

Posted: Wed Dec 14, 2011 4:54 am
by Capt. Murphy
Wildeblood - I have an untested idea as to how this could be achieved. The check could be done as the player enters the f7 screen, the text added if appropriate, and then removed again as the player exits the screen.

Re: local planetinfo overrides

Posted: Fri Dec 16, 2011 1:01 pm
by Kaks
If you use the same methods the native Oolite missions use you won't be too far wrong: mission.addMessageText() & mission.addMessageTextKey() were created specifically to add on-the-fly info to gui screens...

Have a look inside oolite-constrictor-hunt-mission.js, inside the .guiScreenChanged event handler to see the TextKey variant 'in action' on the system data screen! :)

Re: local planetinfo overrides

Posted: Fri Dec 16, 2011 4:46 pm
by Wildeblood
Kaks wrote:
If you use the same methods the native Oolite missions use you won't be too far wrong: mission.addMessageText() & mission.addMessageTextKey() were created specifically to add on-the-fly info to gui screens...
I assumed they only worked on the manifest screen, that's where everyone seems to use them. But look here, it's a bit gawdy on the system data screen, it changes the text colour from green to yellow.

Image

I think backing up the description to some obviously named variable like this.system_description_backup on entering the F7 screen, then restoring it as you leave that screen would be a bit swisher.

Now, back to the subject of local planetinfo overrides, where can I read the documentation? I seem to have broken it. :(

I have saved games with lots of stuff in there, but it doesn't show up in game. I assumed a misplaced pointy bracket, so when I loaded and re-saved one I expected to see the local_planetinfo_overrides section flushed. But no, it's all still in there. So I'm thinking there's a limit to how much can be stored in there, and I've gone over the limit so the game is just ignoring it all?

Re: local planetinfo overrides

Posted: Wed Dec 21, 2011 5:48 am
by Capt. Murphy
Kaks wrote:
If you use the same methods the native Oolite missions use you won't be too far wrong: mission.addMessageText() & mission.addMessageTextKey() were created specifically to add on-the-fly info to gui screens...

Have a look inside oolite-constrictor-hunt-mission.js, inside the .guiScreenChanged event handler to see the TextKey variant 'in action' on the system data screen! :)
Just a note that mission.addMessageText() needs to be documented on the wiki... :wink:

Re: local planetinfo overrides

Posted: Wed Dec 21, 2011 8:24 am
by Eric Walch
Capt. Murphy wrote:
Just a note that mission.addMessageText() needs to be documented on the wiki... :wink:
You probably mean mission.addMessageTextKey() from Kaks remark? But there he was mixing things up as that method does not exists. mission.addMessageText() can be found on the Mission page.
But, I now added a comment that it works on non-missionscreens as well. :)

Re: local planetinfo overrides

Posted: Thu Dec 22, 2011 5:04 am
by Kaks
Nope, mission.addMessageTextKey() does exist, and can be tested using the js console. However, it's defined inside oolite-global-prefix.js rather than next to .addMessageText() (not exactly sure why, but the big A might be able to tell us).
Maybe we should have an extra comment inside OOJSMission.m as a quick reminder... ;)

Re: local planetinfo overrides

Posted: Thu Dec 22, 2011 6:20 am
by JensAyton
Kaks wrote:
Nope, mission.addMessageTextKey() does exist, and can be tested using the js console. However, it's defined inside oolite-global-prefix.js rather than next to .addMessageText() (not exactly sure why, but the big A might be able to tell us).
Because native callbacks are fiddly, error-prone and hard to maintain, and there’s no significant disadvantage to implementing it in the prefix. This is the motivation for the various other convenience wrappers defined there, too.

(My basic position is/was that anything that can be implemented in JS without a significant performance hit should be. For example, I evaluated implementing all vector and quaternion operations in JS, but it turned out that building JS vector objects from C using slots for the fields was significantly more expensive than sticking a malloced struct in the private field, and doing maths in JS using the private-field approach was significantly more expensive than using slots. This could of course change with future versions of SpiderMonkey.)

Re: local planetinfo overrides

Posted: Thu Dec 22, 2011 3:21 pm
by Kaks
Aha, I knew there was a reason! :D

Thanks, Ahruman! :)

Re: local planetinfo overrides

Posted: Thu Dec 22, 2011 3:32 pm
by Kaks
Wildeblood wrote:
Now, back to the subject of local planetinfo overrides, where can I read the documentation? I seem to have broken it. :(

I have saved games with lots of stuff in there, but it doesn't show up in game. I assumed a misplaced pointy bracket, so when I loaded and re-saved one I expected to see the local_planetinfo_overrides section flushed. But no, it's all still in there. So I'm thinking there's a limit to how much can be stored in there, and I've gone over the limit so the game is just ignoring it all?
[EliteWiki] Here!

When loading a savegame, the overrides inside the savegame are superimposed to all the overrides in all planetinfo.plists.
When changing a system's value - via javascript or legacy scripting - the overrides are updated immediately.

When retrieving any system data Oolite does the following:
  • it generates the pseudo-random data
  • it looks for all possible overrides, and uses the overridden data if present.
There's no limit to the override data that can be stored inside either planetinfo.plist, or the savegame. If you want, you could PM me the savegame(s) in question, and I can try & figure out what's going on... :)