Difference between revisions of "Lib PAD"
m (Doc part II) |
Cholmondely (talk | contribs) m (Note about Vector OXP) |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[Image:IconLib.png|100px|right]] |
[[Image:IconLib.png|100px|right]] |
||
+ | [[File:P.A.D..png|320px|right]] |
||
==Overview== |
==Overview== |
||
− | Lib_PAD (part of [[Library]]) is a logbook, mission-log, diary and interface. AddOns can implement data to get important organisations, events, systems or persons exposed to the player in an unified way. It also ships search functionality, a way to customize players data (species, gender, etc) and players can also add own notes. |
+ | The P.A.D. on the F4 ship-station interface screen. Lib_PAD (part of [[Library]]) is a logbook, mission-log, diary and interface. AddOns can implement data to get important organisations, events, systems or persons exposed to the player in an unified way. It also ships search functionality, a way to customize players data (species, gender, etc) and players can also add own notes. |
+ | There was an earlier version in [[Vector OXP]]. |
||
==Categories== |
==Categories== |
||
+ | [[File:Lib_pad_layout.jpg|right|thumb|200px|Textures layout]] |
||
The categories in Lib_PAD are the first component of all dotted pathes. Pages in a category do share a template which defines the layout of the page. All pages, except LOGS, do have 6 slots for textures (t0 - t5). |
The categories in Lib_PAD are the first component of all dotted pathes. Pages in a category do share a template which defines the layout of the page. All pages, except LOGS, do have 6 slots for textures (t0 - t5). |
||
:;GALCOP:Category for GalCop, Police, Navy and other official organisations related to GalCop. |
:;GALCOP:Category for GalCop, Police, Navy and other official organisations related to GalCop. |
||
− | :::Contains entries: name, entry, |
+ | :::Contains entries: name, entry, enlisted, kills, missions, awards, info. |
+ | ::::name is set by Lib_PAD. |
||
:;GUILDS:Category for other organisations which do have a membership. |
:;GUILDS:Category for other organisations which do have a membership. |
||
− | :::Contains entries: name, entry, |
+ | :::Contains entries: name, entry, enlisted, kills, missions, awards, info. |
+ | ::::name is set by Lib_PAD. |
||
:;INFOS:Category for special events, news, specific stations, etc. |
:;INFOS:Category for special events, news, specific stations, etc. |
||
:::Contains entries: name, location, beacon, purpose, special, notes. |
:::Contains entries: name, location, beacon, purpose, special, notes. |
||
Line 16: | Line 19: | ||
:;PERSONS:Category for characters you have met or you got infos about. |
:;PERSONS:Category for characters you have met or you got infos about. |
||
:::Contains entries: name, origin, species, gender, age, rank, ship, info, notes. |
:::Contains entries: name, origin, species, gender, age, rank, ship, info, notes. |
||
+ | ::::Players name, origin, species, gender, age, rank and ship are set by Lib_PAD. |
||
:;SYSTEMS:Category for special systems like Leesti, Tianve, Tionisla, etc. |
:;SYSTEMS:Category for special systems like Leesti, Tianve, Tionisla, etc. |
||
:::Contains entries: name, info, notes. |
:::Contains entries: name, info, notes. |
||
===Types=== |
===Types=== |
||
− | :;Number: age. |
+ | :;Number: age, kills. |
:;String: beacon, enlisted, entry, gender, location, name, origin, purpose, rank, ship, species. |
:;String: beacon, enlisted, entry, gender, location, name, origin, purpose, rank, ship, species. |
||
:;Array: awards, info, list, missions, notes, special. |
:;Array: awards, info, list, missions, notes, special. |
||
+ | |||
+ | ===Textures=== |
||
+ | Specified textures can be any filename, but Lib_PAD also ships own textures for organisations, characters, insignia and medals. If set to a Number it will lookup the corresponding filename or if zero it won't show it. |
||
+ | :t0 - Usually an organisation on GALCOP, GUILDS and PERSONS pages. Lib_PAD uses greyscale textures. |
||
+ | :t1 - Usually a character on GALCOP, GUILDS and PERSONS pages. |
||
+ | :t2 - Usually an insignia / rank on GALCOP, GUILDS and PERSONS pages. |
||
+ | :t3 - Usually a medal on GALCOP, GUILDS and PERSONS pages. |
||
+ | :t4 - Unused yet. |
||
+ | :t5 - Unused yet. |
||
Line 28: | Line 41: | ||
The following entry points for AddOns can be used on [[Oolite_JavaScript_Reference:_World_script_event_handlers#startUpComplete|.startUpComplete]] or later. |
The following entry points for AddOns can be used on [[Oolite_JavaScript_Reference:_World_script_event_handlers#startUpComplete|.startUpComplete]] or later. |
||
===_addPageInCategory=== |
===_addPageInCategory=== |
||
− | {{CodeEx|codeex= _addPageInCategory: function( path, content )}} |
+ | {{CodeEx|codeex= _addPageInCategory: function( path, content, parent, sil )}} |
Register a new page entry in the specified dotted path. The inserted Object is cloned and merged with the corresponding template. |
Register a new page entry in the specified dotted path. The inserted Object is cloned and merged with the corresponding template. |
||
Line 34: | Line 47: | ||
:;path:String. Dotted path: [[#Categories|Category]] and page identifier. E.g. "GALCOP.NAVY". |
:;path:String. Dotted path: [[#Categories|Category]] and page identifier. E.g. "GALCOP.NAVY". |
||
:;content:Object. |
:;content:Object. |
||
+ | :;parent:Array. Pathes to relate to one or more other pages. |
||
+ | :;sil:Bool. Add the page silently. |
||
'''Returns:''' |
'''Returns:''' |
||
Line 40: | Line 55: | ||
===_setPageEntry=== |
===_setPageEntry=== |
||
− | {{CodeEx|codeex= _setPageEntry: function( path, value )}} |
+ | {{CodeEx|codeex= _setPageEntry: function( path, value, sil )}} |
Set value in the specified dotted path. |
Set value in the specified dotted path. |
||
'''Parameters:''' |
'''Parameters:''' |
||
:;path:String. Dotted path: [[#Categories|Category]], page identifier and [[#Types|page entry]]. E.g. "GALCOP.NAVY.enlisted". |
:;path:String. Dotted path: [[#Categories|Category]], page identifier and [[#Types|page entry]]. E.g. "GALCOP.NAVY.enlisted". |
||
− | :;value:Primitive (String or Number). If the path points to an Array the value will be pushed. |
+ | :;value:Primitive (String or Number). If the path points to an Array the value will be pushed. For kills '''++''' can be used to increase the value by one. |
+ | :;sil:Bool. Add the value silently. |
||
'''Returns:''' |
'''Returns:''' |
||
Line 59: | Line 74: | ||
'''Returns:''' |
'''Returns:''' |
||
− | :Object (on success) or ''' |
+ | :Object (on success) or '''null''' (if the path does not exist). |
+ | |||
+ | |||
+ | ==Handling== |
||
+ | Lib_PAD leaves the handling for loading and storing of inserted data to the inserting AddOns to avoid external resources like textures not being available and thus generating errors. It loads and stores it's own entries (pathes GALCOP.GENERIC, GALCOP.NAVY, GUILDS.GENERIC, INFOS.GENERIC, LOGS.GENERIC, PERSONS.GENERIC and SYSTEMS.GENERIC) |
||
+ | |||
+ | Loading and storing of data can be achieved easily, as shown in the following example. |
||
+ | <pre> |
||
+ | this.$data = { |
||
+ | GCI: {entry:clock.clockString,enlisted:"Sergeant",awards:["GCI Silver Cross"],t0:27,t1:1} |
||
+ | }; |
||
+ | this.startUpComplete = function(){ |
||
+ | if(missionVariables.MYMISSIONVARIABLE) this.$data = JSON.parse(missionVariables.MYMISSIONVARIABLE); |
||
+ | worldScripts.Lib_PAD._addPageInCategory("GALCOP.GCI",this.$data.GCI,0,1); |
||
+ | }; |
||
+ | this.playerWillSaveGame = function(){ |
||
+ | this.$data.GCI = worldScripts.Lib_PAD._getData("GALCOP.GCI"); |
||
+ | missionVariables.MYMISSIONVARIABLE = JSON.stringify(this.$data); |
||
+ | }; |
||
+ | </pre> |
||
Latest revision as of 20:31, 18 July 2021
Contents
Overview
The P.A.D. on the F4 ship-station interface screen. Lib_PAD (part of Library) is a logbook, mission-log, diary and interface. AddOns can implement data to get important organisations, events, systems or persons exposed to the player in an unified way. It also ships search functionality, a way to customize players data (species, gender, etc) and players can also add own notes.
There was an earlier version in Vector OXP.
Categories
The categories in Lib_PAD are the first component of all dotted pathes. Pages in a category do share a template which defines the layout of the page. All pages, except LOGS, do have 6 slots for textures (t0 - t5).
- GALCOP
- Category for GalCop, Police, Navy and other official organisations related to GalCop.
- Contains entries: name, entry, enlisted, kills, missions, awards, info.
- name is set by Lib_PAD.
- Contains entries: name, entry, enlisted, kills, missions, awards, info.
- GUILDS
- Category for other organisations which do have a membership.
- Contains entries: name, entry, enlisted, kills, missions, awards, info.
- name is set by Lib_PAD.
- Contains entries: name, entry, enlisted, kills, missions, awards, info.
- INFOS
- Category for special events, news, specific stations, etc.
- Contains entries: name, location, beacon, purpose, special, notes.
- LOGS
- Category for standard events like rescued escape pods, bailed out, fined, etc.
- Contains entries: list.
- PERSONS
- Category for characters you have met or you got infos about.
- Contains entries: name, origin, species, gender, age, rank, ship, info, notes.
- Players name, origin, species, gender, age, rank and ship are set by Lib_PAD.
- Contains entries: name, origin, species, gender, age, rank, ship, info, notes.
- SYSTEMS
- Category for special systems like Leesti, Tianve, Tionisla, etc.
- Contains entries: name, info, notes.
Types
- Number
- age, kills.
- String
- beacon, enlisted, entry, gender, location, name, origin, purpose, rank, ship, species.
- Array
- awards, info, list, missions, notes, special.
Textures
Specified textures can be any filename, but Lib_PAD also ships own textures for organisations, characters, insignia and medals. If set to a Number it will lookup the corresponding filename or if zero it won't show it.
- t0 - Usually an organisation on GALCOP, GUILDS and PERSONS pages. Lib_PAD uses greyscale textures.
- t1 - Usually a character on GALCOP, GUILDS and PERSONS pages.
- t2 - Usually an insignia / rank on GALCOP, GUILDS and PERSONS pages.
- t3 - Usually a medal on GALCOP, GUILDS and PERSONS pages.
- t4 - Unused yet.
- t5 - Unused yet.
Methods
The following entry points for AddOns can be used on .startUpComplete or later.
_addPageInCategory
_addPageInCategory: function( path, content, parent, sil ) |
Register a new page entry in the specified dotted path. The inserted Object is cloned and merged with the corresponding template.
Parameters:
- path
- String. Dotted path: Category and page identifier. E.g. "GALCOP.NAVY".
- content
- Object.
- parent
- Array. Pathes to relate to one or more other pages.
- sil
- Bool. Add the page silently.
Returns:
- true (on success) or false (if the page already exists).
_setPageEntry
_setPageEntry: function( path, value, sil ) |
Set value in the specified dotted path.
Parameters:
- path
- String. Dotted path: Category, page identifier and page entry. E.g. "GALCOP.NAVY.enlisted".
- value
- Primitive (String or Number). If the path points to an Array the value will be pushed. For kills ++ can be used to increase the value by one.
- sil
- Bool. Add the value silently.
Returns:
- true (on success) or false (if the path does not exist).
_getData
_getData: function( path ) |
Returns the cloned data-object in the specified dotted path.
Parameters:
- path
- String. Dotted path: Category and page identifier. E.g. "GALCOP.NAVY".
Returns:
- Object (on success) or null (if the path does not exist).
Handling
Lib_PAD leaves the handling for loading and storing of inserted data to the inserting AddOns to avoid external resources like textures not being available and thus generating errors. It loads and stores it's own entries (pathes GALCOP.GENERIC, GALCOP.NAVY, GUILDS.GENERIC, INFOS.GENERIC, LOGS.GENERIC, PERSONS.GENERIC and SYSTEMS.GENERIC)
Loading and storing of data can be achieved easily, as shown in the following example.
this.$data = { GCI: {entry:clock.clockString,enlisted:"Sergeant",awards:["GCI Silver Cross"],t0:27,t1:1} }; this.startUpComplete = function(){ if(missionVariables.MYMISSIONVARIABLE) this.$data = JSON.parse(missionVariables.MYMISSIONVARIABLE); worldScripts.Lib_PAD._addPageInCategory("GALCOP.GCI",this.$data.GCI,0,1); }; this.playerWillSaveGame = function(){ this.$data.GCI = worldScripts.Lib_PAD._getData("GALCOP.GCI"); missionVariables.MYMISSIONVARIABLE = JSON.stringify(this.$data); };