Java script question - help, please!
Moderators: winston, another_commander
- Lestradae
- ---- E L I T E ----
- Posts: 3095
- Joined: Tue Apr 17, 2007 10:30 pm
- Location: Vienna, Austria
Java script question - help, please!
I have hacked/created two equipment items with which's java scripts I am partially unhappy because I want them to be sellable and this is not working as intended.
The first .js should do the following:
If the player ship has "EQ_COMBAT_COMP" installed then "player.ship.reticleTargetSensitive = true" should be the case.
If the player ship has the above not installed (because it was never bought, is damaged or was re-sold), then "player.ship.reticleTargetSensitive = false" should be the case.
The second .js should do:
If the player ship has "EQ_GALACTIC_HYPERDRIVE_2" installed, then ...
"this.defaultGalacticHyperspaceBehaviour = player.ship.galacticHyperspaceBehaviour
player.ship.galacticHyperspaceBehaviour = "BEHAVIOUR_ALL_SYSTEMS_REACHABLE"
... should be the case.
If the player ship doesn't have this installed (same as above, because it was never bought, is damaged or was re-sold), then ...
"this.defaultGalacticHyperspaceBehaviour = player.ship.galacticHyperspaceBehaviour
player.ship.galacticHyperspaceBehaviour = "BEHAVIOUR_STANDARD"
... should be the case.
Could someone help me with this or even provide simple java scripts that do this for me?
Would be very grateful for any help
Cheers
L
The event functions you want are this.playerBoughtEquipment = function(equipment) triggered when the player buys a piece of equipment (identified in the parameter equipment, this.equipmentDamaged = function(equipment) and this.equipmentDestroyed = function(equipment) for when it gets damaged or destroyed/sold respectively.
By using these functions you can set or change the parameters (very much along the lines that the original equipment items do).
If you're still stuck let me know and I'll script it for you, just not now as I'm sat at Geneva Airport waiting for a plane...
By using these functions you can set or change the parameters (very much along the lines that the original equipment items do).
If you're still stuck let me know and I'll script it for you, just not now as I'm sat at Geneva Airport waiting for a plane...
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Lestradae
- ---- E L I T E ----
- Posts: 3095
- Joined: Tue Apr 17, 2007 10:30 pm
- Location: Vienna, Austria
..
Then this here should work?!?
... and this here, too:
Hope for answers, I am absolutely noob again with the .js
Yes? No? Got something wrong/missing?
Cheers
L
Code: Select all
this.playerBoughtEquipment = function(equipment)
{
if(equipment == "EQ_COMBAT_COMP")
{
player.ship.reticleTargetSensitive = true
}
}
this.equipmentDamaged = this.equipmentDestroyed = function(equipment)
{
if(equipment == "EQ_COMBAT_COMP")
{
player.ship.reticleTargetSensitive = false
}
}
Code: Select all
this.playerBoughtEquipment = function(equipment)
{
if(equipment == "EQ_GALACTIC_HYPERDRIVE_2")
{
this.defaultGalacticHyperspaceBehaviour = player.ship.galacticHyperspaceBehaviour
player.ship.galacticHyperspaceBehaviour = "BEHAVIOUR_ALL_SYSTEMS_REACHABLE"
}
}
this.equipmentDamaged = this.equipmentDestroyed = function(equipment)
{
if(equipment == "EQ_GALACTIC_HYPERDRIVE_2")
{
this.defaultGalacticHyperspaceBehaviour = player.ship.galacticHyperspaceBehaviour
player.ship.galacticHyperspaceBehaviour = "BEHAVIOUR_STANDARD"
}
}
Yes? No? Got something wrong/missing?
Cheers
L
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
It probably also needs a:
You must also check on reset as the property reticleTargetSensitive will not be stored in the save file.
But why invent the wheel by creating existing equipment?
Code: Select all
this.reset = function()
{
if(player.ship.hasEquipment ( "EQ_COMBAT_COMP"))
{
player.ship.reticleTargetSensitive = true
}
}
But why invent the wheel by creating existing equipment?
UPS-Courier & DeepSpacePirates & others at the box and some older versions