You can also look at https://developer.mozilla.org/en/JavaScriptRustybolts wrote:My pm?
Good site though!
Creating misssion oxp
Moderators: winston, another_commander
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
UPS-Courier & DeepSpacePirates & others at the box and some older versions
A good resource for German or French speaking people might be http://de.selfhtml.org/javascript/sprache/index.htm or http://fr.selfhtml.org/javascript/langage/index.htm
- Commander McLane
- ---- 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:
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.hacht wrote:A good resource for German or French speaking people might be http://de.selfhtml.org/javascript/sprache/index.htm or http://fr.selfhtml.org/javascript/langage/index.htm
- Rustybolts
- ---- E L I T E ----
- Posts: 293
- Joined: Sun Jun 07, 2009 6:22 pm
- Location: UK
Converting Blackjacksbullion to js here's what i have so far
Does this look ok am i doing anything wrong ?
Do i use or current or are these both the same and dont make much difference?
Oh and is their an equivalent of
in js?
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';
}
Do i use
Code: Select all
planetNumber==243
Code: Select all
system.Id==243
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
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Both will work (ID not Id), but I'd prefer system.ID.Rustybolts wrote:Do i useor currentCode: Select all
planetNumber==243
or are these both the same and dont make much difference?Code: Select all
system.Id==243
There are different ways to do itRustybolts wrote:Oh and is their an equivalent ofCode: Select all
gui_screen_string oneof GUI_SCREEN_STATUS, GUI_SCREEN_EQUIP_SHIP, GUI_SCREEN_SHORT_RANGE_CHART
Code: Select all
if(guiScreen == "GUI_SCREEN_STATUS" || guiScreen == "GUI_SCREEN_EQUIP_SHIP" || guiScreen == "GUI_SCREEN_SHORT_RANGE_CHART") { your code }
Code: Select all
var myGuiChecks = ["GUI_SCREEN_STATUS", "GUI_SCREEN_EQUIP_SHIP", "GUI_SCREEN_SHORT_RANGE_CHART"];
if(myGuiChecks.indexOf(guiScreen) != -1) { your code }
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 }
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
And you can replace:
by
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.
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';
}
Code: Select all
if (player.dockedStation.isMainStation && !missionVariables.bolts && system.ID==241){
mission.runMissionScreen("revengebolts_briefing", "pod.png")
setMissionDescription: bolts1;
missionVariables.bolts='STAGE1';
}
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Commander McLane
- ---- 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:
In most cases, though, what you want is simply:Svengali wrote:There are different ways to do itRustybolts wrote:Oh and is their an equivalent ofCode: Select all
gui_screen_string oneof GUI_SCREEN_STATUS, GUI_SCREEN_EQUIP_SHIP, GUI_SCREEN_SHORT_RANGE_CHART
Code: Select all
if(guiScreen == "GUI_SCREEN_STATUS" || guiScreen == "GUI_SCREEN_EQUIP_SHIP" || guiScreen == "GUI_SCREEN_SHORT_RANGE_CHART") { your code }
Code: Select all
if(guiScreen != "GUI_SCREEN_MISSION") { your code }
- Rustybolts
- ---- E L I T E ----
- Posts: 293
- Joined: Sun Jun 07, 2009 6:22 pm
- Location: UK
Error log:-
Am i adding my ships wrong?
Code:-[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: 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;
}
}
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
- Rustybolts
- ---- E L I T E ----
- Posts: 293
- Joined: Sun Jun 07, 2009 6:22 pm
- Location: UK
This way of writing it seems to of passed that error
LOL but my next error log is
corrected it.
was also wrong
after correcting all cases with above format the log contained no errors
All that is left is to test play the mission to see if it plays as it should.
Code: Select all
addSystemShips("bolts", 1, 0.10);
*edit* I think i have the correct format now as this:-[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;
Code: Select all
awardCargo(20, "Gold");
Code: Select all
this.setLegalStatus: 64;
Code: Select all
this.setLegalStatus(64);
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
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
Really? I'm surprised that mixing legacy scripting with js doesn't give you some 'hits' in Latest.log.Rustybolts wrote:after correcting all cases with above format the log contained no errors :D
Anyway - better use the follwing
Code: Select all
system.legacy_addSystemShips("bolts", 1, 0.10);
player.ship.awardCargo("Gold",20);
player.ship.bounty = 64;
- Rustybolts
- ---- E L I T E ----
- Posts: 293
- Joined: Sun Jun 07, 2009 6:22 pm
- Location: UK
Thanks for that.Svengali wrote:Really? I'm surprised that mixing legacy scripting with js doesn't give you some 'hits' in Latest.log.Rustybolts wrote:after correcting all cases with above format the log contained no errors
Anyway - better use the follwingAnd there is more to be explored. Please take a look in the WIKI -> Category:Oolite scripting - EliteWikiCode: Select all
system.legacy_addSystemShips("bolts", 1, 0.10); player.ship.awardCargo("Gold",20); player.ship.bounty = 64;
Have just discovered i should of awarded credits by
Code: Select all
player.credits+=9500;
STE.+ Firefly/Dragonfly + BlackJacksbullion v.1.23 link below.
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871
http://www.mediafire.com/?sharekey=ca16 ... f6e8ebb871