Scripting:Interfaces

From STNE Wiki

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
-
[[Category:Scripting|Interfaces]]
+
[[Category:Scripting]]
 +
{{ScriptingMenu}}
 +
 
Interfaces extend the possibilities of scripts by registering pre-defined variables.
Interfaces extend the possibilities of scripts by registering pre-defined variables.
For example, the {{code|Web}} interface provides two variables representing the HTTP request and response.
For example, the {{code|Web}} interface provides two variables representing the HTTP request and response.

Revision as of 16:51, 10 September 2010


Main | Syntax | Operators | Interfaces | FAQ | Contents | API Reference | Index


Interfaces extend the possibilities of scripts by registering pre-defined variables. For example, the Web interface provides two variables representing the HTTP request and response. Using this interface, scripts can generate HTML output and get some information about the HTTP request.

You can use an interface in a script by going to the settings tab in the script editor and ticking the interfaces you want to use. You can also do it manually by adding this code at the top of the script:

#UseInterface Web, ShipPortal  // a comma separated list of interfaces


Contents

Web

The Web interface provides a script with the ability to generate HTML output and to read some information about the HTTP request.

Registered variables

Response As CWebResponse
This represents the root element for your script's HTML response. By adding elements to Response, the script can generate HTML output.
Request As CWebRequest
This contains some data describing the HTTP request and some additional data added by STNE. Most notably, it contains the submitted form data.


ShipPortal

The ShipPortal interface enables a script to be used as a ship portal. Ship portals can be installed on a ship. Anyone with a ship in the same sector can enter the ship's portal, and they will see the HTML output generated by the script. By adding forms to the output you can also have the guest enter data which will be available to the script when the form is submitted. See the 'Web' interface on details how to generate output.

The interface provides a few variables exposing on which ship the portal is running, and the user and ship that entered the portal. It also seems to include everything the Web interface provides. However, it is recommended to also include the Web interface whenever you include this interface.

Registered variables

MyShip As CMyShip
This is the ship the portal is running on.
GuestShip As CShip
This is the ship that the guest entered the portal from.
GuestUser As CUser
The user who entered the portal.


ColoniePortal

The ColoniePortal interface enables a script to be used as a ship portal. Colony portals can be installed on a ship. Anyone with a ship in the same sector can enter the colony's portal, and they will see the HTML output generated by the script. By adding forms to the output you can also have the guest enter data which will be available to the script when the form is submitted. See the Web interface on details how to generate output.

The interface provides a few variables exposing on which ship the portal is running, and the user and ship that entered the portal. It also seems to include everything the Web interface provides. However, it is recommended to also include the Web interface whenever you include this interface.

Registered variables

MyColony As CMyColony
This is the colony the portal is running on.
GuestShip As CShip
This is the ship that the guest entered the portal from.
GuestUser As CUser
The user who entered the portal.
Personal tools