Difference between revisions of "GNN Doc"

From Elite Wiki
(Added link to Snoopers Doc's upgrade to GNN example, and note on Snooper's "Error Codes")
m (Retagged!)
 
Line 112: Line 112:
 
These are not listed here, but [[Snoopers Doc]] has a section on Error Codes which may well be included in GNN (Snoopers was first published in 2009 and replaced by GNN in 2018)
 
These are not listed here, but [[Snoopers Doc]] has a section on Error Codes which may well be included in GNN (Snoopers was first published in 2009 and replaced by GNN in 2018)
  
[[Category:OXPDoc]]
+
[[Category:OXP API's]]

Latest revision as of 13:44, 20 September 2023

The recommended way in GNN is passing news through _insertNews(obj). The user has to check for messages on the ship and system interfaces screen (F4).

If you need to force a message onto the user as soon as he docks use _showScreen(obj) from your OXP's shipDockedWithStation() method.

Console usage

worldScripts.GNN._Help();


Functions

_insertNews(obj)

Puts the passed object in a queue of messages to be shown (the display pools). The object must contain at least .ID and .Message. Use at startUpComplete or later. Pooled messages are shown when the user checks the Galactic News Network on ship and system interfaces screen (F4).

ID
String. worldScript name.
Message
String. Text to be displayed. GNN will try to expand it via expandMissionText.
DKey
Bool. If set expandDescription will be used on Message.
Priority
Number (1..5), Default: 3. Used to sort messages.
Agency
Number. 1=GNN, 2=Rooters, 3=Snoopers, 4=Chronicle.
Pic
String. Overlay, Default:{name:'GNN_clean.png',height:512}. Needs alpha channel for Model.
PicExt
String. worldScript name which expanded the picture pool.
Music
Music for Newsflash. Default:'GNN.ogg'.
Model
String. Role of the model. Default:'lib_ms_helper'.
Pos
Array. Position for Model.
Ori
Array. Orientation for Model.
Spin
Bool. Sets spinModel. Default:false.
AutoPos
Bool. Automagically sets the position and orientation.
Tex
String. Sets the texture.
Mat
Object. Sets the material.
Delay
Number. Number of days until the newsflash will be available.
CB
String. Path of callback function. Passes the expanded message.
CBID
String. Callback returns CBID instead of message. Added in v1.1

Return: On success this method returns 0. On failure this method throws an exception.

A simple example:

worldScripts.GNN._insertNews({ID:'BGS',Message:'Hello'});

GNN applies some rules in the following order:

Agency disables Pic
Model disables Tex
!Model disables Ori and Pos.
!Pos enables AutoPos.

_showScreen(obj)

Displays the passed GNN object immediately. Requires to be docked and !system.isInterstellarSpace. Callbacks are disabled. Use at startUpComplete or later. The obj is constructed the same as for the above call. Use this message from your OXP's shipDockedWithStation() method.

Return: This method returns true if the message was shown, false otherwise.

A simple example:

worldScripts.GNN._showScreen({ID:'BGS',Message:'Hello'});

_addExtImages(arr,ws)

Expands the pool of overlay images. Use at startUpComplete or later. Added in v1.1

arr
Array. Must hold Arrays for all 4 Agencies, e.g [[],[],[],[]] (order GNN, Rooters, Snoopers and Chronicle) containing filenames. The arrays can be empty. The images should be 1024px * 512px with the cutout in the upper right corner for displaying models.
ws
String. worldScript name to relate news to expansion images (see PicExt).


shipdata.plist

GNN uses a script_info key in shipdata.plist to decide if the interface should be shown. Set 'GNN' to true for stations. By default only main stations and stations with hasNPCTraffic set will get an interface. Stations in interstellar space are excluded.

script_info = {GNN = true;};

An example

This is Massively Locked's MoarNews.oxz: This is the script.js from inside the Config folder. There is also a manifest.plist. That is the entire functioning .oxz - two files and one folder!

"use strict"
this.name		= "moarNews"
this.version		= "0.1"
this.description	= "moar news items for GNN"
this.author		= "Massively Locked"
this.copyright		= "(C) 2022"
this.licence		= "CC-NC-by-SA 4.0"
/*
This add-on obviously requires the GNN OXZ to be installed.  If it isn't, this add-on will have no effect.
*/

this.$main = function () {
	const moarNews = [		// this array contains all the news entries- it can get big!
		{ID: "moarNews000", Message: "The office of the Director of the Galactic Archives has issued a press release indicating that major announcements regarding the Archives will soon be forthcoming.  When asked if there is any merit to the rumors of relocating the office to the Digebiti system, the office had no comment."},
		{ID: "moarNews001", Message: "The 342nd Annual Ships Expo has created enormous traffic jams in the Mariar system.  One pilot interviewed at the station reportedly said that they were massively locked from witchpoint all the way to the station.  Authorities advise travelling off-lane and to use public transport where possible."},
		{ID: "moarNews002", Message: "In entertainment news, there are rumors swirling about that the popular vid-serial, The Frontier in Life, which was cancelled several years ago- will be making a come-back.  So far, there has been no word if the original cast would be returning for this possible revival."},
		// template for new entries.  Don't forget to increment the ID# and the comma after the closing }
		// {ID: "moarNews00#", Message: "..."},
	]	// closing bracket of moarNews- make sure that this is always after the last news entry

	moarNews.forEach (function (elmnt, ndx) {
		worldScripts.GNN._insertNews (elmnt)
		// the following IF statement is mainly for testing
		const rndNews = Math.floor (Math.random () * moarNews.length)
		if (ndx === rndNews) worldScripts.GNN._showScreen (elmnt)
	})
}
this.startUpComplete = function () {
	if (worldScripts.GNN._insertNews) const delayMoarNews = new Timer (this, $main, 1)
}

Upgrading Snoopers to GNN

See Snoopers Doc for an example taken from the Jaguar Company OXP (which currently uses Snoopers).

CCL PhraseGen Tool.gif

GNN Phrase Generator

Cabal Common Library Doc PhraseGen could be relevant - the GNN version may well have been taken from CCL

Error Codes

These are not listed here, but Snoopers Doc has a section on Error Codes which may well be included in GNN (Snoopers was first published in 2009 and replaced by GNN in 2018)