I'm having trouble finding out how to make use of ship event handlers of the kind one would use in worldscripts - this.shipDockedWithStation, etc. - from within script that is attached to a piece of equipment. I need to be able to do that (or something like it) because I need to do stuff with timers (esp. abort them) on docking or witchspace jump, etc.
I've tried just putting the handlers within the equipment script, but they don't seem to fire. And if I were to have an equipment script and a world script, I don't know how I'd get timers set by the equipment script to be alterable by the world script.
Advice? Sorry if the info is out there already and I've missed it.
Equipment scripts (and how they relate to worldscripts)
Moderators: winston, another_commander
- Commander McLane
- ---- E L I T E ----
- Posts: 9520
- Joined: Thu Dec 14, 2006 9:08 am
- Location: a Hacker Outpost in a moderately remote area
- Contact:
Re: Equipment scripts (and how they relate to worldscripts)
I have no experience yet with equipment scripts, and the Wiki seems currently to be down, so I can't check, but from what I've understood so far, equipment scripts are only for checking conditions when the F3-screen is created, and basically determine whether the equipment in question will be displayed as available or not.
Thus, doing or checking anything after the equipment is installed still has to be done in your world script.
EDIT: see the Oolite 1.77 announcement and the 1.77 introduction for OXPers.
So, in short, there are no "equipment scripts", but only "conditions for equipment availability scripts".
Thus, doing or checking anything after the equipment is installed still has to be done in your world script.
EDIT: see the Oolite 1.77 announcement and the 1.77 introduction for OXPers.
So, in short, there are no "equipment scripts", but only "conditions for equipment availability scripts".
Re: Equipment scripts (and how they relate to worldscripts)
Neither equipment operation scripts nor equipment condition scripts use world script event handlers. If you need the equipment to pay attention to them, the easiest way is to have a worldscript manage the equipment, timers, etc., and then have a very short equipment script that just relays commands:
Have a look at my Camera OXP for an example.
EDIT: corrected code example as noted below
Code: Select all
this.activated = function()
{
worldScripts["My Equipment Script"]._activateEquipment();
}
EDIT: corrected code example as noted below
Last edited by cim on Wed Mar 27, 2013 3:14 pm, edited 1 time in total.
Re: Equipment scripts (and how they relate to worldscripts)
And equipment scripts are not accessible for other scripts. It's a one-way ticket .-)cim wrote:Neither equipment operation scripts nor equipment condition scripts use world script event handlers. If you need the equipment to pay attention to them, the easiest way is to have a worldscript manage the equipment, timers, etc., and then have a very short equipment script that just relays commands:
No.Commander McLane wrote:So, in short, there are no "equipment scripts", but only "conditions for equipment availability scripts".
-
- ---- E L I T E ----
- Posts: 1248
- Joined: Sat Sep 12, 2009 11:58 pm
- Location: Essex (mainly industrial and occasionally anarchic)
Re: Equipment scripts (and how they relate to worldscripts)
Thanks for the help, everyone. Great!
But in
It should actually be this.activated, right?
But in
Code: Select all
this.activate = function()
{
worldScripts["My Equipment Script"]._activateEquipment();
}
Re: Equipment scripts (and how they relate to worldscripts)
Yes, sorry. Typing from memory because I couldn't get at the wiki.UK_Eliter wrote:It should actually be this.activated, right?
- Commander McLane
- ---- E L I T E ----
- Posts: 9520
- Joined: Thu Dec 14, 2006 9:08 am
- Location: a Hacker Outpost in a moderately remote area
- Contact:
Re: Equipment scripts (and how they relate to worldscripts)
Yes.UK_Eliter wrote:But inIt should actually be this.activated, right?Code: Select all
this.activate = function() { worldScripts["My Equipment Script"]._activateEquipment(); }
You're right, of course. I forgot about the scripts for primeable equipment, and only thought of the new equipment condition scripts.Svengali wrote:No.Commander McLane wrote:So, in short, there are no "equipment scripts", but only "conditions for equipment availability scripts".
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Equipment scripts (and how they relate to worldscripts)
And the future 1.77 equipment method
for action on the 'b' key was missing in the wiki.
Code: Select all
this.mode = function ()
{
// your code
}
UPS-Courier & DeepSpacePirates & others at the box and some older versions