Naev

Module commodity

Lua bindings to interact with commodities.

This will allow you to create and manipulate commodities in-game.

An example would be:

 c = commodity.get( "Food" ) -- Gets the commodity by name
 if c:price() > 500 then
    -- Do something with high price
 end
 

Functions

__eq (o1, o2) Checks to see if two commodities are the same.
get (s) Gets a commodity.
getStandard () Gets the list of standard commodities.
name (s) Gets the translated name of the commodity.
nameRaw (s) Gets the raw (untranslated) name of the commodity.
price (o) Gets the base price of an commodity.
priceAt (o, p) Gets the base price of an commodity on a certain planet.
priceAtTime (o, p, t) Gets the price of an commodity on a certain planet at a certain time.


Functions

__eq (o1, o2)
Checks to see if two commodities are the same. ( o1, o2 )

Parameters:

  • o1 Commodity First commodity to compare.
  • o2 Commodity Second commodity to compare.

Returns:

    boolean true if both commodities are the same.

Usage:

    if o1 == o2 then -- Checks to see if commodity o1 and o2 are the same
get (s)
Gets a commodity. ( s )

Parameters:

  • s string Raw (untranslated) name of the commodity to get.

Returns:

    Commodity or nil The commodity matching name or nil if error.

Usage:

    s = commodity.get( "Food" ) -- Gets the food commodity
getStandard ()
Gets the list of standard commodities. ()

Returns:

    table A table containing commodity objects, namely those which are standard (buyable/sellable anywhere).
name (s)
Gets the translated name of the commodity.

This translated name should be used for display purposes (e.g. messages). It cannot be used as an identifier for the commodity; for that, use commodity.nameRaw() instead. ( s )

Parameters:

  • s Commodity Commodity to get the translated name of.

Returns:

    string The translated name of the commodity.

Usage:

    commodityname = s:name() -- Equivalent to `_(s:nameRaw())`
nameRaw (s)
Gets the raw (untranslated) name of the commodity.

This untranslated name should be used for identification purposes (e.g. can be passed to commodity.get()). It should not be used directly for display purposes without manually translating it with _(). ( s )

Parameters:

  • s Commodity Commodity to get the raw name of.

Returns:

    string The raw name of the commodity.

Usage:

    commodityrawname = s:nameRaw()
price (o)
Gets the base price of an commodity. ( o )

Parameters:

  • o Commodity Commodity to get information of.

Returns:

    number The base price of the commodity.

Usage:

    print( o:price() ) -- Prints the base price of the commodity
priceAt (o, p)
Gets the base price of an commodity on a certain planet. ( o, p )

Parameters:

  • o Commodity Commodity to get information of.
  • p Planet Planet to get price at.

Returns:

    number The price of the commodity at the planet.

Usage:

    if o:priceAt( planet.get("Polaris Prime") ) > 100 then -- Checks price of an outfit at polaris prime
priceAtTime (o, p, t)
Gets the price of an commodity on a certain planet at a certain time. ( o, p, t )

Parameters:

  • o Commodity Commodity to get information of.
  • p Planet Planet to get price at.
  • t Time Time to get the price at.

Returns:

    number The price of the commodity at the planet.

Usage:

    if o:priceAtTime( planet.get("Polaris Prime"), time ) > 100 then -- Checks price of an outfit at polaris prime
generated by LDoc 1.4.6 Last updated 2020-11-30 07:37:22