Module planet
Functions for planets
Global functions
Planet.all () | returns an iterator over all planets (including stars and moons, so check for flags). |
Planet.getFromName (name) | finds any planet by name |
Class Planet
planet:addMilitaryPresence (clan, diff) | modifies (up or down) military presence for clan. |
planet:addPublicOpinion (clan, diff) | modifies (up or down) public opinion of a clan. |
planet:addTaxLeech (clan, rate) | adds (or updates) a tax leech for the planet. |
planet:areas () | get an iterator over areas on the planet. |
planet:forceEchoRooms () | get the list of rooms with the force.echoPossible dvar. |
planet:getCrime () | returns the crime level of the planet. |
planet:getDescription () | returns the description of the planet. |
planet:getGovernedBy () | returns the clan currently governing the planet. |
planet:getMilitary () | returns the current military funding level of the planet. |
planet:getMilitaryPresence (clan) | returns the current military presence of the given clan on this planet. |
planet:getName () | returns the name of the planet. |
planet:getPoliceAlert () | returns the police alert level of the planet. |
planet:getPopulation () | returns the current population of the planet. |
planet:getPosition () | get the planet's position within system |
planet:getPublicOpinion (clan) | returns the current public opinion of the given clan on this planet. |
planet:getRandomPublicRoom () | tries to find a random public room on this planet. |
planet:getResource (resource) | get the settings for a given resource on this planet. |
planet:getResourceNames () | get the list of resource names bought or sold on this planet. |
planet:getResourcePriceHistory (resource) | get the price history for a given resource on this planet. |
planet:getStarsystem () | get the planet's starsystem |
planet:getTaxLeech (clan) | gets the rate at which a clan is leeching taxes from a planet. |
planet:getTaxModifier () | gets the tax modifier of a planet |
planet:getTaxRate () | returns the tax rate percentage of the planet (0-100). |
planet:hasActiveEvent (eventType) | returns whether the planet currently has the given event running. |
planet:hasFlag (flag) | get whether a flag is set on this planet. |
planet:removeTaxLeech (clan) | removes a tax leech from the planet. |
planet:setCrime (number) | set the crime level of the planet. |
planet:setFlag (flag, value) | set a flag on this planet. |
planet:setMilitary (level) | sets military funding level of the planet. |
planet:setMilitaryPresence (clan, diff) | sets the military presence for a clan. |
planet:setPublicOpinion (clan, diff) | sets the 'special events' public opinion effect for a clan. |
planet:setResourcePrice (resource, curPrice) | set the price of a resource on this planet. |
planet:setTaxLeechExpiration (hours) | sets an automatic expiration for a tax leech |
planet:setTaxModifier (number) | set the tax modifier of a planet (cannot be negative) |
Global functions
- Planet.all ()
-
returns an iterator over all planets (including stars and moons, so check for flags).
Returns:
-
an iterator of Planet
Usage:
for planet in Planet:all() do -- do something end
- Planet.getFromName (name)
-
finds any planet by name
Parameters:
- name string the planet name.
Returns:
-
Planet
the planet, or nil if not found
Class Planet
Functions on planet variables
- planet:addMilitaryPresence (clan, diff)
-
modifies (up or down) military presence for clan.
Parameters:
- clan Clan the clan to modify military presence for.
- diff number the amount to add. Use a negative number to lower presence.
- planet:addPublicOpinion (clan, diff)
-
modifies (up or down) public opinion of a clan.
This always shows in smalltalk under the "Special Events" category.
Parameters:
- clan Clan the clan to modify opinion of.
- diff number the amount to add. Use a negative number to lower opinion.
- planet:addTaxLeech (clan, rate)
-
adds (or updates) a tax leech for the planet.
Parameters:
- clan Clan the clan to establish as the tax leech.
- rate number the percentage of total tax revenue to leech (0.01 to 100.00)
Usage:
-- Have the Crimson Dawn steal 60.25% of the total tax revenue generated by the planet local crimson = Clan.getFromName("Crimson Dawn") planet:addTaxLeech(crimson, 60.25) -- Now update their leech percentage to 20% planet:addTaxLeech(crimson, 20.00)
- planet:areas ()
-
get an iterator over areas on the planet.
Returns:
-
an iterator of Area
Usage:
for area in planet:areas() do -- do something end
- planet:forceEchoRooms ()
-
get the list of rooms with the force.echoPossible dvar.
Returns:
-
table
A table of room vnum ints
Usage:
for _, vnum in ipairs(planet:forceEchoRooms()) do -- do stuff end
- planet:getCrime ()
-
returns the crime level of the planet.
Returns:
-
number
the planet's crime level
- planet:getDescription ()
-
returns the description of the planet.
Returns:
-
string
the planet description
- planet:getGovernedBy ()
-
returns the clan currently governing the planet.
Returns:
-
Clan
the clan who owns the planet, or nil if none is set.
- planet:getMilitary ()
-
returns the current military funding level of the planet.
Returns:
-
number
the planet's current military funding level.
- planet:getMilitaryPresence (clan)
-
returns the current military presence of the given clan on this planet.
Parameters:
- clan Clan the clan to get military presence for.
Returns:
-
number
the clan's current military presence here.
- planet:getName ()
-
returns the name of the planet.
Returns:
-
string
the planet name
- planet:getPoliceAlert ()
-
returns the police alert level of the planet.
Returns:
-
number
the planet's police alert level
- planet:getPopulation ()
-
returns the current population of the planet.
Returns:
-
number
the planet's current population
- planet:getPosition ()
-
get the planet's position within system
Returns:
- number the planet's x coordinate
- number the planet's y coordinate
- number the planet's z coordinate
Usage:
local x, y, z = planet:getPosition()
- planet:getPublicOpinion (clan)
-
returns the current public opinion of the given clan on this planet.
Parameters:
- clan Clan the clan to get opinion of.
Returns:
-
number
the clan's current public opinion here.
- planet:getRandomPublicRoom ()
-
tries to find a random public room on this planet.
This can return any room in any area on the planet which is pathable to a public landing pad or hail point.
Returns:
-
Room
a room if found, or nil if none could be found after 100 attempts
- planet:getResource (resource)
-
get the settings for a given resource on this planet.
Parameters:
- resource string The name of the resource.
Returns:
- number The mode for the resource: "none", "import", or "export"
- number The current price
- number The minimum natural price
- number The maximum natural price
Usage:
local mode, current, min, max = planet:getResource("goods")
- planet:getResourceNames ()
-
get the list of resource names bought or sold on this planet.
Returns:
-
table
A table of resource name strings
Usage:
for _, resName in ipairs(planet:getResourceNames()) do -- do stuff end
- planet:getResourcePriceHistory (resource)
-
get the price history for a given resource on this planet.
The output is a table which indicates the price over each recorded price tick, about 30
minutes apart on average.
Parameters:
- resource string The name of the resource.
Returns:
-
table
A table of resource prices over each recorded price tick
Usage:
for _, price in ipairs(planet:getResourcePriceHistory("goods")) do -- do stuff end
- planet:getStarsystem ()
-
get the planet's starsystem
Returns:
-
Starsystem
the planet's starsystem
- planet:getTaxLeech (clan)
-
gets the rate at which a clan is leeching taxes from a planet.
Parameters:
- clan Clan the clan for which the rate is being sought
Returns:
-
number
the percentage of tax revenue leeched by the clan, or 0 if the clan isn't leeching
Usage:
-- Gets the tax leech clan and amount, or nil and 0 if there is no tax leech local clan = Clan.getFromName("Crimson Dawn") local amt = planet:getTaxLeech(clan)
- planet:getTaxModifier ()
-
gets the tax modifier of a planet
Returns:
-
number
the planet's tax modifier
- planet:getTaxRate ()
-
returns the tax rate percentage of the planet (0-100).
Returns:
-
number
the planet's tax rate
- planet:hasActiveEvent (eventType)
-
returns whether the planet currently has the given event running.
Parameters:
- eventType string The type of event, as a string.
Returns:
-
boolean
True if the event is active, false otherwise.
if planet:hasActiveEvent("holiday") do
ch:say("We're on holiday!")
end
- planet:hasFlag (flag)
-
get whether a flag is set on this planet.
Parameters:
- flag string The flag to check for
Returns:
-
boolean
True if the flag is set, false otherwise
Usage:
if planet:hasFlag("freeport") do ch:echoAt("You can trade cargo here.") end
- planet:removeTaxLeech (clan)
-
removes a tax leech from the planet.
Parameters:
- clan Clan the clan to remove as a tax leech..
Usage:
-- Remove the Crimson Dawn as a tax leech local crimson = Clan.getFromName("Crimson Dawn") planet:removeTaxLeech(crimson)
- planet:setCrime (number)
-
set the crime level of the planet.
Parameters:
- number the new crime level
Usage:
planet:setCrime(planet:getCrime()+10)
- planet:setFlag (flag, value)
-
set a flag on this planet.
Parameters:
- flag string The flag to set
- value boolean The new value to set
Usage:
planet:setFlag("freeport", true)
- planet:setMilitary (level)
-
sets military funding level of the planet.
Parameters:
- level number the new military funding level to set.
- planet:setMilitaryPresence (clan, diff)
-
sets the military presence for a clan.
Parameters:
- clan Clan the clan to set military presence for.
- diff number the new military presence.
- planet:setPublicOpinion (clan, diff)
-
sets the 'special events' public opinion effect for a clan.
This always shows in smalltalk under the "Special Events" category.
Note that the value set here won't be their final opinion.
It will still be modified up or down by other effects on the planet.
Parameters:
- clan Clan the clan to set opinion of.
- diff number the new special events effect amount.
- planet:setResourcePrice (resource, curPrice)
-
set the price of a resource on this planet.
Parameters:
- resource string The name of the resource.
- curPrice number The minimum price
Usage:
-- Set the price of goods to 12.5 and to randomly float around between 10 and 15 over time planet:setResource("goods", 10, 12.5, 15)
- planet:setTaxLeechExpiration (hours)
-
sets an automatic expiration for a tax leech
Parameters:
- hours number the number of hours before the leech expires (or 0 for no expiration)
Usage:
-- Have the Crimson Dawn steal 60.25% of the total tax revenue generated by the planet local crimson = Clan.getFromName("Crimson Dawn") planet:setTaxLeechExpiration(crimson, 72)
- planet:setTaxModifier (number)
-
set the tax modifier of a planet (cannot be negative)
Parameters:
- number the new tax modifier
Usage:
-- Raise the tax modifier by 10% planet:setTaxModifier(planet:getTaxModifier()+0.1)
-- Just double tax revenue planet:setTaxModifier(2.0)