Posted: Thu Jul 23, 2009 8:01 pm
You can also look at https://developer.mozilla.org/en/JavaScriptRustybolts wrote:My pm?
Good site though!
For information and discussion about Oolite.
https://bb.oolite.space/
You can also look at https://developer.mozilla.org/en/JavaScriptRustybolts wrote:My pm?
Good site though!
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
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';
}
Code: Select all
planetNumber==243
Code: Select all
system.Id==243
Code: Select all
gui_screen_string oneof GUI_SCREEN_STATUS, GUI_SCREEN_EQUIP_SHIP, GUI_SCREEN_SHORT_RANGE_CHART
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 }
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';
}
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 }
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;
}
}
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);
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
Code: Select all
system.legacy_addSystemShips("bolts", 1, 0.10);
player.ship.awardCargo("Gold",20);
player.ship.bounty = 64;
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;
Code: Select all
player.credits+=9500;