If you want to do it for your own mission screens, then:
Code: Select all
mission.runScreen(
{
// other parameters...
exitScreen: guiScreen
}, /* callback goes here */);
Moderators: winston, another_commander
Code: Select all
mission.runScreen(
{
// other parameters...
exitScreen: guiScreen
}, /* callback goes here */);
cim wrote:Most of the time in practice I think that would either be the interfaces screen, or something invalid (for mission screens called when docking), and I'm not sure how well it would work for a chain of mission screens.
Fixed - thank you.Neelix wrote:(including Ship Registration)
Code: Select all
this.isLaserOnline = function()
{
if (this.weaponsOnline == true)
{
player.consoleMessage("Debug MSG:Weapons Online");
//this.laserBayDoorOpen();
}
if (this.weaponsOnline == false)
{
player.consoleMessage("Debug MSG:Weapons offline");
//this.laserBayDoorClosed();
}
}
Code: Select all
this.$checkNPCalert = function()
{
if (this.ship.hasHostileTarget == false)
{
this.$laserDoorClosed();
}
if (this.ship.hasHostileTarget == true)
{
this.$laserDoorOpen();
this.ship.commsMessage("DEBUG ATTACKING");
}
}
Code: Select all
this.startUp = function()
{
this.$alertchecker = new Timer(this, this.$checkNPCalert,6, 15);
}
This will be the problem - the actual check code looks fine.dertien wrote:(I am running this periodiacally with a timer that is initialized at startup)Code: Select all
this.startUp = function() { this.$alertchecker = new Timer(this, this.$checkNPCalert,6, 15); }
startUp
event in a ship script: startUp
happens exactly once, in worldscripts only, when a commander (new or existing) is loaded from disk. Use shipSpawned
for initialisation code in ship scripts.Code: Select all
OPTION A
Check damage status of purchased equipment with timer
Check if subentity is intact && if it is at position x
if intact and at position x (all is well)
if subent has been destroyed - remove relevant purchased equipment set equipment status to "EQUIPMENT_DAMAGED"
Restore all subentitites & check status of all equipment
Depending on EQUIPMENT_OK or EQUIPMENT_DAMAGED hide subents in the model
Code: Select all
OPTION B
Step A: Check which EQ_equipment is EQ_damaged or EQ_OK using a switch case which gets initialized on launch from the station
if equipment is ok reset subent to position, if equipment is damaged remove the dummy.
Step B:
this.equipmentDamaged = function(eqKey)
{
if (eqKey == "EQ_ADVANCED_NAVIGATIONAL_ARRAY")
{
/* Two subentities exist on the ship, the real subentity equipment and its dummy.
The dummy is located inside the ship model, the other is placed on the hull*/
/* if both subentities exist, there is no problem and the equipment should be repaired.
This is in case the EQ_equipment is destroyed without the subentity being destroyed by npc*/
if (this._findSubEntity("HPC_ana") != null && this._findSubEntity("HPC_ana_dummy") != null)
{
// both are intact and equipment should not be destroyed so repair it
this.ship.setEquipmentStatus("EQ_ADVANCED_NAVIGATIONAL_ARRAY","EQUIPMENT_OK");
}
/* However, if the subentity equipment does not exist on the ship and the dummy isn't
then the subentity equipment is destroyed*/
if (this._findSubEntity("HPC_ana") == null && this._findSubEntity("HPC_ana_dummy") != null)
{
// then the ana is destroyed thus do the following:
this.ship.setEquipmentStatus("EQ_ADVANCED_NAVIGATIONAL_ARRAY","EQUIPMENT_DAMAGED"); // damage EQ_equipment
this.ship.restoreSubEntities() // restore subentities and put them back on the model as not to trigger the overhaul when docked
var $ana = this._findSubEntity("HPC_ana"); // find the subent ana and put it inside the model
if ($ana)
{
$ana.position = [0,0,0];
}
var $ana_dmy = this._findSubEntity("HPC_ana_dmy"); // destroy the dummy ana
if ($ana_dmy)
{
HPC_ana_dmy.remove(); // remove the ana dummy in order to not trigger both if's() above and use timer to loop through A and B
}
}
}
else if (eqKey == "EQ_ECM")
{
// and so on
}
// and so on
}
Step C:
During docking tunnel, stop/delete timers and restore all subentites to have no overhaul or destroy all dummies again according to rule A before docking to have an overhaul.
restoreSubEntities
, as well as returning all subentities to the ship, also returns all subentities back to their original position, orientation, energy values, etc. So if you have anything like the landing gear which can move independently, you'll also need to record what state it's in. The "energy values" one is particularly important - subentity A gets destroyed, so you damage equipment A, restore subentities, and move subentity A to the hidden position ... and subEntity B which was at 10/300 energy left is now restored to 300/300. So before calling restoreSubEntities, you'll need to record the energy levels of all subentities, then call it, then reset the energy levels.energy_recharge_rate
of 0 - you'll also need to do this on save/load)Code: Select all
this.playerBoughtEquipment = function(equipment)
{
switch(equipment)
{
case "EQ_WEAPON_PULSE_LASER":
{
var pulselaser = this._findSubEntity("HPC_pulselaser");
if (pulselaser)
{
pulselaser.position = [-10.0, 1.63, 14.23];
break;
}
}
case "EQ_WEAPON_BEAM_LASER":
{
var beamlaser = this._findSubEntity("HPC_beamlaser");
if (beamlaser)
{
beamlaser.position = [-10.0, 1.63, 14.23];
break;
}
}
case "EQ_WEAPON_MINING_LASER":
{
var mininglaser = this._findSubEntity("HPC_mininglaser");
if (mininglaser)
{
mininglaser.position = [-10.0, 1.63, 14.23];
break;
}
}
case "EQ_WEAPON_MILITARY_LASER":
{
var militarylaser = this._findSubEntity("HPC_militarylaser");
if (militarylaser)
{
militarylaser.position = [-10.0, 1.63, 14.23];
break;
}
}
}
}
See the previous page in this thread, where I was asking a similar thing.dertien wrote:Can someone tell me how I should check for equipment that is already on the ship, in this case the lasers ?
Code: Select all
player.ship.currentWeapon.equipmentKey
Code: Select all
player.ship.forwardWeapon.equipmentKey