Guys,
Having problems with roles. A bit of background trying to script some actions for a ship building station and would like to recognise player ships that correspond to the ship types that are built at the station, so that differing actions can be provided. Whilst I can do this by using constructs like "if (player.ship.name === "xxx" !! player.ship.name === "yyy") I thought it would be easier on maintenance if I could assign a special role and use " if (player.ship.hasrole("rrr") ". However when I try this it fails, It would appear that the only role a player ship has is 'player', is this correct? NPC ships have the full list of roles when I list them in the console, but the player only ever shows 1 role, 'player'. The Wiki does not say anything about this restriction for the player ship, well in those pages I have read anyway.
Ironfist
Problem with roles
Moderators: winston, another_commander
Problem with roles
64bit Mint 10 and Win 8 64bit on E8400 at 3.6GHz - ATI HD5750 graphics.
Concentration is the ability to think of absolutely nothing when it is absolutely necessary.
Concentration is the ability to think of absolutely nothing when it is absolutely necessary.
Re: Problem with roles
Unfortunately it's done on purpose. The reason behind it is that NPCs tend to develop erratic behaviours if we add secondary roles to the player (specifically police & thargoid, but maybe pirate as well).
However, there is one thing you could do. Each player ship can be assigned a unique script in shipdata.plist, so you can create a ship.script containing at least the following
you can then always check for
'Course, since it's not a standard property, it's always best to give it a fairly unique name, so no other oxps are likely to use the same property by accident...
However, there is one thing you could do. Each player ship can be assigned a unique script in shipdata.plist, so you can create a ship.script containing at least the following
Code: Select all
this.name = 'testing';
this.author = 'Ironfist';
....
this.ironfistBuildStation = 'YAY';
Code: Select all
if(player.ship.script.ironfistBuildStation == 'YAY'){
...
}
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
Re: Problem with roles
Kaks,
Thanks for the suggestion I will give it a go and see whether if it offers any advantages over what I am currently doing, which is to have a piece of equipment called "Manufacturers Tag" which is standard equipment for ships produced by Oodulldoff Inc. Testing this allows the station scripts to react differently for differing ships and currently does not require writing a ship script for each type of ship. But your option may be better since I assume the equipment approach could fail if it was destroyed in combat.
Ironfist
Thanks for the suggestion I will give it a go and see whether if it offers any advantages over what I am currently doing, which is to have a piece of equipment called "Manufacturers Tag" which is standard equipment for ships produced by Oodulldoff Inc. Testing this allows the station scripts to react differently for differing ships and currently does not require writing a ship script for each type of ship. But your option may be better since I assume the equipment approach could fail if it was destroyed in combat.
Ironfist
64bit Mint 10 and Win 8 64bit on E8400 at 3.6GHz - ATI HD5750 graphics.
Concentration is the ability to think of absolutely nothing when it is absolutely necessary.
Concentration is the ability to think of absolutely nothing when it is absolutely necessary.