Functions

The Schemaverse has a lot of functions, some of which may have yet to be mentioned in this tutorial. This is a full listing of all available functions a player can use during play.

Getting around
ship_course_control
refuel_ship

Actions
attack
mine
repair

Purchasing and Trading
convert_resource
upgrade

Utilities
get_char_variable
set_char_variable
get_numeric_variable
set_numeric_variable
get_player_id
get_player_username
get_player_error_channel
get_player_symbol
get_player_rgb
in_range_planet
in_range_ship
read_event


SHIP_COURSE_CONTROL(Ship ID, Speed, Direction, Destination)


Description
Use this function to set the course of your ships.

Parameters

Name Type Description
Ship ID integer
Target Speed integer Cannot be greater then my_ships.max_speed
Target Direction integer Leave this as NULL to have your ship automatically go in the direction required to get to your destination
Destination Point Use Destination (X,Y) point to tell the system to tell the ship to try to slow down once the destination is in range.

Returns

Type Description
boolean Returns TRUE (t) if the ships new course is set successfully and FALSE (f) if it is not.

refuel_ship(Ship ID)


Description
Using this function will take fuel from your players fuel reserve (my_player.fuel_reserve) and add it to the fuel of the specified ship ID. It will always fill up the ship to the level of max_fuel.

This does not count as a ship action.

Any errors that occur during this function will be piped through the players error_channel.

Parameters

Name Type Description
Ship ID integer
*Returns*
Type Description
integer Returns amount of fuel added to the ship.

attack(Attacking Ship ID, Enemy Ship ID)


Description
Use this function to attack other ships. Careful though, friendly fire is possible!

When the attack is executed successfully, an event will be added to the my_events view for both players involved. Any errors that occur during this function will be piped through the players error_channel.

Using this function will act as an Action for the ship. The ship will not be able to perform another action until the game tic increases.

Parameters

Name Type Description
Attacking Ship ID integer
Enemy Ship ID integer

Returns

Type Description
integer Damage done in attack to enemy ship

mine(Mining Ship ID, Planet ID)


Description
Use this function to mine planets that are in range. Mining is important because it helps you acquire fuel that can then fuel your fleets or be traded to afford upgrades. It is further important because it is by successfully mining that you claim new planets as conquered.

When the mining is started by a ship with this command, the ship is added to one of the hidden Schemaverse system tables. At the end of each system tic, the Schemaverse tic.pl script executes a function called perform_mining(). For each planet currently being mined this tic, the system takes a look at each ship’s prospecting abilities, the amount of mining that can occur on a planet, and consequently calculates which ship(s) have successfully mined the planet. Once the actual mining takes place, the information will be added to the my_events view for all involved players.

Any errors that occur during mining will be piped through the players error_channel.

Using this function will act as an Action for the ship. The ship will not be able to perform another action until the game tic increases.

Parameters

Name Type Description
Mining Ship ID integer
Planet ID integer The Planet must be in range of the ship attempting to mine it

Returns

Type Description
boolean Returns TRUE (t) if the ship was successfully added to the current mining table for this tic. Returns FALSE (f) if the ship is out of range and could not be added

repair(Repair Ship ID, Damaged Ship ID)


Description
Use this function to repair other ships. A ship with zero health cannot perform actions.

When the repair is executed successfully, an event will be added to the my_events view for the player involved. Any errors that occur during this function will be piped through the players error_channel.

Using this function will act as an Action for the ship. The ship will not be able to perform another action until the game tic increases.

Parameters

Name Type Description
Repair Ship ID integer
Damaged Ship ID integer

Returns

Type Description
integer Health regained by the ship

convert_resource(Current Resource Type, Amount to Convert)


Description
Use this function to convert fuel to currency or vice versa. The value of the fuel will fluctuate based on levels in the game.

Any errors that occur during this function will be piped through the players error_channel.

Using this function does not count as an action and can be run as often as you like.

Parameters

Name Type Description
Current Resource Type character varying What is the player selling for conversion. Either the string ‘FUEL’ or ‘MONEY
Amount to Convert integer

Returns

Type Description
integer Total resources acquired from the conversion

upgrade(Ship ID, Product Code, Quantity)


Description
Use this function to upgrade your fleet of ships. This does not count as a ship action.

To see a list of what is available for upgrade, run a SELECT on the price_list table. Then use the code listed there for the Product Code parameter for this function.

There are a maximum amount of upgrades that can be done to ship. To learn the maximum values, look in the public_variable view.

Any errors that occur during this function will be piped through the players error_channel.

Parameters

Name Type Description
Ship ID integer
Product Code character varying See the price_list table for a list of values to use here.
Quantity integer

Returns

Type Description
boolean Returns TRUE (t) if the purchase was successful and FALSE (f) if there was a problem

get_char_variable(Variable Name)


Description
This utility function simply makes it easier to recall character varying values set by your player or the system.

Using this function does not count as an action and can be run as often as you like.

Parameters

Name Type Description
Variable Name character varying The name of the value you wish to return.

Returns

Type Description
character varying The matching character varying value from the public_variable view

set_char_variable(Variable Name, Variable Value)


Description
This is a utility function that allows you to store charater variables for later use. Useful with creating a state in your fleet scripts.

Using this function does not count as an action and can be run as often as you like.

Parameters

Name Type Description
Variable Name character varying The name of the value you wish to return from public_variable
New Value character varying The value of the variable you are setting

Returns

Type Description
character varying The matching character varying value that has just been set

get_numeric_variable(Variable Name)


Description
This utility function simply makes it easier to recall integer values set by your player or the system.

Using this function does not count as an action and can be run as often as you like.

Parameters

Name Type Description
Variable Name character varying The name of the value you wish to return from public_variable

Returns

Type Description
integer The matching integer value from the public_variable view

set_numeric_variable(Variable Name, Numeric Value)


Description
This is a utility function that allows you to store integer values for later use. Useful with creating a state in your fleet scripts.

Using this function does not count as an action and can be run as often as you like.

Parameters

Name Type Description
Variable Name character varying The name of the value you wish to store
Value Integer The new value you wish to be stored

Returns

Type Description
integer The new integer value of the variable.

get_player_id(Player Username)


Description
This utility function performs a lookup of a users player id based on the username given.

Using this function does not count as an action and can be run as often as you like.

Parameters

Name Type Description
Player Username character varying

Returns

Type Description
integer The player id for the username supplied

get_player_username(Player ID)


Description
This utility function performs a lookup of a players username based on the Player ID given.

Using this function does not count as an action and can be run as often as you like.

Parameters

Name Type Description
Player ID integer

Returns

Type Description
character varying The player username for the Player ID supplied

get_player_error_channel(Player Username [DEFAULT SESSION_USER])


Description
This utility function performs a lookup of a users error_channel based on the username given. This information is readily available from my_players but this just makes the lookup easier.

Using this function does not count as an action and can be run as often as you like.

Parameters

Name Type Description
Player Username character varying

Returns

Type Description
character(10) The error channel for the username supplied

get_player_symbol(Player Username | Player ID)


Description
This utility function performs a lookup of a users chosen symbol based on the username or ID given.

Using this function does not count as an action and can be run as often as you like.

Parameters

Name Type Description
Player Username OR Player ID character varying OR Integer

Returns

Type Description
character(1) The player's chosen symbol

get_player_rgb(Player Username | Player ID)


Description
This utility function performs a lookup of a user's chosen colour.

Using this function does not count as an action and can be run as often as you like.

Parameters

Name Type Description
Player Username OR Player ID character varying OR Integer

Returns

Type Description
character(6) The colour chosen by the player

in_range_planet(Ship ID, Planet ID)


Description
This utility function performs a lookup to see if a ship is within range of a specified planet. Helpful to find out if a ship is able to mine a planet during this tic.

Using this function does not count as an action and can be run as often as you like.

Parameters

Name Type Description
Ship ID integer
Planet ID integer

Returns

Type Description
boolean Returns TRUE (t) if the Planet is within range and FALSE (f) if it is not

in_range_ship(Ship ID, Ship ID)


Description
This utility function performs a lookup to see if a ship is within range of another specified ship. Helpful to find out if a ship is able to attack or repair the other ship during this tic.

Using this function does not count as an action and can be run as often as you like.

Parameters

Name Type Description
Ship ID integer
Ship ID integer

Returns

Type Description
boolean Returns TRUE (t) if the Ships are within range and FALSE (f) if they are not

read_event(Event ID)


Description
This utility uses the available data within a row of the event table to convert the information into a readable string of text. Consider the following entry in my_events:

EventID Action player_id_1 ship_id_1 referencing_id descriptor_numeric public
171 MINE_SUCCESS 1 1 1 1879 t

SELECT READ_EVENT(171); will return the following:
(#1)cmdr’s ship (#1)dog has successfully mined 1879 fuel from the planet (#1)Torono"

Using this function does not count as an action and can be run as often as you like.

Parameters

Name Type Description
Event ID integer

Returns

Type Description
Text Returns the text based on the type of action being read and event details

© The Schemaverse 2012