Scripters cove

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

Hmm, ok. But there's still the question of both the background transparency and more importantly having the ship control keys still accessible with the mission screen visible.
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: Scripters cove

Post by Capt. Murphy »

Thargoid wrote:
Hmm, ok. But there's still the question of both the background transparency and more importantly having the ship control keys still accessible with the mission screen visible.
Fair enough point for Gimbal's use....however inflight Mission Screens could be used for all sorts of other useful Shenanigans. :wink:
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Re: Scripters cove

Post by Svengali »

mission.runScreen works pretty well inflight. The only limit is that you can't display a model there. But using missionscreens inflight is simply a bad design decision for OXPs as it takes away control from the player. OXPs can use other ways if they really need to display additional infos or to give the player options.
User avatar
Zieman
---- E L I T E ----
---- E L I T E ----
Posts: 680
Joined: Tue Sep 01, 2009 11:55 pm
Location: in maZe

Re: Scripters cove

Post by Zieman »

Is it possible to change player-ship's cargo capacity on-the-fly?

I have a ship in the pipeline, that has 2 subentities that can be shot off - it would be cool if losing the subents would reduce cargo space and repairing them would give the space back.
I think I could get away with one such subent with a bit of scripting & invisible Lagre Garco Bay, but not with two...
...and keep it under lightspeed!

Friendliest Meteor Police that side of Riedquat

[EliteWiki] Far Arm ships
[EliteWiki] Z-ships
[EliteWiki] Baakili Far Trader
[EliteWiki] Tin of SPAM
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: Scripters cove

Post by Capt. Murphy »

Zieman wrote:
Is it possible to change player-ship's cargo capacity on-the-fly?

I have a ship in the pipeline, that has 2 subentities that can be shot off - it would be cool if losing the subents would reduce cargo space and repairing them would give the space back.
I think I could get away with one such subent with a bit of scripting & invisible Lagre Garco Bay, but not with two...
Have a look at Thargoid's HyperCargo and Vortex oxps for some ideas on 'virtual' cargo bays. Then beware that you'll need to make them compatible with cim's new Cargoes, and I'll have to update Illegal Goods Tweak. But don't let that put you off it sounds like a fun idea.
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: Scripters cove

Post by Capt. Murphy »

Svengali wrote:
But using missionscreens inflight is simply a bad design decision for OXPs as it takes away control from the player.
That would be the only reason I'd ever use them in flight - the player wouldn't be in control, they would be a kind of holding screen whilst a script does all sorts of weirdness that you don't really want the player to see the effects of.
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Scripters cove

Post by Okti »

Capt. Murphy wrote:
Svengali wrote:
But using missionscreens inflight is simply a bad design decision for OXPs as it takes away control from the player.
That would be the only reason I'd ever use them in flight - the player wouldn't be in control, they would be a kind of holding screen whilst a script does all sorts of weirdness that you don't really want the player to see the effects of.
One is used for LongRangeScanner as a cheat or debugging tool :D. I know it is not elegant but no other choice. Also as Thargoid said same aproach is used in Vortex. If you are in need to give inflight choices for the player there are two options: mission screens or custom messages via a special equipment. Choice is up to the scripters.
My OXP's
And Latest Mission Coyote's Run
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: Scripters cove

Post by Capt. Murphy »

Can anyone tell me what I'm doing wrong in attempting to add a Passenger via script / debug console.
The eta is in the future, there is space for a passenger, but the addPassenger method is returning false?
Current trunk.

Code: Select all

> player.ship.addPassenger("Ab Nuthsoen",129,2,180058873294,528)
false
> player.ship.passengers
[]
> player.ship.passengerCapacity
1
> player.ship.passengerCount
0
> player.ship.addPassenger("Ab Nuthsoen",129,2,180058873294,528)
false
> clock.seconds
180058229497.2031
> clock.seconds < 180058873294
true
Edit to add - it appears to be a minor Oolite bug when you purchase a new ship or use the new player.replaceShip method. If the current ship has a passenger when you purchase or replace the ship examining the save files before and after shows that <key>passenger_record</key> isn't updated, although <key>passengers</key> is. And attempting to add a passenger with the same name as one present in <key>passenger_record</key> fails, even if <key>passengers</key> is empty.
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

Capt. Murphy wrote:
Edit to add - it appears to be a minor Oolite bug when you purchase a new ship or use the new player.replaceShip method. If the current ship has a passenger when you purchase or replace the ship examining the save files before and after shows that <key>passenger_record</key> isn't updated, although <key>passengers</key> is. And attempting to add a passenger with the same name as one present in <key>passenger_record</key> fails, even if <key>passengers</key> is empty.
Thanks - will fix.

EDIT: fixed in r4892. Since it could theoretically cause problems in 1.76 in very obscure circumstances, fixed in maintenance as well as trunk.
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: Scripters cove

Post by Pleb »

Can anyone explain why this isn't allowed in a JS script:

Code: Select all

var name = missionVariables.mission_taxi_passenger;
var curloc = system.ID;
var dest = missionVariables.mission_taxi_dest;
var time = missionVariables.mission_taxi_time;
var pay = missionVariables.mission_taxi_pay;
player.ship.addPassenger(name, curloc, dest, clock.seconds+time*24*3600, pay);
Can I not add passengers to a ship using stored variables?
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

Pleb wrote:
Can I not add passengers to a ship using stored variables?
It should make absolutely no difference whether the function is called with stored variables or not.

Just to check the obvious things first:
1) The ship has at least one empty passenger cabin
2) The ship does not already have a passenger with the same name as missionVariables.mission_taxi_passenger

Assuming that's not it, feel free to PM me a link to the OXP and I'll have a look for more obscure things.
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: Scripters cove

Post by Capt. Murphy »

Possibly relevant or possibly not (depending on where you are getting your variables from) but the wiki entry http://wiki.alioth.net/index.php/Oolite ... passengers is wrong in the passengers[0].fee is not returned as an integer as stated but a string (albeit a number in a string). Same goes for http://wiki.alioth.net/index.php/Oolite ... #contracts

Not sure if this is a documentation error or a bug.

However both addPassenger and awardContract require fee to be a number.

Conversion is straight forward. e.g this.fee = Number(player.ship.passengers[0].fee)
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

Capt. Murphy wrote:
However both addPassenger and awardContract require fee to be a number.
The interface between Javascript and the Oolite engine is fairly flexible about this - provided the number is recognisably a number, it can be 528, 528.0, "528", or "528.0". If the problem is the JS type of a variable being provided to a function, I'll be surprised.

As for the Wiki entry, that looks more like a bug rather than a documentation error (since all the other numeric values are both documented as and returned as numeric types), and I'll fix that now.

EDIT: fixed in r4900. Just in case there's some OXP code that relies on the old type, I won't push this change to the maintenance branch yet.
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: Scripters cove

Post by Pleb »

For reasons unknown I've managed to get my code to work now. I still can't explain why it wasn't working, but I think it was to do with the time...however it is working now so never mind cheers anyways though.
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Scripters cove

Post by Eric Walch »

Pleb wrote:
For reasons unknown I've managed to get my code to work now. I still can't explain why it wasn't working, but I think it was to do with the time...however it is working now so never mind cheers anyways though.
Looking at the code, there are only two reasons when adding a contract fails:
A: When there is no free passenger cabin.
B: When that passenger is already present.

I assume B can easily happen during testing. At least it should be added to the wiki that there can not be two passengers with the same name. (edit: done)
Post Reply