A rather long question about the Planetfall.oxp

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
User avatar
lave
Deadly
Deadly
Posts: 141
Joined: Thu Sep 09, 2010 12:21 am
Location: Deep in Leesti space mining asteroids for a living.
Contact:

A rather long question about the Planetfall.oxp

Post by lave »

Hi all.

I am new to oxp scripting. However I have been reading through the files for the planetfall.oxp and some of it actually makes sence to me.

I can see from the script file that a screen will pop up if you land on an 'open field' or 'waste ground (dump)'.

Going through the files, I can see that this.lastPlanetType = "Prime" checks to make sure you are landing on a prime planet.

Then I see that this.landingChoice = (Math.random()*10) creates a randon number. This number determines where you are on a planet... Capital City, Military Base, Shipyard, ect...

I know there are other variables that check to see if you are on a sub planet or a moon too.

Now, this works fine and when I land on a prime planet I see the F5 screen says... Lave Prime - Shipyard, ect...

Now what I tried to do was set it up so that I ALWAYS landed on an 'Open Field' by changing this.landingChoice = (Math.random()*10) to this.landingChoice = 9.8.

This would then activate if(this.landingChoice >= 9.8) // spawn open fields or waste dump.

This works because the F5 screen says... Lave Prime - Open Fields.

Looking at the other variable, I see that...

if(!player.ship.dockedStation.hasRole("planetFall_noTrade")) // if we're at a location where trading is not possible
{ return; }


and

// no-one to trade with in empty fields
if(player.ship.dockedStation.hasRole("planetFall_mainSurface_fields") || player.ship.dockedStation.hasRole("planetFall_subSurface_fields"))
{
if(guiScreen == "GUI_SCREEN_EQUIP_SHIP" || guiScreen == "GUI_SCREEN_MARKET")
{
mission.runScreen({title:"Nothing but fields...", messageKey:"planetFall_noTrade", background:"planetFall_fields.png"});
}
}


...are true, so when I land on a main planet and arrive at an open field, then a screen should appear with an open field image for the background and then some text from the missiontext.plist file.

However that didn't work.

All that happened was that the F5 screen had my location on it as Lave Prime - Open Field.

The strange thing is that I know that the screen function with the background image works because it worked when I landed on a moon once.
It just don't seem to work when I change this.landingChoice = (Math.random()*10) to this.landingChoice = 9.8 to make me always land there.

The reason I was testing this out is because I was hoping to write a small oxp (or edit the existing one) so that a new background image was displayed for each possible landing location.
So a city image for Capital City, a miltiary base image for the Military Base, a shipyard image for the Shipyard, ect....

Can anyone help me with this as it's doing my head in lol.

Other than that, if someone could write a small script to work with Planetfall that would display a background image for a location, I can then duplicate that for each other location and make background images for each one.

Idealy I'd love to see a different background image on the F5 screen for each location on a planet or moon but I think that would not be possible.

Thanks.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

Moved to Expansion Pack.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

You're misunderstanding it slightly.

Planetfall was written before customisable backgrounds were available in the game (I think I wrote it around Oolite 1.72 or thereabouts). What the script does is intercept gui screen changes from the status screen to the marketplace or equipment screens in the non-trade locations when you're "docked" (ie in the temporary station used to simulate planetary landing), and in such cases it pops up a mission screen with the relevant background and the text about not being able to trade (thus blocking access to the original screens).

In your example above, when you land on the open field location you should see the standard F5 screen as you describe. The image screen should (and will) only appear when you press either F3 or F8.

I'm not keen on the idea of specific backgrounds for the planetary locations, as it would probably clash horribly with other OXPs which may do something similar (BGS mainly, but there may be others in the future) plus it would increase the OXP size quite considerably given how many images would be required.

If you want to do it for your own personal use then I would suggest looking at the scripting in BGS to give you more idea on how to do it. But for anything beyond that I would draw your attention to the license included with PF. A bolt-on additional script (as a separate OXP) is OK, but distributing it as a modifed version of the OXP isn't.
User avatar
lave
Deadly
Deadly
Posts: 141
Joined: Thu Sep 09, 2010 12:21 am
Location: Deep in Leesti space mining asteroids for a living.
Contact:

Post by lave »

Thargoid wrote:
In your example above, when you land on the open field location you should see the standard F5 screen as you describe. The image screen should (and will) only appear when you press either F3 or F8.
DOH!!! Yes I see that now. And I also understand that particular part of the code now too. Thanks.
Thargoid wrote:
If you want to do it for your own personal use then I would suggest looking at the scripting in BGS to give you more idea on how to do it.
Yes I have BGS so I will take a look.
Thargoid wrote:
A bolt-on additional script (as a separate OXP) is OK, but distributing it as a modifed version of the OXP isn't.
I would never distribute a modified version of any OXP without permission first. If I can do what I want then it would be for personal use anyway.

Thanks.
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Post by Svengali »

lave wrote:
Thargoid wrote:
If you want to do it for your own personal use then I would suggest looking at the scripting in BGS to give you more idea on how to do it.
Yes I have BGS so I will take a look.
The script does not much with images as nearly everything is done by Oolite via screenbackgrounds.plist. The interesting part for you happens in guiScreenChanged. There I'm switching the background (setScreenBackground()) if specific properties are set:

Code: Select all

if(this.bgsImageSwitch && (this.bgsDisableCrowd || this.bgsNoCrowd) && to==='GUI_SCREEN_STATUS') setScreenBackground('bgs-i_statusdocked_nocrowd.png');
Post Reply