Yeah, it was originally like that, but it doesn't make sense to me. My intention isn't that the UFOship be already in the area, but that it responds to a prompt that a certain number of thargoids are present. The UFOship should appear after (countShipsWithPrimaryRole ("thargoid")), if the players kill score is 512, or higher, AND the thargoid count exceeds ??. I had originally planned for that number to be ">2", but that starts getting into Math, which is waaaaay beyond my ken.cim wrote:Judging by the comment on the next line, this should probably becountShipsWithPrimaryRole("UFOship")
instead. Otherwise that looks okay to me.
Scripters cove
Moderators: winston, another_commander
Re: Scripters cove
Re: Scripters cove
Right. That's what the comment suggested. Your first check is for "are there any UFOships" and "does the player have too few kills" - and if either of those is true, don't add any more UFOships. So the role check there needs to be for UFOships.mandoman wrote:Yeah, it was originally like that, but it doesn't make sense to me. My intention isn't that the UFOship be already in the area, but that it responds to a prompt that a certain number of thargoids are present. The UFOship should appear after (countShipsWithPrimaryRole ("thargoid")), if the players kill score is 512, or higher, AND the thargoid count exceeds ??. I had originally planned for that number to be ">2", but that starts getting into Math, which is waaaaay beyond my ken.cim wrote:Judging by the comment on the next line, this should probably becountShipsWithPrimaryRole("UFOship")
instead. Otherwise that looks okay to me.
Two lines down you've got a similar check for thargoids, which you use as described for when the player is Dangerous or better, to add UFOships equal to the number of thargoids.
Re: Scripters cove
Okay. I knew it was correct, because Capt Murphy wrote it, but I have GOT to figure out how this scripting coordinates. The wording throws me off. I'll keep plugging at it. No insult intended to Capt. Murphy, but that original script didn't produce. Maybe the AI I wrote is screwing it up, I don't know.cim wrote:Right. That's what the comment suggested. Your first check is for "are there any UFOships" and "does the player have too few kills" - and if either of those is true, don't add any more UFOships. So the role check there needs to be for UFOships.
Two lines down you've got a similar check for thargoids, which you use as described for when the player is Dangerous or better, to add UFOships equal to the number of thargoids.
- 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: Scripters cove
Whatever the AI does, the problem with your script is already identified and was clearly shown to you. I have no idea why you choose to ignore it.mandoman wrote:No insult intended to Capt. Murphy, but that original script didn't produce. Maybe the AI I wrote is screwing it up, I don't know.
I write it again:
Is there anything in here that you don't understand? If so, then please ask.Commander McLane wrote:The function is calledshipExitedWitch[b][color=#FF0000]s[/color][/b]pace
.
Small 's'.
As in every computer language, the JavaScript commands have a fixed syntax. As in every written language, orthography is important. In computer languages it is even more important than in human languages. A human can read a text with typos and still figure out what is meant. For instance, if somebody writes "thier" instead of "their", you still understand the word. The computer, however, is dumb. It does not understand what you want to say, if you get only one letter wrong.
That's why we have a documentation in the Wiki, where the exact syntax of each command is explained. Please use this documentation and stick to the exact syntax.
The documentation tells you that there is a command shipExitedWitchspace. Please click on the link and read what this command means and what it does.
You are using a command in the 10th line of your code example which for your eyes may look the same as the one I have linked to above. For your eyes it may look the same, but it isn't. It has nothing to do with a command. Because the command is spelled "shipExitedWitchspace". But you have typed "shipExitedWitchSpace". Do you notice that this is not the same? Do you notice that there is a small, but important difference? The correct syntax requires you to write "Witchspace" with a small letter "s" in the middle. But you have written "WitchSpace" with an uppercase letter "S" in the middle. Do you see the difference?
Your computer does. For your computer "Witchspace" and "WitchSpace" are two completely different things. Your computer knows "Witchspace" as part of a command, but it has never ever heard of "WitchSpace". As far as your computer is concerned, you could have written "shipExitedRdfbsodjbviuer". It's just the same as "shipExitedWitchSpace". It is not a command your computer knows. Therefore your computer simply does nothing when it reads this command.
Please, learn the correct syntax of the commands you want to use and stick to this syntax. Do not change even one single letter. If an uppercase is required, type an uppercase. If a lowercase is required, type a lowercase. And never make up your own commands. Every command that is allowed to use is written down and explained in one of the documentation pages on the wiki. Please use them. And please type the commands exactly as you see them on these documentation pages, without changing a letter.
Re: Scripters cove
Thank you for that. I always enjoy a good lecture on my inability to grasp the obvious. I'll try harder.
- Gimbal Locke
- ---- E L I T E ----
- Posts: 293
- Joined: Sun Jan 08, 2012 11:32 pm
- Location: Brussels
- Contact:
Re: Scripters cove
Hi, I want to write my first OXP for Oolite. I am new to JavaScript, but I've been programming in many languages and I'm eager to learn.
I was wondering if there is a way to detect if a player is in "rear view"? Is there any way to know that the player presses "F2"?
I tried to find it on the Methods page at the wiki (in particular at gui_screen_string), but I did not find anything. Am I looking at the right place? If it is not there, does it mean that it doesn't exist?
Totally unrelated and off-topic : There existed a "my other ship is a thargoid" rear window sticker for Archimedes Elite. Does anybody have a picture of that, because if I google it the only picture I find says something like "this site has been pwned"?
I was wondering if there is a way to detect if a player is in "rear view"? Is there any way to know that the player presses "F2"?
I tried to find it on the Methods page at the wiki (in particular at gui_screen_string), but I did not find anything. Am I looking at the right place? If it is not there, does it mean that it doesn't exist?
Totally unrelated and off-topic : There existed a "my other ship is a thargoid" rear window sticker for Archimedes Elite. Does anybody have a picture of that, because if I google it the only picture I find says something like "this site has been pwned"?
- Capt. Murphy
- Commodore
- Posts: 1127
- Joined: Fri Feb 25, 2011 8:46 am
- Location: UK South Coast.
Re: Scripters cove
Mandoman - Firstly an apology as the scripts I originally posted for you had the this.shipExitedWitchSpace / this.shipExitedWitchspace typo.......
The scripts also weren't just running under this.shipExitedWitchspace, but also under this.shipLaunchedFromStation. Because you might dock and relaunch several times that's why it included a check for existing UFOships, so extra ones aren't spawned every time you launch. If you only want to potentially spawn them on entering a new system you don't need that check. However you have kept the check but changed it to a check for thargoids....
The change you've made to this line...
is actually having the effect - do nothing if player kills is less than 512 or there are thargoids in the universe. The
The scripts also weren't just running under this.shipExitedWitchspace, but also under this.shipLaunchedFromStation. Because you might dock and relaunch several times that's why it included a check for existing UFOships, so extra ones aren't spawned every time you launch. If you only want to potentially spawn them on entering a new system you don't need that check. However you have kept the check but changed it to a check for thargoids....
The change you've made to this line...
Code: Select all
var thargoidCounter = system.countShipsWithPrimaryRole("thargoid"); // count how may thargoid ships are in the system.
if (player.score < 512 || thargoidCounter > 0){return;} // do nothing if player kills is less than 512 or there are already UFOships in the ooniverse.
is actually having the effect - do nothing if player kills is less than 512 or there are thargoids in the universe. The
return;
command effectively ends the function if the conditions are met so the rest of it is not run. Delete that line so you have the code below and it should work... edit to add - as long as your script is set up as a worldScript.Code: Select all
// Standard attributes
this.name = "UFOship.js";
this.author = "mandoman";
this.copyright = "This script is hereby placed in the public domain.";
this.version = "1.0.1";
this.description = "Script to spawn equal number of UFOships as number of Thargoid ships if player ship with score 512, or higher exits Witchspace."
// will run as player exits witchspace, and after game engine has populated the system
this.shipExitedWitchspace = function()
{
var thargoidCounter = system.countShipsWithPrimaryRole("thargoid"); // counts how many thargoids there are
if (player.score >= 512 && thargoidCounter> 0) // if more than 0 and player score is more than 512 then spawn equal number of UFOships.
{
system.addShips("UFOship", thargoidCounter, player.ship.position, 20000);
}
}
Last edited by Capt. Murphy on Mon Mar 12, 2012 5:58 am, edited 1 time in total.
Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
- Capt. Murphy
- Commodore
- Posts: 1127
- Joined: Fri Feb 25, 2011 8:46 am
- Location: UK South Coast.
Re: Scripters cove
Hi Gimbal-Locke - the page you are looking at is for the legacy scripting engine, not the much more flexible JS script engine.Gimbal Locke wrote:Hi, I want to write my first OXP for Oolite. I am new to JavaScript, but I've been programming in many languages and I'm eager to learn.
I was wondering if there is a way to detect if a player is in "rear view"? Is there any way to know that the player presses "F2"?
I tried to find it on the Methods page at the wiki (in particular at gui_screen_string), but I did not find anything. Am I looking at the right place? If it is not there, does it mean that it doesn't exist?
Totally unrelated and off-topic : There existed a "my other ship is a thargoid" rear window sticker for Archimedes Elite. Does anybody have a picture of that, because if I google it the only picture I find says something like "this site has been pwned"?
Try here as a starting point for what you want to do..... http://maikschulz.de/wiki/Oolite_JavaSc ... ionChanged
I'd also read this page http://maikschulz.de/wiki/Scripting_Ool ... JavaScript and follow all of the links to get a grip on how Oolite interacts with the JS engine. These pages have all the Oolite specific JS stuff you need to know.
The two links in my signature will take you to sites that are a general guide to JS syntax, structure and commands (not Oolite specific).
Having read all of that you may still be bemused.....the next thing is to get some scripts from an existing OXP (pick something relatively simple) and see if you can follow how they work referring to the references linked above as necessary.
Last edited by Capt. Murphy on Mon Mar 12, 2012 5:51 am, edited 2 times in total.
Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
- 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: Scripters cove
Gimbal Locke wrote:I was wondering if there is a way to detect if a player is in "rear view"? Is there any way to know that the player presses "F2"?
Code: Select all
this.viewDirectionChanged = function(viewString)
{
if (viewString == "VIEW_AFT")
{
// Your code here
}
}
- Gimbal Locke
- ---- E L I T E ----
- Posts: 293
- Joined: Sun Jan 08, 2012 11:32 pm
- Location: Brussels
- Contact:
Re: Scripters cove
Thanks Capt. Murphy & Cmdr. Okti, I'll try that.
- 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: Scripters cove
Generally, JavaScript is event driven. This means that all scripts act on a pre-defined set of events. Scripting means to attach a script to an event. Whenever this event takes place, your script will be executed.Gimbal Locke wrote:Hi, I want to write my first OXP for Oolite. I am new to JavaScript, but I've been programming in many languages and I'm eager to learn.
I was wondering if there is a way to detect if a player is in "rear view"? Is there any way to know that the player presses "F2"?
All events are listed on the event handler pages in the Wiki. There are two distinct sets of events, one for world scripts and one for ship scripts. Ship scripts translate to "things that can happen to NPC ships", and world scripts roughly translate to "things that can happen to the player and/or their ship".
- Gimbal Locke
- ---- E L I T E ----
- Posts: 293
- Joined: Sun Jan 08, 2012 11:32 pm
- Location: Brussels
- Contact:
Re: Scripters cove
Thanks for the information Cmdr. McLane.
With the hints from you, Okti & Capt. Murphy I think I'll get my rear window stickers OXP working soon enough.
With the hints from you, Okti & Capt. Murphy I think I'll get my rear window stickers OXP working soon enough.
Re: Scripters cove
Thanks Capt. Murphy, I'll give that a try.
- Capt. Murphy
- Commodore
- Posts: 1127
- Joined: Fri Feb 25, 2011 8:46 am
- Location: UK South Coast.
Re: Scripters cove
I don't think this can be done, but thought I'd seen something somewhere (maybe I was dreaming ), but is it possible to disable/change a customsounds.plist entry on a temporary basis via script? Specifically I'd like to be able to change the
"[witchdrive-malfunction]" = "bgs-c_ws_malf.ogg";
in BGS-M, to a dummy sound file, and then change it back again after an OXP has done some stuff. Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
Re: Scripters cove
Nope, not possible.Capt. Murphy wrote:I don't think this can be done, but thought I'd seen something somewhere (maybe I was dreaming ), but is it possible to disable/change a customsounds.plist entry on a temporary basis via script?