Page 8 of 46
Posted: Sun Aug 23, 2009 7:07 pm
by JensAyton
That is pretty odd… I would have expected an anarchy symbol.
No, really.
Posted: Sun Aug 23, 2009 7:38 pm
by Eric Walch
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
I am not sure but do you mean something like this:
this.array=system.shipsWithRole("myRole")
You can also give a range to limit the search range. In contrast to shipsWithPrimaryRole() this one evaluates all roles.
Posted: Sun Aug 23, 2009 8:33 pm
by Ramirez
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:
Code: Select all
Ship "Feudal Knight (Gelaed)" ID: 212 position (xxx,yyy,zzz,) ScanClass: CLASS_NEUTRAL status: STATUS_IN_FLIGHT
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:
Code: Select all
this.logDetails = function()
{
var list = this.ship.roles
var details = list.indexOf("testrole")
this.ship.commsMessage(details)}
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:
Code: Select all
this.logDetails = function()
{
var list = this.ship.roles
var list2 = list[1]
var details = list2.indexOf("test")
this.ship.commsMessage(list2)}
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:
Code: Select all
this.logDetails = function()
{
var list = system.allShips
var list2 = list[1]
var details = list2.indexOf("Coriolis")
this.ship.commsMessage(details)}
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.
Posted: Sun Aug 23, 2009 9:04 pm
by Svengali
indexOf returns only the position where the entry is found in the array. If not found it returns -1. What you're looking for is more .match('test').
Posted: Sun Aug 23, 2009 9:15 pm
by JensAyton
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)}
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.
Posted: Mon Aug 24, 2009 1:55 pm
by Kaks
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...
Code: Select all
this.logDetails = function()
{
var list = system.allShips
var list2 = list[1].roles
var details = list2.indexOf("Coriolis")
this.ship.commsMessage(details)}
But then again, I'm not really sure about what you're looking for!
Posted: Mon Aug 24, 2009 5:34 pm
by JensAyton
Kaks wrote:I thought ship.roles was actually just a string containing the names of all possible roles.
It’s
documented, you know. And the documentation happens to be right:
Code: Select all
case kShip_roles:
result = [[entity roleSet] sortedRoles];
break;
-[OORoleSet sortedRoles] returns an array of strings.
Posted: Mon Aug 24, 2009 7:14 pm
by Ramirez
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:
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)}
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.
Posted: Mon Aug 24, 2009 8:10 pm
by Kaks
Glad to be of assistance!
...and I'll check the wiki more often too!
Posted: Tue Aug 25, 2009 8:03 pm
by Chaky
(Feudal states WIP v0.2)
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.
The problem is with lines 450-453. Simple switch from this
Code: Select all
</dict>
<key>weapon_position_forward</key>
<string>0.0 -0.18 27.06</string>
to this
Code: Select all
<key>weapon_position_forward</key>
<string>0.0 -0.18 27.06</string>
</dict>
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
Code: Select all
[script.unpermittedMethod]: ***** SCRIPT ERROR: in trident_down, method 'clearMissionDescription:' not allowed.
Posted: Wed Aug 26, 2009 8:26 pm
by Ramirez
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?
Posted: Wed Aug 26, 2009 8:34 pm
by Svengali
Wow, pretty stuff ...eem astounding, Sire!
Posted: Wed Aug 26, 2009 8:43 pm
by Disembodied
Ramirez wrote:Any other things people can think of that might be the subject of a sneaky recon mission?
A partially-completed space station or megaship hull ... maybe a stripped-out dredger being refitted as a Behemoth?
Posted: Wed Aug 26, 2009 8:45 pm
by Cmd. Cheyd
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....
Posted: Wed Aug 26, 2009 9:40 pm
by DaddyHoggy
Disembodied wrote:Ramirez wrote:Any other things people can think of that might be the subject of a sneaky recon mission?
A partially-completed space station <snip>
Just where do you get your ideas from?