Unfortunately not, you can check for what lasers are installed from script but not change them. Your only choice is 'like_ship'ing, and it sounds like your setting yourself a real PITA task. If you were just to include the core ships it is worth doing two sets (one for Griff's and one for the standard model names), with a very very low probablity attached to the role for the standard model names. If you do that players with Griff's installed will see Griff's ships, players without, the standard model or the retextured version if say Smiv's or Neolite's are installed.cim wrote:Is there a way to set a ship's lasers from script?................................................................but I thought I'd better ask before I started massively expanding shipdata.plist.
Scripters cove
Moderators: winston, another_commander
- Capt. Murphy
- Commodore
- Posts: 1127
- Joined: Fri Feb 25, 2011 8:46 am
- Location: UK South Coast.
Re: Scripters cove
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
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Scripters cove
Yes, I think we both missed something: that you were replying to something I posted months ago. As an answer to the literal request I made back then, you are correct. I replied from the context of my current concerns. Please accept my apology if my reply seemed ungrateful, dismissive or just plain odd.Capt. Murphy wrote:I could well be missing something because I have not looked into this at all closely, but...
Re: Scripters cove
To avoid counting beyond the 2048 systems in Galaxy Charts 1-8, you could also add this simple check:
Code: Select all
if(galaxyNumber >7 || galaxyNumber <0) {
// DIRE warnings about being off-the-charts.
player.commsMessage("Outside known space! No matching Star Charts found!",6);
}
- Capt. Murphy
- Commodore
- Posts: 1127
- Joined: Fri Feb 25, 2011 8:46 am
- Location: UK South Coast.
Re: Scripters cove
No worries - what I'm actually doing is an achievements/mile-stones module for explorers' club, and I don't want to spam alternative Ooniverse users with nonsense mile-stones (Oresrati, Great Rift etc.) - they get a 'Wow! Far-out! You are exploring a parallel Ooniverse......Boldly go......" message (or something along those lines ) instead.Wildeblood wrote:Yes, I think we both missed something: that you were replying to something I posted months ago. As an answer to the literal request I made back then, you are correct. I replied from the context of my current concerns. Please accept my apology if my reply seemed ungrateful, dismissive or just plain odd.Capt. Murphy wrote:I could well be missing something because I have not looked into this at all closely, but...
Switeck -I'll add that to my Switch as a default if galaxyNumber is beyond 7, and as a check at start-up.
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
With apologies if this got answered and I missed it, but couldn't see any reply. It depends what you mean by target - if you mean the missile/ident lock, then that can be set simply by scripting (player.ship.target is read/write) all you need to do is check when the player targets something (there are worldscript events for that) and if it's the appropriate entity (the satellite asteroids) then set the target to the main entity.Wildeblood wrote:I want to create a group of asteroids which behave as one object when the player is trying to target them with the ident computer. One will be the core, and there will be several others around it. If the player targets one of the outlying ones, target should be immediately re-directed to the core one, so the player can't get a target lock on the outliers. Suggestions, please?
That does of course require that they are both on the scanner together, as if you try and set the target to something off-scanner then you'll of course lose lock immediately. If you want a guide to this kind of thing, look at my target autolock OXP.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
Re: Scripters cove
Thought so - thanks for confirming. It's not that bad, as it goes - I can do a bit of preprocessing to generate most of the shipdata.plist automatically since the changes from the base ship spec will be minimal - so all I really need to do is keep a list of hunters.Capt. Murphy wrote:Unfortunately not, you can check for what lasers are installed from script but not change them. Your only choice is 'like_ship'ing, and it sounds like your setting yourself a real PITA task.
- Capt. Murphy
- Commodore
- Posts: 1127
- Joined: Fri Feb 25, 2011 8:46 am
- Location: UK South Coast.
Re: Scripters cove
Well, you were quite right to express concerns about checking position of systemID '0'. Some testing with galaxy_seeds close to the original reveals that it can be in the same place very often. However same testing shows that systemID 255 is in a wildly different position. I've edited the code snippet to reflect the better test.Wildeblood wrote:Yes, I think we both missed something: that you were replying to something I posted months ago. As an answer to the literal request I made back then, you are correct. I replied from the context of my current concerns. Please accept my apology if my reply seemed ungrateful, dismissive or just plain odd.Capt. Murphy wrote:I could well be missing something because I have not looked into this at all closely, but...
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
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Scripters cove
It seems to me you're just making work for yourself. If you're just after a coding challenge, I have a long list of OXP ideas that are beyond my ability to implement yet (all brilliant ideas, obviously). I could send you a list and you could just pick out any that appeal to you.Capt. Murphy wrote:Well, you were quite right to express concerns about checking position of systemID '0'. Some testing with galaxy_seeds close to the original reveals that it can be in the same place very often. However same testing shows that systemID 255 is in a wildly different position. I've edited the code snippet to reflect the better test.
Put my mind at ease by telling me exactly why you feel the need to verify you're in the traditional ooniverse (hereinafter referred to as 'elite-0')? In my view, you never need such a test for any mission intended for elite-0, because it's not something the player can accidentally exit from. A player knows if they're using an alternative ooniverse, and if they are, they know it won't start at Lave and end at Oresrati. (By way of experiment last night, I tossed in some 'random' numbers, hopped around the eight to see if they looked interesting, and ended up on planet "User". Spooky. True.) OTOH, you do need such a test for any mission intended for any other ooniverse, because sure enough someone - not understanding what it is - will expect it to work in elite-0 and complain when it doesn't.
Re: Scripters cove
While on the subject of alternate ooniverses, a shorter version of Capt. Murphy's test could be:
Code: Select all
this.alternateOoniverse = function(){
var testCoords=[[4.8,40.6,0],[9.6,30.4,0],[31.2,42.4,0],[62.4,34.2,0],[51.2,28.8,0],[86.4,27.6,0],[70.8,4.6,0],[90.8,39.8,0]];
if (galaxyNumber < 0 || galaxyNumber > 7) return true;
return (System.infoForSystem(galaxyNumber, 255).coordinates.distanceTo(testCoords[galaxyNumber]) > 0.00001);
}
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
- Capt. Murphy
- Commodore
- Posts: 1127
- Joined: Fri Feb 25, 2011 8:46 am
- Location: UK South Coast.
Re: Scripters cove
That's quite a lot shorter - thanks Kaks.
Wildeblood - not particularly after coding challenges but if there is anything you'd like me to have a look at either to advise or to consider putting some script together then shout. I won't promise anything as time is often not on my side, but always happy to try and help.
I've done this for a particular reason for the next version of Explorers' Club. I probably wouldn't have done it except for the knowledge that at least one likely user (who could that be ) does like to play in alternative Ooniverses. Having found a (with Kak's optimisation) relatively small function that should reliably tell an OXP if it's in the standard Ooniverse or not, I thought it worth sharing as some other scripters may feel the need to do the same thing.
Wildeblood - not particularly after coding challenges but if there is anything you'd like me to have a look at either to advise or to consider putting some script together then shout. I won't promise anything as time is often not on my side, but always happy to try and help.
I've done this for a particular reason for the next version of Explorers' Club. I probably wouldn't have done it except for the knowledge that at least one likely user (who could that be ) does like to play in alternative Ooniverses. Having found a (with Kak's optimisation) relatively small function that should reliably tell an OXP if it's in the standard Ooniverse or not, I thought it worth sharing as some other scripters may feel the need to do the same thing.
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
Is there a better way than this to determine if one array is a subset or equal to another array (ordering doesn't matter)?
I also tried an esoteric combination of .filter with an .indexOf based function in the callback but suffered a failure to get the syntax right or get my head round why it was failing.
This works though.
I also tried an esoteric combination of .filter with an .indexOf based function in the callback but suffered a failure to get the syntax right or get my head round why it was failing.
This works though.
this.isArray1_subsetOfArray2 = function (array1,array2)
{
if (!array1 || !array2)
{return false;}
if (array1.length > array2.length)
{return false;}
var tempArray = new Array;
var counter = 0;
for (counter = 0; counter < array1.length; counter++)
{
if (array2.indexOf(array1[counter]) !== -1)
{tempArray.push(array1[counter]);}
}
if (tempArray.length === array1.length)
{return true;}
else {return false;}
}
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
This should work:
note: I tend to be 'a bit' paranoid about what parameters a function's been fed, but I'm not too fussed about my logical expression evaluations ("I remember the days === woud give you a syntax error")!
Code: Select all
this.isArray1_subsetOfArray2 = function (array1,array2)
{
if (!(typeof array1 == 'object' && array1 instanceof Array) || !(typeof array2 == 'object' && array2 instanceof Array) || array1.length > array2.length)
{return false;}
return array1.length == array2.filter(function(value){return this.indexOf(value) >= 0},array1).length;
}
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
Re: Scripters cove
If you only want to see if elements in arr2 are in arr1 you could use .arrDiff(arr1,arr2) in CCL (order independent).
For a real subset order matters though.
For a real subset order matters though.
- RyanHoots
- ---- E L I T E ----
- Posts: 958
- Joined: Fri May 20, 2011 8:10 pm
- Location: Nowhere
- Contact:
Re: Scripters cove
I'm working on learning JavaScript, so I'm modifying some of the scripts that come with the game. I'm working on a Borg script, just for fun, but I need help. Here's what I have:
The problem is that with the above script, the Borg ship will tell you that you will be assimilated after the Borg ship dies. What do I replace
Code: Select all
this.shipDied = function ()
{
this.ship.commsMessage(expandDescription("We are Borg. You will be assimilated. Resistance is futile."));
};
this.shipDied
with so that the borg ship sends the comm message as soon as the player encounters it?Re: Scripters cove
What about:
Every time the borg ship targets anything, or every time they get shot with a laser they'll say the same sentence.
The command expandDescription wasn't doing anything useful - there was nothing to expand inside your sentence. However, it's a very useful command if you want them to be slightly less boring!
You'll need some alternative phrases inside a descriptions.plist first. If you have:
then every time you do:
you'll get a different random borg phrase, picked from the ones you wrote in the descriptions.plist above.
Code: Select all
this.shipTargetAcquired = this.shipBeingAttacked = function ()
{
this.ship.commsMessage("We are Borg. You will be assimilated. Resistance is futile.");
};
The command expandDescription wasn't doing anything useful - there was nothing to expand inside your sentence. However, it's a very useful command if you want them to be slightly less boring!
You'll need some alternative phrases inside a descriptions.plist first. If you have:
Code: Select all
RH-borg-banter = ("We are Borg.", "Resistance is futile.", "You will be assimilated.", "We'll add your distinctivness to our own", "Resistance is futile, you will be assimilated.", "We are Borg, resistance is futile.");
Code: Select all
this.ship.commsMessage(expandDescription("[RH-borg-banter]"));
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)