Scripting:Interfaces

From STNE Wiki

Revision as of 23:51, 14 August 2010 by Glest Durnham (Talk | contribs)
Jump to: navigation, search

Interfaces extend the possibilities of scripts by registering pre-defined variables. For example, the 'Web' interface provides the variables 'Response As CWebResponse' and 'Request As CWebRequest'. 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 the script with the ability to generate HTML output and to read 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 you generate HTML output.
Request As CWebRequest
This contains some data describing the HTTP request. Most notably, it contains the submitted form data.


ShipPortal

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

Ship portals can be installed on a ship. Anyone with a ship in the same sector can enter the ships 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.


Registered variables

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


ColonyPortal

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

Colony portals can be installed on a colony. Anyone with a ship in the same sector can enter the colonies 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.


Registered variables

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