The Feudal States
Moderators: winston, another_commander
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
I am not sure but do you mean something like this: this.array=system.shipsWithRole("myRole")Ramirez wrote:Now, using the ship's own ship script, with an appropriate trigger I can record some of its details as a mission variable. The bit I particularly need is the [house]-knight part. As the ship was created using a primary role of 'feudal-knight' I need to use the this.ship.roles function to pick up the other role. I can select the bit I need using code like this
You can also give a range to limit the search range. In contrast to shipsWithPrimaryRole() this one evaluates all roles.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
I've been trying to use system.shipsWithRole but I'm having trouble making use of the results. To explain, I've set up a buoy that scans for ships in the area, and I've been testing it by having it send a comms message to me containing the results of the search. I can get the buoy to do system.shipsWithRole and I get an array that contains the full entity details of relevant ships, e.g:
What I then want to do is for each element in the array, search for certain strings, e.g. a certain feudal house or ship type.
I looked around for help on javascript functions and came across indexOf, which looked as if it would do the job. However, while I can use it to search the results of this.ship.roles, it doesn't seem to work with the results of system.allShips or system.shipWithRole, even when looking at just one element in the array.
For example, the tournament buoy has roles of 'feudal-buoy' and 'testrole'. I put this in its ship script:
This worked, correctly finding testrole as the second element in the array. As I also wanted to be able to do partial matches within arrays I came up with this bit of code that seemed to work:
This was able to pick out any text contained in the string 'testrole'. Given that both this.ship.role and system.shipsWithRole both return results as arrays, I thought I could use the same technique, e.g:
When I try this though, I get an error saying 'list2.indexOf' isn't a function. If I remove the list2 = list[1] step, the indexOf function runs but returns a negative result as it can't do a partial match against the entity data.
A possible way to get around this is if the buoy could somehow run the ship.roles on the entities it identifies as having a certain primary role, as it seems I can search the results of ship.roles with no trouble.
Code: Select all
Ship "Feudal Knight (Gelaed)" ID: 212 position (xxx,yyy,zzz,) ScanClass: CLASS_NEUTRAL status: STATUS_IN_FLIGHT
I looked around for help on javascript functions and came across indexOf, which looked as if it would do the job. However, while I can use it to search the results of this.ship.roles, it doesn't seem to work with the results of system.allShips or system.shipWithRole, even when looking at just one element in the array.
For example, the tournament buoy has roles of 'feudal-buoy' and 'testrole'. I put this in its ship script:
Code: Select all
this.logDetails = function()
{
var list = this.ship.roles
var details = list.indexOf("testrole")
this.ship.commsMessage(details)}
Code: Select all
this.logDetails = function()
{
var list = this.ship.roles
var list2 = list[1]
var details = list2.indexOf("test")
this.ship.commsMessage(list2)}
Code: Select all
this.logDetails = function()
{
var list = system.allShips
var list2 = list[1]
var details = list2.indexOf("Coriolis")
this.ship.commsMessage(details)}
A possible way to get around this is if the buoy could somehow run the ship.roles on the entities it identifies as having a certain primary role, as it seems I can search the results of ship.roles with no trouble.
Download Resistance Commander plus many other exciting OXPs HERE
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Since roles is an array of strings, list2 is a string rather than an array. indexOf is defined for strings, but it could be that list2 is undefined because list[1] is the second element of the list – list[0] is the first.Ramirez wrote:Code: Select all
this.logDetails = function() { var list = this.ship.roles var list2 = list[1] var details = list2.indexOf("test") this.ship.commsMessage(list2)}
E-mail: [email protected]
One thing I'd do is to find out exactly what list2 is ...
If in doubt, just add something like
just after the line where you define list2.
In normal js usage, string.indexOf(substring) should return the (first matching) substring's position within string, or -1 if not found.
I thought ship.roles was actually just a string containing the names of all possible roles.
If that's the case, I would expect the first list2 to just contain the second character of the ship.roles string.
edit:
assuming that the second entry of the allShips array actually contains the station, I would expect this to produce what you're actually looking for...
But then again, I'm not really sure about what you're looking for!
If in doubt, just add something like
Code: Select all
log('list2 = [['+list2+']]');
In normal js usage, string.indexOf(substring) should return the (first matching) substring's position within string, or -1 if not found.
I thought ship.roles was actually just a string containing the names of all possible roles.
If that's the case, I would expect the first list2 to just contain the second character of the ship.roles string.
edit:
assuming that the second entry of the allShips array actually contains the station, I would expect this to produce what you're actually looking for...
Code: Select all
this.logDetails = function()
{
var list = system.allShips
var list2 = list[1].roles
var details = list2.indexOf("Coriolis")
this.ship.commsMessage(details)}
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
It’s documented, you know. And the documentation happens to be right:Kaks wrote:I thought ship.roles was actually just a string containing the names of all possible roles.
Code: Select all
case kShip_roles:
result = [[entity roleSet] sortedRoles];
break;
E-mail: [email protected]
Thanks Kaks, I think you've solved my problem - the key was the getting the list of roles after the system.allShips function.
I've set up the system so 5 feudal knights are created at random. Then I get the buoy to run something like this:
I'll get 5 results that indicate whether each of the ships meets the criteria. Having established the house I can then generate names and ranks for the pilots. Now I can get the role information, rather than all that entity data, I don't need to worry so much about partial matches.
I've set up the system so 5 feudal knights are created at random. Then I get the buoy to run something like this:
Code: Select all
var list = system.shipsWithRole("feudal-knight")
for (var i=0; i<list.length; i++)
{
var list2 = list[i].roles
var details = list2.indexOf("Aronar-knight")
this.ship.commsMessage(details)}
Download Resistance Commander plus many other exciting OXPs HERE
Glad to be of assistance!
...and I'll check the wiki more often too!
...and I'll check the wiki more often too!
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
(Feudal states WIP v0.2)
There's a typo in shipdata.plist that logs as
The problem is with lines 450-453. Simple switch from this
to this
does the trick.
.. had to use process of elimination to deduct from 100 or so oxps...
P.S.
Any plans of updating Trident down for 1.73? Makes a lot of
There's a typo in shipdata.plist that logs as
Code: Select all
[shipData.load.badEntry]: ***** ERROR: the shipdata.plist entry "weapon_position_forward" is not a dictionary.
Code: Select all
</dict>
<key>weapon_position_forward</key>
<string>0.0 -0.18 27.06</string>
Code: Select all
<key>weapon_position_forward</key>
<string>0.0 -0.18 27.06</string>
</dict>
.. had to use process of elimination to deduct from 100 or so oxps...
P.S.
Any plans of updating Trident down for 1.73? Makes a lot of
Code: Select all
[script.unpermittedMethod]: ***** SCRIPT ERROR: in trident_down, method 'clearMissionDescription:' not allowed.
I might revisit Trident Down sometime - if I do I'l be aiming to rewrite it using javascript. Also I'd want to wait until 1.73 is finalised and released.
For Feudal States I've rewritten the shipdata to cope with shaders so this error should be resolved in v0.3, which I hope to upload soon.
I've been doing some more tweaks on the decals as well as having one or two fights with some nobles, so here are some more screenshots.
On the left is the shield model I had ages ago, and consists of a specific model that uses a 512x512 texture for the coat of arms. Note this shot was was taken in Drydock rather than in-game. On the right is a shield of the same size (around 100m high) that uses a generic model with the coat of arms painted on using the same decal as used for the ships. It's slightly less detailed because the decal texture is currently only about 250px high. As with the ships, it means only needing to have one .dat file and and using the shipdata/shader combo to paint on the details.
Here a couple of ships in action, a Freiherr-class Jäger of the House of Gelaed, and a Prinz-class Zerstörer from the house of Tibecea:
And finally, I was thinking about the photo-recon mission idea and thought I could do with some new and unusual targets for it. How about a massive space defence cannon (borrowing heavily from the prevous comms satellite in Trident Down)?
Any other things people can think of that might be the subject of a sneaky recon mission?
For Feudal States I've rewritten the shipdata to cope with shaders so this error should be resolved in v0.3, which I hope to upload soon.
I've been doing some more tweaks on the decals as well as having one or two fights with some nobles, so here are some more screenshots.
On the left is the shield model I had ages ago, and consists of a specific model that uses a 512x512 texture for the coat of arms. Note this shot was was taken in Drydock rather than in-game. On the right is a shield of the same size (around 100m high) that uses a generic model with the coat of arms painted on using the same decal as used for the ships. It's slightly less detailed because the decal texture is currently only about 250px high. As with the ships, it means only needing to have one .dat file and and using the shipdata/shader combo to paint on the details.
Here a couple of ships in action, a Freiherr-class Jäger of the House of Gelaed, and a Prinz-class Zerstörer from the house of Tibecea:
And finally, I was thinking about the photo-recon mission idea and thought I could do with some new and unusual targets for it. How about a massive space defence cannon (borrowing heavily from the prevous comms satellite in Trident Down)?
Any other things people can think of that might be the subject of a sneaky recon mission?
Download Resistance Commander plus many other exciting OXPs HERE
- Disembodied
- Jedi Spam Assassin
- Posts: 6885
- Joined: Thu Jul 12, 2007 10:54 pm
- Location: Carter's Snort
- Cmd. Cheyd
- ---- E L I T E ----
- Posts: 934
- Joined: Tue Dec 16, 2008 2:52 pm
- Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...
Raw materials (asteroid) Refining Facility
Weapons Manufacturing Facility
Follow the "Insert Court Official Here" who is believed to be secretly in league with another house
Pictures of the "Princess" who is secretly meeting with another House's Prince in a secret tryst. BLACKMAIL!!!!
That's a few quick ideas that just jumped into my head....
Weapons Manufacturing Facility
Follow the "Insert Court Official Here" who is believed to be secretly in league with another house
Pictures of the "Princess" who is secretly meeting with another House's Prince in a secret tryst. BLACKMAIL!!!!
That's a few quick ideas that just jumped into my head....
- DaddyHoggy
- Intergalactic Spam Assassin
- Posts: 8515
- Joined: Tue Dec 05, 2006 9:43 pm
- Location: Newbury, UK
- Contact:
Just where do you get your ideas from?Disembodied wrote:A partially-completed space station <snip>Ramirez wrote:Any other things people can think of that might be the subject of a sneaky recon mission?
Oolite Life is now revealed hereSelezen wrote:Apparently I was having a DaddyHoggy moment.