I had
Code: Select all
this.missionScreenEnded=function(){
mission.clearMissionScreen();
}
Moderators: winston, another_commander, Getafix
Code: Select all
this.missionScreenEnded=function(){
mission.clearMissionScreen();
}
Code: Select all
this.doingMissionScreen = false // Set to true when starting a mission screen
this.shipWillLaunchFromStation = function(station)
{
if (this.doingMissionScreen) this.missionScreenEnded() // Should only happen in 1.70
}
this.missionScreenEnded = function()
{
if (this.doingMissionScreen)
{
mission.clearMissionScreen()
// Any post-mission handling
this.doingMissionScreen = false
}
}
And into the Java translations of UPS were I copied this. But I still think one needs a common variable among scripts like the "mission_offering" I am consequently using, to tell that the script wants to set up a second mission screen. Without this variable and other scripts that respect this variable status, you can get the situation that script 1 sets up his 1st screen, script 2 shows the second screen and script 1 shows his second screen. Mission screens are interfering with each other. But not really clashing in the way you loose information, just the display order will not be correct. It will be rare however as multiple screen offers are rare and there must be a second script also setting up a mission screen.Ahruman wrote:Note: missionScreenEnded is sent to all world scripts (and the player ship script) when a mission screen end, so you should only be doing things in it if you think you’re currently in a mission screen. Look at oolite-trumbles-mission.js for an example.
Code: Select all
this.missionScreenEnded = function()
{
if (this.doingMissionScreen)
{
mission.clearMissionScreen()
mission.setBackgroundImage('none');
//LogWithClass('script.'+this.name , 'screen ended!!');
// Any post-mission handling
this.doingMissionScreen = false
}
}
It could. I already thought of that. I was already one step further as I am resetting any mission choices in UPS on launch. I added that long ago as I noticed that several other missions didn't reset this properly and forcing my script not to offer anything as i could not figure out If there would come a reaction. So when you clear the choices on launch, it can't be some others screen.It could be someone else’s mission screen. For instance, if someone left the station while the trumble mission screen was up, prior to revision 1339.
I don’t see a clean way to do this in the current structure. A better way of handling mission screens (creating Mission objects, customizing them and then showing them atomically, with no means of cross-contamination between screens) is one of those would-be-good-in-future things.Eric Walch wrote:EDIT:
On second thought: Make the choices local to the script that called them
Thanks, I saw future bug occurring with misuse of this function as the name is misleading when it does more than just clearing things of the missionscreen. In my newest UPS I do the missionscreens in a special function. That is the most easiest way and you don't have to do any clearing every time. The function takes care of that.In the meantime, I’ve removed resetMissionChoice from clearMissionScreen on the basis that you clearly have a better grasp of writing mission screens than I do.
Code: Select all
this.missionScreen=function(messageKey, backGround, choiceKey, myMusic, myShipModel)
{
mission.showShipModel(myShipModel);mission.setMusic(myMusic)
mission.setBackgroundImage(backGround);
mission.showMissionScreen();
mission.addMessageTextKey(messageKey);
if (choiceKey != null) mission.setChoicesKey(choiceKey)
mission.clearMissionScreen();
}
Code: Select all
this.missionScreen=function(messageKey, backGround, choiceKey, myMusic, myShipModel)
{
mission.showShipModel(myShipModel);mission.setMusic(myMusic)
mission.setBackgroundImage(backGround);
mission.showMissionScreen();
mission.addMessageTextKey(messageKey);
if (choiceKey != null) mission.setChoicesKey(choiceKey)
mission.showShipModel();mission.setMusic()
mission.setBackgroundImage();
}
Code: Select all
player.call("playSound:", 'yoursound.ogg');
Code: Select all
this.missionScreen=function(messageKey, backGround, choiceKey, myMusic, myShipModel)
{
mission.showShipModel(myShipModel);
player.call('playSound:', myMusic); //found in the Sound directory, not Music
mission.setBackgroundImage(backGround);
mission.showMissionScreen();
mission.addMessageTextKey(messageKey);
if (choiceKey) mission.setChoicesKey(choiceKey);
mission.showShipModel();
mission.setBackgroundImage();
}
Code: Select all
this.missionScreen("ups_docs_1st_offer", "UPS.png", "ups_docs_accepted_yesno")
//and
this.missionScreen("ups_docs_1st_delivery", "UPS.png")
Code: Select all
mission.setBackgroundImage();
Music is supposed to work cross-platform in the trunk, though. If it doesn’t, I’d like to hear about it. :-)Kaks wrote:Hey, did I hear my name? :D
Thanks about the extra work on this.missionScreen. There's just two points I'd like to add:
- instead of mission.setMusic you can useto make the sound work on a windows / linux computer in Oolite 1.70. The ogg file needs to be inside the Sound directory instead of the Music one. That way everybody hears the mission sound!Code: Select all
player.call("playSound:", 'yoursound.ogg');
Possibly fixed in r1370, please test.One thing that doesn't seem to work for me, on a windows pc, is the
bit. What I wanted to do was to clear the background image if the player pressed 1 to leave the station in the middle of a briefing. If I press 1 and - once in flight - press 6, the mission background is displayed with the local map. I'm still trying to figure out a way to solve that problem. Who knows, it might be sorted out for 1.71! :)Code: Select all
mission.setBackgroundImage();
Code: Select all
mission.setBackgroundImage();
In that case, I shall entertain the hope that Sound.playMusic() does, too. :-)Kaks wrote:mission.setMusic now works on windows.
Code: Select all
Sound.playMusic('musicfile.ogg');