Oolite Bulletins

For information and discussion about Oolite.
It is currently Mon Oct 15, 2018 3:50 pm

All times are UTC




Post new topic  Reply to topic  [ 85 posts ]  Go to page 1 2 3 4 5 6 Next
Author Message
PostPosted: Sun Apr 29, 2012 10:35 am 
Offline
Commodore
Commodore
User avatar

Joined: Fri Feb 25, 2011 8:46 am
Posts: 1127
Location: UK South Coast.
Morning all,

cim has spent the last couple of days implementing some new JS features that I think a lot of OXpers and players will get quite excited about. These are:

ship.dataKey - http://wiki.alioth.net/index.php/Oolite ... ip#dataKey
player.ship.price - http://wiki.alioth.net/index.php/Oolite ... Ship#price
player.ship.serviceLevel - http://wiki.alioth.net/index.php/Oolite ... rviceLevel
player.replaceShip(dataKey[,entityPersonality]) - http://wiki.alioth.net/index.php/Oolite ... eplaceShip

In addition the following are all now read/write

ship.aftWeapon
ship.forwardWeapon
ship.portWeapon
ship.starboardWeapon

Before someone shouts Laser Coolers, switching weapons in flight does not reset the laser temperature!

EDITED:

Ship_Storage_Helper.OXP

https://www.box.com/s/0f2ea12624ceb2052640
Quote:
Ship_Storage_Helper.oxp

Capt Murphy 2012
Licence: CC BY-NC-SA 3.0 - see http://creativecommons.org/licenses/by-nc-sa/3.0/ for more info.
Requires: Oolite 1.77 - Trunk builds after revision 5025 (nightly build 23/06/12).
Version 0.20 24/06/12

Overview.

Ship_Storage_Helper contains helper functions for OXP writers that wish to use the new Trunk JS method player.replaceShip(dataKey[,entityPerosnality]). It facilitates storing information about the current player ship in a variable or missionVariable, and reinstating a stored player ship as the players current ship, taking into account known OXP variables that also need to be stored/reinstated.

As development and testing is ongoing it is anticipated that additional OXP compatibility code will need to included. I would be grateful if testers and OXP authors could alert me to any bugs using the current release. In the long term I hope this OXP to become a community maintained OXP as it will require regular updating in light of new OXP releases.

Current OXP Compatibility.


Ship_Storage_Helper contains code to explicitly overcome compatibility issues for the following OXPs:

New Cargoes, HyperCargo, Vortex, APRIL, Iron Hide, Missiles and Bombs, Railgun, Target Autolock Plus, Target Reticle Sensitive, Armoury, Aquatics, Battle Damage, 'Breakables', TCAT, Respray for Griffs.

Functions.

worldScripts["Ship_Storage_Helper.js"].storeCurrentShip()

This function can be called from other worldScripts immediately before changing the player's ship with player.replaceShip(dataKey), and returns a string including the stored ships essential attributes.

worldScripts["Ship_Storage_Helper.js"].restoreStoredShip(storedShipString)

This function takes the output of storeCurrentShip as an argument and uses it to reinstate the player ship from the stored information. Returns true if successful or one of the following error strings if it fails.

"Error-Invalid Parameter, expected String" - indicates that storedShipString is in wrong format
"Error-Invalid Parameter, array incorrect length" - indicates that storedShipString was created by a newer version of Ship_Storage_Helper.
"Error-Invalid dataKey" - indicates that the OXP that defined that dataKey has been removed since storedShipString was created.

The output of storeCurrentShip is a JSON stringified array of ship attributes, containing the following indices as of v0.16.

0: Place and time of storage - Array [galaxyNumber,system.ID,clock.seconds,player.ship.displayName,system.name,stationAttributes,player.ship.price] (stationAttributes are [player.ship.dockedStation.primaryRole, player.ship.dockedStation.dataKey, player.ship.dockedStation.position])
1: dataKey (e.g. "cobra3-player")
2: aftWeapon equipmentKey
3: forwardWeapon equipmentKey
4: portWeapon equipmentKey
5: starboardWeapon equipmentKey
6: Array of pylon equipmentKeys
7: Array of normal equipment equipmentKeys & equipmentStatus
8: Array of manifest contents.
9: fuel
10: passenger contracts
11: array of subEnts (only if frangible subEnts are missing on storage)
12: serviceLevel
13: entityPersonality
14: unused
15: Cim's New Cargoes suspended cargo variable
16: Array of Thargoid's HyperCargo missionVariables
17: Array of Thargoid's Vortex/Maelstrom missionVariables
18: Array of Thargoid's APRIL missionVariables
19: Array of Thargoid's IronHide missionVariables
20: Ramirez's Missile & Bombs missionVariable
21: Array of McClane's Railgun missionVariables.
22: Thargoid's TargetAutoLock Plus missionVariable.
23: Eric's TargetReticle Sensitive missionVariable.
24: Thargoid's Armoury missionVariable.
25: Thargoid's Aquatics missionVariable.
26: Smivs Battle Damage missionVariable.
27: Respray for Griff's missionVariables.

Individual elements can be accessed from your own script. For example-

var myStoredShip = worldScripts["Ship_Storage_Helper.js"].storeCurrentShip()
var dataKey = JSON.parse(myStoredShip[1])

worldScripts["Ship_Storage_Helper.js"].disableVortexPBNSFunc(context)
worldScripts["Ship_Storage_Helper.js"].disableMaelstromPBNSFunc(context)

Context must be a string – valid values are “delete” & “retainName”.

Used to temporarily modify the behaviour of the playerBoughtNewShip function in Thargoid's Vortex.oxp, to either prevent it running, or to prevent it renaming a Vortex or Maelstrom that has previously been stored.

worldScripts["Ship_Storage_Helper.js"].enableVortexPBNSFunc()
worldScripts["Ship_Storage_Helper.js"].enableMaelstromPBNSFunc()

Reverses the changes made by the above functions.

worldScripts["Ship_Storage_Helper.js"].disableTCATPBNSFunc()
worldScripts["Ship_Storage_Helper.js"].enableTCATPBNSFunc()

Used to temporarily disable the playerBoughtNewShip function in Thargoid's TCAT.oxp. Buying a new ship is a trigger for mission failure in this OXP, but this may not always be appropriate behaviour using the new methods.

All of these functions are called from Extended_Shipyards.OXP if you need examples of how they can be used.

Variables.


worldScripts["Ship_Storage_Helper.js"].dataKeyArray

This is an array of valid player ship dataKeys from the users currently installed OXPs. It is built at startUp. It is not necessarily comprehensive, and is less likely to be comprehensive the more unique player-flyable ships are installed. It can generally capture up to 60 to 70 unique dataKeys.

ChangeLog

v0.16 31/5/12 – Added additional information to header including system.name as a string, information about the station the ship is stored at, and the full price of the stored ship. Added entityPersonality as a ship attribute that is saved and can be restored (maintains paint colours on Griff's ships under full shaders). Thanks to cim for making this option available from trunk revision 4968. Fixed a bug were version 0.15 was unintentionally dependent on the Breakables OXPs.

v0.17 05/06/12 - v.017 05/6/12 – Fixed a bug in handling of subEntities when the ship doesn’t have any.

v0.18 09/06/12 – Added compatibility for v0.2 of Respray for Griff's.oxp

v0.19 16/06/12 – Updated compatibility for v0.3 of Respray for Griff's.oxp

v0.20 24/06/12 – Updated compatibility for v0.4 of Respray for Griff’s.oxp so that adjusted decals are correctly restored. Ensure that player shield strength is set to maximum on restore (thanks cim for the report).

_________________
[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


Last edited by Capt. Murphy on Sun Jun 24, 2012 8:44 am, edited 13 times in total.

Top
   
PostPosted: Sun Apr 29, 2012 11:21 am 
Offline
Thargoid
Thargoid
User avatar

Joined: Thu Jun 12, 2008 6:55 pm
Posts: 5510
It does open some interesting possibilities, doesn't it :D

APRIL should be quite easy to deal with, as it's just an array/mission variable, similar to HyperCargo. Vortex though might be somewhat more of a challenge as there's much more to it. It will also depend somewhat on whether playerBoughtNewShip gets triggered or not.

But if there's any tweaks to the OXPs that will help in storage, let me know.

_________________
My OXPs via Boxspace or from my Wiki pages :D.

Thargoid TV
Dropbox Referral Link


Top
   
PostPosted: Sun Apr 29, 2012 11:30 am 
Offline
Retired Assassin
Retired Assassin
User avatar

Joined: Tue Feb 09, 2010 11:31 am
Posts: 8396
Location: Disunited Kingdom
Smivs is getting all excited :D

_________________
Commander Smivs, the friendliest Gourd this side of Riedquat.


Top
   
PostPosted: Sun Apr 29, 2012 11:38 am 
Offline
Intergalactic Spam Assassin
Intergalactic Spam Assassin
User avatar

Joined: Thu Dec 14, 2006 9:08 am
Posts: 9520
Location: a Hacker Outpost in a moderately remote area
Quote:
ship.dataKey (read only - reference to the dataKey in shipdata e.g "cobra3-player".
player.replaceShip(dataKey) - a method to change the player ship!
What can I say? Wow, just wow! :shock:

_________________
The Story — The Career — The OXPs


Top
   
PostPosted: Sun Apr 29, 2012 11:39 am 
Offline
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
User avatar

Joined: Fri Nov 11, 2011 6:19 pm
Posts: 4018
Quote:
It will also depend somewhat on whether playerBoughtNewShip gets triggered or not.
It does. When I looked through the various OXPs I had which made use of it, all of them without exception seemed to be asking "has the player's ship changed" rather than "has the player's ship changed because they paid money at the shipyard".

Of course, I don't have every OXP to test with, so if there's a need to separate the two cases out into separate events then I can do that (it would mean that most existing OXPs were using the "wrong" event for their code, which could cause some bugs, so I think it would need a fairly strong case)

_________________
OXPs: [EliteWiki] New Cargoes, [EliteWiki] Skilled NPCs, [EliteWiki] Curse of the Black Sunspot, and more


Top
   
PostPosted: Sun Apr 29, 2012 12:39 pm 
Offline
Commodore
Commodore
User avatar

Joined: Fri Feb 25, 2011 8:46 am
Posts: 1127
Location: UK South Coast.
I think I may be able to work around issues with the Vortex and the like by using a short timer to delay updating the missionVariables on restore to give a chance for it's own script to do it's stuff. But the player will always get the welcome screen on restore and the Vortex may decide to change it's name. I'll experiment with what works/doesn't work and report back to Thargoid.

A timer delay may be the solution to getting passenger/cargo contracts working as-well as I could store the data, but couldn't successfully reinstate it, despite being able to do so with the debug console using the same values.

I've just put a function into my copy of Ship_Storage_Helper that creates an array of valid player-flyable dataKeys from the users current list of installed OXPs. This array will also be accessible for other worldScripts.

Anyway expect regular updates to these over the next week or two, although it will remain firmly WIP until such time as we get a 1.77 test release.

And apologies for my crap spelling in the first post.....I was itching for the 'reveal' this morning and spent less time than I should of on the readmes...

And I should just say how appreciative I am to cim for implementing this in trunk....if I ever get the chance I'll owe you a couple of pints.

_________________
[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


Top
   
PostPosted: Sun Apr 29, 2012 12:56 pm 
Offline
Thargoid
Thargoid
User avatar

Joined: Thu Jun 12, 2008 6:55 pm
Posts: 5510
The Vortex's name is stored when the ship is bought, so you should be able to retrieve it when the ship is restored.

And given all the work and thanks that cim has, he's owed so many pints he'll probably have enough to swim in...

_________________
My OXPs via Boxspace or from my Wiki pages :D.

Thargoid TV
Dropbox Referral Link


Top
   
PostPosted: Sun Apr 29, 2012 4:40 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Wed May 04, 2011 10:42 am
Posts: 1397
Location: Saskatchewan, Canada
:shock: Holy crap! :shock:

:idea: So, when buying equipment, you could check for requires cargo space in the equipment.plist and when the equipment is bought then change ships to one with one less cargo space...and the reverse for selling equipment. Would this work now?

:idea: About the laser cooler that you want to prevent, if you switch ships to an identical one does the laser temp still remain the same?

:idea: So now one could set up a docking sequence mission screen when getting near a derelict and if you wanted to swap ships you could have your ship change to the derelict and the derelict change to your ship. Would this work now?

:idea: So if you wanted to have a performance tweak of a specific ship you could set it up to swap between different versions with different values for max speed, pitch and roll, thrust, etc. Would this work now?

I've had an idea for an Oolite-A type of oxp on my hard drive for the last year or so and was looking at the possibility to do a workaround as a pet project for myself only just recently. So it's possible now without a workaround, eh?

There must be scores of other possibilities now.

:shock: Somebody pinch me<dreaming>

To cim and all the devs:

http://youtu.be/bP8iL0JAcyw

:lol:

Is this the bomb or are there more to be dropped on us before 1.77 :?:

And could someone please post a good link for where to get and how to compile the current trunk for windows xp. As amazing as it may seem I have never bothered to do this so I could use some friendly instruction as I will now be shifting all my oxp development towards what will be available in 1.77.

_________________
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs


Top
   
PostPosted: Sun Apr 29, 2012 4:55 pm 
Offline
Commodore
Commodore
User avatar

Joined: Fri Feb 25, 2011 8:46 am
Posts: 1127
Location: UK South Coast.
Don't get too excited CSOTB, the replaceShip method only works when docked. Building from source - http://aegidian.org/bb/viewtopic.php?f=8&t=5943

_________________
[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


Top
   
PostPosted: Sun Apr 29, 2012 4:59 pm 
Offline
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
User avatar

Joined: Fri Nov 11, 2011 6:19 pm
Posts: 4018
Quote:
:idea: So, when buying equipment, you could check for requires cargo space in the equipment.plist and when the equipment is bought then change ships to one with one less cargo space...and the reverse for selling equipment. Would this work now?
It's not completely impossible, but you would have to define all the reduced variations in shipyard.plist (with chance 0 so they don't appear for sale) and shipdata.plist. Impractical, given how often new player ships are brought out, unless you wanted to restrict the equipment to a small set of special ships.
Quote:
:idea: About the laser cooler that you want to prevent, if you switch ships to an identical one does the laser temp still remain the same?
Since you can only switch ships while docked it doesn't really matter. (There are so many other conceptual issues with switching ships in flight that you shouldn't expect that to happen)
Quote:
:idea: So now one could set up a docking sequence mission screen when getting near a derelict and if you wanted to swap ships you could have your ship change to the derelict and the derelict change to your ship. Would this work now?
Should be possible.
Quote:
:idea: So if you wanted to have a performance tweak of a specific ship you could set it up to swap between different versions with different values for max speed, pitch and roll, thrust, etc. Would this work now?
As long as you define all the variants in shipdata and shipyard, yes.
Quote:
Is this the bomb or are there more to be dropped on us before 1.77 :?:
You'll have to wait and see :wink:
Quote:
And could someone please post a good link for where to get and how to compile the current trunk for windows xp. As amazing as it may seem I have never bothered to do this so I could use some friendly instruction as I will now be shifting all my oxp development towards what will be available in 1.77.
Windows pre-compiled nightly builds from trunk are available. See http://aegidian.org/bb/viewtopic.php?f=8&t=6852 for details.

_________________
OXPs: [EliteWiki] New Cargoes, [EliteWiki] Skilled NPCs, [EliteWiki] Curse of the Black Sunspot, and more


Top
   
PostPosted: Sun Apr 29, 2012 5:05 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Wed May 04, 2011 10:42 am
Posts: 1397
Location: Saskatchewan, Canada
Quote:
Don't get too excited CSOTB, the replaceShip method only works when docked. Building from source - http://aegidian.org/bb/viewtopic.php?f=8&t=5943
:lol: Isn't passion and excitement the primary driving factor in oxp development?

Works when docked is ok by me. Thanks for the link Capt. Murphy. :D

_________________
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs


Top
   
PostPosted: Sun Apr 29, 2012 5:13 pm 
Offline
Thargoid
Thargoid
User avatar

Joined: Thu Jun 12, 2008 6:55 pm
Posts: 5510
Quote:
:lol: Isn't passion and excitement the primary driving factor in oxp development?

Personally I find it's more inspiration and beer. :wink: :lol:

_________________
My OXPs via Boxspace or from my Wiki pages :D.

Thargoid TV
Dropbox Referral Link


Top
   
PostPosted: Sun Apr 29, 2012 5:18 pm 
Offline
Retired Assassin
Retired Assassin
User avatar

Joined: Tue Feb 09, 2010 11:31 am
Posts: 8396
Location: Disunited Kingdom
Quote:
Quote:
:lol: Isn't passion and excitement the primary driving factor in oxp development?

Personally I find it's more inspiration and beer. :wink: :lol:
In my case it's the little voices inside my head... :!:

_________________
Commander Smivs, the friendliest Gourd this side of Riedquat.


Top
   
PostPosted: Sun Apr 29, 2012 5:33 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Wed May 04, 2011 10:42 am
Posts: 1397
Location: Saskatchewan, Canada
Quote:
Quote:
:idea: So, when buying equipment, you could check for requires cargo space in the equipment.plist and when the equipment is bought then change ships to one with one less cargo space...and the reverse for selling equipment. Would this work now?
It's not completely impossible, but you would have to define all the reduced variations in shipyard.plist (with chance 0 so they don't appear for sale) and shipdata.plist. Impractical, given how often new player ships are brought out, unless you wanted to restrict the equipment to a small set of special ships.
Quote:
:idea: About the laser cooler that you want to prevent, if you switch ships to an identical one does the laser temp still remain the same?
Since you can only switch ships while docked it doesn't really matter. (There are so many other conceptual issues with switching ships in flight that you shouldn't expect that to happen)
Quote:
:idea: So now one could set up a docking sequence mission screen when getting near a derelict and if you wanted to swap ships you could have your ship change to the derelict and the derelict change to your ship. Would this work now?
Should be possible.
Quote:
:idea: So if you wanted to have a performance tweak of a specific ship you could set it up to swap between different versions with different values for max speed, pitch and roll, thrust, etc. Would this work now?
As long as you define all the variants in shipdata and shipyard, yes.
Quote:
Is this the bomb or are there more to be dropped on us before 1.77 :?:
You'll have to wait and see :wink:
Quote:
And could someone please post a good link for where to get and how to compile the current trunk for windows xp. As amazing as it may seem I have never bothered to do this so I could use some friendly instruction as I will now be shifting all my oxp development towards what will be available in 1.77.
Windows pre-compiled nightly builds from trunk are available. See http://aegidian.org/bb/viewtopic.php?f=8&t=6852 for details.
For equipment taking cargo space I'm actually just thinking of using this for specific ships for an Oolite-A type of oxp.

It's probably best to only be able to switch ships while docked. :wink:

More bombs? Wait and see? :D

Thanks for the link cim! :D

_________________
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs


Top
   
PostPosted: Sun Apr 29, 2012 5:44 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Wed May 04, 2011 10:42 am
Posts: 1397
Location: Saskatchewan, Canada
Quote:
Quote:
:lol: Isn't passion and excitement the primary driving factor in oxp development?

Personally I find it's more inspiration and beer. :wink: :lol:
Which leads to passion and excitement! :D
Quote:
In my case it's the little voices inside my head... :!:
I knew it! :P Hey, I like those little voices of yours, they have come up with some good ideas. :D

_________________
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 85 posts ]  Go to page 1 2 3 4 5 6 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited