Skip to content

Schemaverse Functions

cbbrowne edited this page Mar 27, 2012 · 25 revisions

Getting around
move
refuel_ship

Actions
attack
mine
repair

Purchasing and Trading
convert_resource
upgrade

Utilities
get_char_variable
get_numeric_variable
get_player_id
get_player_username
get_player_error_channel
in_range_planet
in_range_ship
read_event

move(Ship ID, Speed, Direction, Destination X, Destination Y)

Description
Use this function to move around the map. Each ship can execute the MOVE command once per tic. At the end of a tic, if the ship has not moved, but it has values in my_ships.speed and my_ships.direction then the MOVE command will be executed automatically for it.

It is also important to note that moving will decrease the ships fuel supply when accelerating and when decelerating. Whether you travel 100m away or 1,000,000m away, the fuel cost will be 2x your speed: once to get up to speed, then once to stop at your destination.
In addition, fuel is deducted when changing headings mid-flight at a cost of 1 fuel unit per degree changed mid-flight.

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

Parameters

Name Type Description
Ship ID integer
Speed integer Cannot be greater then my_ships.max_speed
Direction integer Leave this as NULL to have your ship automatically go in the direction required to get to your destination
Destination X integer Use Destination X and Destination Y to tell the system to clear values my_ships.speed and my_ships.direction once the destination is in range. This will stop the ship from moving automatically next turn away from the destination
Destination Y integer

Returns

Type Description
boolean Returns TRUE (t) if the ships move is successful and FALSE (f) if it is not.

If you check out How To Play it describes moving around in a bit more detail.

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 mine_planets(). 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.

At some point I will write a separate wiki page to describe the mining process in a bit more detail.

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 from the public_variable view.

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
character varying The matching character varying value from the public_variable view

get_numeric_variable(Variable Name)

Description
This utility function simply makes it easier to recall integer values from the public_variable view.

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

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

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