Creating misssion oxp

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

Moderators: winston, another_commander

User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Rustybolts wrote:
My pm?
Good site though!
You can also look at https://developer.mozilla.org/en/JavaScript
hacht
Average
Average
Posts: 9
Joined: Fri Jul 17, 2009 11:46 am

Post by hacht »

User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

hacht wrote:
Yes, that's what I'm using myself. It has the limitation that it is centred around using JavaScript in HTML-documents for creating web-pages and doesn't give advice on how to create scripts that work as a mod of a game. But still it is very helpful for learning the JS-syntax.
User avatar
Rustybolts
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jun 07, 2009 6:22 pm
Location: UK

Post by Rustybolts »

Converting Blackjacksbullion to js here's what i have so far

Code: Select all

	if ( galaxyNumber==1){
		if (player.dockedStation.isMainStation && !missionVariables.bolts && system.ID==241){
			this.setMissionMusic: none;
			setMissionImage: pod.png;
            setGuiToMissionScreen;
            addMissionText: revengebolts_briefing; 
            setMissionDescription: bolts1;
			missionVariables.bolts='STAGE1';
		}
		if (system.ID==88 && missionVariables.bolts=='STAGE1' && status_string == STATUS_EXITING_WITCHSPACE){
			this.addSystemShips: bolts 1 0.10;
		}
		if (mission_bolts_targetdead == 'TRUE' && mission_bolts == 'STAGE1'){
			this.awardCargo: 20 Gold;
			missionVariables.bolts='STAGE2';
			clearMissionDescription;
		}
		if (player.dockedStation.isMainStation && missionVariables.bolts == 'STAGE2'){
			this.clearMissionScreen;
			setMissionMusic: none;
			setMissionImage: firearms.png;
            setGuiToMissionScreen; 
            addMissionText: revengebolts_firearms; 
            setMissionDescription: bolts2;
			missionVariable.bolts='STAGE3';		
		}	
Does this look ok am i doing anything wrong ?
Do i use

Code: Select all

planetNumber==243
or current

Code: Select all

system.Id==243
or are these both the same and dont make much difference?
Oh and is their an equivalent of

Code: Select all

gui_screen_string oneof GUI_SCREEN_STATUS, GUI_SCREEN_EQUIP_SHIP, GUI_SCREEN_SHORT_RANGE_CHART
in js?
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Image
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Post by Svengali »

Rustybolts wrote:
Do i use

Code: Select all

planetNumber==243
or current

Code: Select all

system.Id==243
or are these both the same and dont make much difference?
Both will work (ID not Id), but I'd prefer system.ID.
Rustybolts wrote:
Oh and is their an equivalent of

Code: Select all

gui_screen_string oneof GUI_SCREEN_STATUS, GUI_SCREEN_EQUIP_SHIP, GUI_SCREEN_SHORT_RANGE_CHART
There are different ways to do it

Code: Select all

if(guiScreen == "GUI_SCREEN_STATUS" || guiScreen == "GUI_SCREEN_EQUIP_SHIP" || guiScreen == "GUI_SCREEN_SHORT_RANGE_CHART") { your code }
The other a bit more elegant way is to use an array

Code: Select all

var myGuiChecks = ["GUI_SCREEN_STATUS", "GUI_SCREEN_EQUIP_SHIP", "GUI_SCREEN_SHORT_RANGE_CHART"];
if(myGuiChecks.indexOf(guiScreen) != -1) { your code }
If there are more places in the script that will need this check declare it as property

Code: Select all

this.myGuiChecks = ["GUI_SCREEN_STATUS", "GUI_SCREEN_EQUIP_SHIP", "GUI_SCREEN_SHORT_RANGE_CHART"];
if(this.myGuiChecks.indexOf(guiScreen) != -1) { your code }
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

And you can replace:

Code: Select all

      if (player.dockedStation.isMainStation && !missionVariables.bolts && system.ID==241){ 
         this.setMissionMusic: none; 
         setMissionImage: pod.png; 
            setGuiToMissionScreen; 
            addMissionText: revengebolts_briefing; 
            setMissionDescription: bolts1; 
         missionVariables.bolts='STAGE1'; 
      } 
by

Code: Select all

      if (player.dockedStation.isMainStation && !missionVariables.bolts && system.ID==241){ 
         mission.runMissionScreen("revengebolts_briefing", "pod.png")
            setMissionDescription: bolts1; 
         missionVariables.bolts='STAGE1'; 
      } 
As we have a new command that does it all for you. You can also define music and ships with it. It also makes sure that unused stuff is cleared properly so you don't have to think at it. Only for special cases you might want to use the individual commands.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Svengali wrote:
Rustybolts wrote:
Oh and is their an equivalent of

Code: Select all

gui_screen_string oneof GUI_SCREEN_STATUS, GUI_SCREEN_EQUIP_SHIP, GUI_SCREEN_SHORT_RANGE_CHART
There are different ways to do it

Code: Select all

if(guiScreen == "GUI_SCREEN_STATUS" || guiScreen == "GUI_SCREEN_EQUIP_SHIP" || guiScreen == "GUI_SCREEN_SHORT_RANGE_CHART") { your code }
In most cases, though, what you want is simply:

Code: Select all

if(guiScreen != "GUI_SCREEN_MISSION") { your code }
The whole list with the oneof was only necessary because in legacy scripting there was no notequal.
User avatar
Rustybolts
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jun 07, 2009 6:22 pm
Location: UK

Post by Rustybolts »

Error log:-
[script.javaScript.exception.125]: ***** JavaScript exception: SyntaxError: invalid label
[script.javaScript.exception.125]: AddOns/Blackjacksbullion.oxp/Config/script.js, line 14: this.addSystemShips: bolts 1 0.10;
[script.javaScript.load.failed]: ***** Error loading JavaScript script AddOns/Blackjacksbullion.oxp/Config/script.js -- compilation failed
Code:-

Code: Select all

	if ( galaxyNumber==1){
		if (guiScreen != "GUI_SCREEN_MISSION" && player.dockedStation.isMainStation && !missionVariables.bolts && system.ID==241){
			this.mission.runMissionScreen("revengebolts_briefing", "pod.png");
            setMissionDescription: bolts1;
			missionVariables.bolts='STAGE1';
		}
		if (system.ID==88 && missionVariables.bolts=='STAGE1' && status_string == STATUS_EXITING_WITCHSPACE){
			this.addSystemShips: bolts 1 0.10;
		}
		if (mission_bolts_targetdead == 'TRUE' && mission_bolts == 'STAGE1'){
			this.awardCargo: 20 Gold;
			missionVariables.bolts='STAGE2';
			clearMissionDescription;
		}
		if (guiScreen != "GUI_SCREEN_MISSION" && player.dockedStation.isMainStation && missionVariables.bolts == 'STAGE2'){
			this.mission.runMissionScreen("revengebolts_firearms", "firearms.png");
            setMissionDescription: bolts2;
			missionVariable.bolts='STAGE3';		
		}	
		if (guiScreen != "GUI_SCREEN_MISSION" && player.dockedStation.isMainStation && missionVariables.bolts == 'STAGE3' && system.ID==233){
			this.mission.runMissionScreen("revengebolts_robbery")
			awardCargo 1 Firearms;
			missionVariable.bolts='STAGE4';
			setMissionDescription: bolts3;
		}
		if (guiScreen != "GUI_SCREEN_MISSION" && player.dockedStation.isMainStation && missionVariables.bolts == 'STAGE4' && system.ID==127){
			this.mission.runMissionScreen("revengebolts_flee", "vipers.png");
			setLegalStatus: 64;
			missionVariable.bolts='STAGE5';
			setMissionDescription: bolts4;
		}
		if (missionVariables.bolts=='STAGE5'){
			this.setLegalStatus: 64;
		}
		if (system.ID==99 && missionVariables.bolts=='STAGE5' && status_string == STATUS_EXITING_WITCHSPACE){
			this.addSystemShips: witness 1 0.10;
		}
		if (mission_witness_targetdead == 'TRUE' && mission_bolts == 'STAGE5'){
			this.missionVariables.bolts='STAGE6';
			clearMissionDescription;
			setMissionDescription: bolts5;
		}
		if (missionVariables.bolts=='STAGE6'){
			this.setLegalStatus: 64;
		}
		if (guiScreen != "GUI_SCREEN_MISSION" && player.dockedStation.isMainStation && missionVariables.bolts == 'STAGE6' && system.ID==67){
			this.mission.runMissionScreen("revengebolts_finnish", "end.png")
			awardCredits: 9500;
			missionVariable.bolts='STAGE99';
			setLegalStatus: 0;
			clearMissionDescription;
		}
	}
Am i adding my ships wrong?
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Image
User avatar
Rustybolts
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jun 07, 2009 6:22 pm
Location: UK

Post by Rustybolts »

This way of writing it seems to of passed that error

Code: Select all

addSystemShips("bolts", 1, 0.10);
LOL but my next error log is
[script.javaScript.exception.125]: ***** JavaScript exception: SyntaxError: invalid label
[script.javaScript.exception.125]: AddOns/Blackjacksbullion.oxp/Config/script.js, line 17: this.awardCargo: 20 Gold;
*edit* I think i have the correct format now as this:-

Code: Select all

awardCargo(20, "Gold");
corrected it.

Code: Select all

this.setLegalStatus: 64;
was also wrong

Code: Select all

this.setLegalStatus(64);
after correcting all cases with above format the log contained no errors :D
All that is left is to test play the mission to see if it plays as it should.
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Image
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Post by Svengali »

Rustybolts wrote:
after correcting all cases with above format the log contained no errors :D
Really? I'm surprised that mixing legacy scripting with js doesn't give you some 'hits' in Latest.log.
Anyway - better use the follwing

Code: Select all

system.legacy_addSystemShips("bolts", 1, 0.10);
player.ship.awardCargo("Gold",20);
player.ship.bounty = 64;
And there is more to be explored. Please take a look in the WIKI -> Category:Oolite scripting - EliteWiki
User avatar
Rustybolts
---- E L I T E ----
---- E L I T E ----
Posts: 293
Joined: Sun Jun 07, 2009 6:22 pm
Location: UK

Post by Rustybolts »

Svengali wrote:
Rustybolts wrote:
after correcting all cases with above format the log contained no errors :D
Really? I'm surprised that mixing legacy scripting with js doesn't give you some 'hits' in Latest.log.
Anyway - better use the follwing

Code: Select all

system.legacy_addSystemShips("bolts", 1, 0.10);
player.ship.awardCargo("Gold",20);
player.ship.bounty = 64;
And there is more to be explored. Please take a look in the WIKI -> Category:Oolite scripting - EliteWiki
Thanks for that.
Have just discovered i should of awarded credits by

Code: Select all

player.credits+=9500;
Bring back programming on the spectrum, you knew you had made a mistake by that loud beep and the red flashing cursor highlighting the line that was wrong.
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Image
Post Reply