Help required with js code
Moderators: winston, another_commander
Help required with js code
Could anyone help me with the appropriate script.
I don't understand js but can usually make do by copying other peoples code.
I want to jump into a new galaxy, scoot across to a 'spy' who sends me an 'on-screen message' and also uploads instructions to my 'mission screen'.
I can get this to work reasonably well with the following code:
this.playerEnteredNewGalaxy = function()
{
...
system.legacy_addShipsAtPrecisely("bountyhunter", 1, "w", [0, 0, 0.3]);
mission.setInstructionsKey("mission_galaxy_instructgo");
...
which puts my bounty hunter at the waybeacon
and the code in the bountyhunter AI:
"FOUND_PLAYER" = ("commsMessage: [hunter-here]", "setAITo: exitingTraderAI.plist");
which displays an on-screen message.
The above works well, but i have my mission sceen updated with the message BEFORE I rendezvous with the bountyhunter.
What is the code for updating the mission screen only after I get in range of the bountyhunter, i.e the on-screen message and the mission screen instructions occur together.
Thanks
I don't understand js but can usually make do by copying other peoples code.
I want to jump into a new galaxy, scoot across to a 'spy' who sends me an 'on-screen message' and also uploads instructions to my 'mission screen'.
I can get this to work reasonably well with the following code:
this.playerEnteredNewGalaxy = function()
{
...
system.legacy_addShipsAtPrecisely("bountyhunter", 1, "w", [0, 0, 0.3]);
mission.setInstructionsKey("mission_galaxy_instructgo");
...
which puts my bounty hunter at the waybeacon
and the code in the bountyhunter AI:
"FOUND_PLAYER" = ("commsMessage: [hunter-here]", "setAITo: exitingTraderAI.plist");
which displays an on-screen message.
The above works well, but i have my mission sceen updated with the message BEFORE I rendezvous with the bountyhunter.
What is the code for updating the mission screen only after I get in range of the bountyhunter, i.e the on-screen message and the mission screen instructions occur together.
Thanks
- Okti
- ---- E L I T E ----
- Posts: 700
- Joined: Sun Sep 26, 2010 1:51 pm
- Location: A GH shop, near witchpoint to Oresrati in Galaxy 8
Re: Help required with js code
Hi DGill,
Because you have the mission.setInstructionKey in the this.playerEnteredNewGalaxy event handler, the mission screen is updated when you enter the new galaxy.
You must work on a nother script block which will execute after player meets the bountyhunter.
Because you have the mission.setInstructionKey in the this.playerEnteredNewGalaxy event handler, the mission screen is updated when you enter the new galaxy.
You must work on a nother script block which will execute after player meets the bountyhunter.
Re: Help required with js code
Any suggestion as to what the function call trigger would be?Okti wrote:Hi DGill,
Because you have the mission.setInstructionKey in the this.playerEnteredNewGalaxy event handler, the mission screen is updated when you enter the new galaxy.
You must work on a nother script block which will execute after player meets the bountyhunter.
this.playerEnteredNewGalaxy seems to be a valid call - what would be the event call for meeting another ship?
- Okti
- ---- E L I T E ----
- Posts: 700
- Joined: Sun Sep 26, 2010 1:51 pm
- Location: A GH shop, near witchpoint to Oresrati in Galaxy 8
Re: Help required with js code
What you need to do is atach a js file to your bountyhunter shipdata.plist entry And Have a code similar to thatDGill wrote:Any suggestion as to what the function call trigger would be?
this.playerEnteredNewGalaxy seems to be a valid call - what would be the event call for meeting another ship?
Code: Select all
this.setMissionInstructions = function()
{
// do whatever you want
}
Code: Select all
"FOUND_PLAYER" = ("commsMessage: [hunter-here]","sendScriptMessage: setMissionInstructions", "setAITo: exitingTraderAI.plist");
Re: Help required with js code
Thanks Okti, I'll give it a try
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Help required with js code
Just note that when setting instructions from other scripts than the worldScript, you must specify the worldScript when setting instructions, or the code does not know for which script the instructions are.
Code: Select all
this.setMissionInstructions = function()
{
// do whatever you want
mission.setInstructionsKey("mission_galaxy_instructgo", "your_worldscript_name");
}
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Okti
- ---- E L I T E ----
- Posts: 700
- Joined: Sun Sep 26, 2010 1:51 pm
- Location: A GH shop, near witchpoint to Oresrati in Galaxy 8
Re: Help required with js code
Thats right, I missed that. You must add a wordscripts.plist file to your Config directory pointing to js file. If necessary send a temprorary location to your OXP and I will test it, and point you to the right directions.Eric Walch wrote:Just note that when setting instructions from other scripts than the worldScript, you must specify the worldScript when setting instructions, or the code does not know for which script the instructions are.Code: Select all
this.setMissionInstructions = function() { // do whatever you want mission.setInstructionsKey("mission_galaxy_instructgo", "your_worldscript_name"); }
- 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:
Re: Help required with js code
And note that what you are setting is not a mission screen, but the short mission description on the manifest screen. A mission screen is a different screen from the manifest screen.
Re: Help required with js code
He he - it worked! - thanks guys
Only took 4 or 5 hours (and a bottle of wine) to do a couple of lines of code! really appreciate now those who write oxp from scratch.
Only took 4 or 5 hours (and a bottle of wine) to do a couple of lines of code! really appreciate now those who write oxp from scratch.
- 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:
Re: Help required with js code
With time and practice you can certainly get it down to 2 or 3 hours, and half a bottle.DGill wrote:He he - it worked! - thanks guys
Only took 4 or 5 hours (and a bottle of wine) to do a couple of lines of code! really appreciate now those who write oxp from scratch.
But seriously, it takes time indeed, and the actual creation of code takes the least of it. Firing up Oolite again and again, and testing whether it actually does what you want, then figuring out that you accidentally inserted (or left out) a semicolon or comma, correcting this, firing up Oolite again, only to discover the next small bug, etc., etc., is what actually makes up the lion's share of OXP-creating.
- Mauiby de Fug
- ---- E L I T E ----
- Posts: 847
- Joined: Tue Sep 07, 2010 2:23 pm
Re: Help required with js code
This is the reason I haven't really got very far with my own efforts. I could probably find enough time to sit down and write things, if I didn't have to spend so much time booting up Oolite to find out what I did wrong.Commander McLane wrote:Firing up Oolite again and again, and testing whether it actually does what you want, then figuring out that you accidentally inserted (or left out) a semicolon or comma, correcting this, firing up Oolite again, only to discover the next small bug, etc., etc., is what actually makes up the lion's share of OXP-creating.
Actually, thinking about it now, it's just occurred to me that when it comes to doing the same things repeatedly, I could probably write something to paste into the Debug console to do things automatically. Except that means getting more proficient with that... Still, might save me some time in the long run...
Re: Help required with js code
I recommend business trips for this - nice long evenings without much other commitment and a good way to avoid staring at hotel walls or at CNN. Oh and the supply of wine is better as well
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
-
- Quite Grand Sub-Admiral
- Posts: 6683
- Joined: Wed Feb 28, 2007 7:54 am
Re: Help required with js code
Agree, but one has to be careful with that. I have often found myself in what started as nice long evenings without much commitment, fighting bugs (and I don't mean Thargoids here) until 03:30 in the morning, with an all-important meeting or presentation coming up at 08:00. It requires tremendous will power to be actually able to say 'I stop now' and stop, instead of 'I'll try this last thing, if it doesn't work I'm off to bed' over and over again.Thargoid wrote:I recommend business trips for this - nice long evenings without much other commitment and a good way to avoid staring at hotel walls or at CNN. Oh and the supply of wine is better as well
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Re: Help required with js code
You can save a lot of time here using the console, especially for world scripts.Commander McLane wrote:DGill wrote:But seriously, it takes time indeed, and the actual creation of code takes the least of it. Firing up Oolite again and again, and testing whether it actually does what you want, then figuring out that you accidentally inserted (or left out) a semicolon or comma, correcting this, firing up Oolite again, only to discover the next small bug, etc., etc., is what actually makes up the lion's share of OXP-creating.
Code: Select all
> this.oxp = worldScripts["whatever"]
> oxp.doSomething = function () { stuff; }
oxp.
to this.
when pasting it back into the world script. When you’ve fixed the syntax errors, you can test it by calling oxp.doSomething()
directly, or by triggering it through the game in the usual fashion.On a Mac, you can make this simpler by pressing option-up-arrow or page up to get the previous input line back, and option-return to type a newline without sending it to the console. You can also make the text entry area bigger by dragging the separator.
Under Linux (and presumably Windows), you can’t copy from the console, so do all the editing in a text editor and copy each change over.
I have no idea what you’re talking about.another_commander wrote:It requires tremendous will power to be actually able to say 'I stop now' and stop, instead of 'I'll try this last thing, if it doesn't work I'm off to bed' over and over again.
<_<
>_>
<_<
What’s this “willpower” thing, then?
E-mail: [email protected]
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Help required with js code
Yes, that works well when only changing small parts of the code. While Oolite is running, you can change the script, copy the changed function and paste it in the right way in the console. Works perfect for worldScripts and ship scripts. (Although you need to do it for every single ship you are examining, until you reboot Oolite)Mauiby de Fug wrote:Actually, thinking about it now, it's just occurred to me that when it comes to doing the same things repeatedly, I could probably write something to paste into the Debug console to do things automatically. Except that means getting more proficient with that... Still, might save me some time in the long run...
Ninja, Ahruman already gave the answer in more depth. I only can add that for ship scripts, I target the ship and than use:
Code: Select all
this.oxp = PS.target.script
UPS-Courier & DeepSpacePirates & others at the box and some older versions