![]() |
naev 0.12.6
|
Handles the Lua commodity bindings. More...
#include "nlua_commodity.h"#include "array.h"#include "ndata.h"#include "nlua_faction.h"#include "nlua_spob.h"#include "nlua_system.h"#include "nlua_tex.h"#include "nlua_time.h"#include "nluadef.h"
Go to the source code of this file.
Functions | |
| static int | commodityL_eq (lua_State *L) |
| Checks to see if two commodities are the same. | |
| static int | commodityL_get (lua_State *L) |
| Gets a commodity. | |
| static int | commodityL_getStandard (lua_State *L) |
| Gets the list of standard commodities. | |
| static int | commodityL_flags (lua_State *L) |
| Gets the flags that are set for a commodity. | |
| static int | commodityL_name (lua_State *L) |
| Gets the translated name of the commodity. | |
| static int | commodityL_nameRaw (lua_State *L) |
| Gets the raw (untranslated) name of the commodity. | |
| static int | commodityL_price (lua_State *L) |
| Gets the base price of an commodity. | |
| static int | commodityL_priceAt (lua_State *L) |
| Gets the base price of an commodity on a certain spob. | |
| static int | commodityL_priceAtTime (lua_State *L) |
| Gets the price of an commodity on a certain spob at a certain time. | |
| static int | commodityL_canSell (lua_State *L) |
| Sees if a commodity can be sold at either a spob or system. | |
| static int | commodityL_canBuy (lua_State *L) |
| Sees if a commodity can be bought at either a spob or system. | |
| static int | commodityL_icon (lua_State *L) |
| Gets the store icon of a commodity if it exists. | |
| static int | commodityL_description (lua_State *L) |
| Gets the description of a commodity if it exists. | |
| static int | commodityL_new (lua_State *L) |
| Creates a new temporary commodity. If a temporary commodity with the same name exists, that gets returned instead. "Temporary" is a relative term. The commodity will be saved with the player while it is in the inventory of their fleet. However, when all instances are gone, it will no longer be saved and disappear. | |
| static int | commodityL_illegalto (lua_State *L) |
| Makes a temporary commodity illegal to a faction. | |
| static int | commodityL_illegality (lua_State *L) |
| Gets the factions to which the commodity is illegal to. | |
| int | nlua_loadCommodity (nlua_env env) |
| Loads the commodity library. | |
| Commodity * | lua_tocommodity (lua_State *L, int ind) |
| Lua bindings to interact with commodities. | |
| Commodity * | luaL_checkcommodity (lua_State *L, int ind) |
| Gets commodity at index or raises error if there is no commodity at index. | |
| Commodity * | luaL_validcommodity (lua_State *L, int ind) |
| Makes sure the commodity is valid or raises a Lua error. | |
| Commodity ** | lua_pushcommodity (lua_State *L, Commodity *commodity) |
| Pushes a commodity on the stack. | |
| int | lua_iscommodity (lua_State *L, int ind) |
| Checks to see if ind is a commodity. | |
| static int | spob_hasCommodity (const Commodity *c, const Spob *s) |
Variables | |
| static const luaL_Reg | commodityL_methods [] |
Handles the Lua commodity bindings.
Definition in file nlua_commodity.c.
|
static |
Sees if a commodity can be bought at either a spob or system.
It does not check faction standings, only if it is possible to buy at a spob or a system (checking all spobs in the system).
Lua function parameter: Commodity c Commodity to check. Lua function parameter: Spob|System where Either a spob or a system to see if the commodity is sold there.
| L | Lua State |
Lua function: canBuy
Definition at line 457 of file nlua_commodity.c.
|
static |
Sees if a commodity can be sold at either a spob or system.
It does not check faction standings, only if it is possible to sell at a spob or a system (checking all spobs in the system).
Lua function parameter: Commodity c Commodity to check. Lua function parameter: Spob|System where Either a spob or a system to see if the commodity can be sold there.
| L | Lua State |
Lua function: canSell
Definition at line 419 of file nlua_commodity.c.
|
static |
Gets the description of a commodity if it exists.
Lua function parameter: Commodity c Commodity to get decription of Lua return parameter: string|nil Description of the commodity if exists, otherwise nil.
| L | Lua State |
Lua function: description
Definition at line 504 of file nlua_commodity.c.
|
static |
Checks to see if two commodities are the same.
Lua usage parameter: if o1 == o2 then – Checks to see if commodity o1 and o2 are the same
Lua function parameter: Commodity o1 First commodity to compare. Lua function parameter: Commodity o2 Second commodity to compare. Lua return parameter: boolean true if both commodities are the same.
| L | Lua State |
Lua function: __eq
Definition at line 190 of file nlua_commodity.c.
|
static |
Gets the flags that are set for a commodity.
Lua return parameter: table A table containing the flags as key and value as boolean.
| L | Lua State |
Lua function: flags
Definition at line 255 of file nlua_commodity.c.
|
static |
Gets a commodity.
Lua usage parameter: s = commodity.get( "Food" ) – Gets the food commodity
Lua function parameter: string s Raw (untranslated) name of the commodity to get. Lua return parameter: Commodity|nil The commodity matching name or nil if error.
| L | Lua State |
Lua function: get
Definition at line 211 of file nlua_commodity.c.
|
static |
Gets the list of standard commodities.
Lua return parameter: table A table containing commodity objects, namely those which are standard (buyable/sellable anywhere).
| L | Lua State |
Lua function: getStandard
Definition at line 234 of file nlua_commodity.c.
|
static |
Gets the store icon of a commodity if it exists.
Lua function parameter: Commodity c Commodity to get icon of. Lua return parameter: Texture|nil Texture of the store icon if exists, otherwise nil.
| L | Lua State |
Lua function: icon
Definition at line 487 of file nlua_commodity.c.
|
static |
Gets the factions to which the commodity is illegal to.
Lua function parameter: c Commodity to get illegality status of. Lua return parameter: table Table of all the factions the commodity is illegal to.
| L | Lua State |
Lua function: illegality
Definition at line 598 of file nlua_commodity.c.
|
static |
Makes a temporary commodity illegal to a faction.
Lua function parameter: Commodity c Temporary commodity to make illegal to factions. Lua function parameter: Faction|table f Faction or table of factions to make illegal to.
| L | Lua State |
Lua function: illegalto
Definition at line 574 of file nlua_commodity.c.
|
static |
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.
Lua usage parameter: commodityname = c:name() – Equivalent to _(c:nameRaw())
Lua function parameter: Commodity c Commodity to get the translated name of. Lua return parameter: string The translated name of the commodity.
| L | Lua State |
Lua function: name
Definition at line 285 of file nlua_commodity.c.
|
static |
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 _().
Lua usage parameter: commodityrawname = c:nameRaw()
Lua function parameter: Commodity c Commodity to get the raw name of. Lua return parameter: string The raw name of the commodity.
| L | Lua State |
Lua function: nameRaw
Definition at line 306 of file nlua_commodity.c.
|
static |
Creates a new temporary commodity. If a temporary commodity with the same name exists, that gets returned instead. "Temporary" is a relative term. The commodity will be saved with the player while it is in the inventory of their fleet. However, when all instances are gone, it will no longer be saved and disappear.
Lua usage parameter: commodity.new( N_("Cheesburgers"), N_("I can has cheezburger?") )
Lua function parameter: string cargo Name of the cargo to add. This must not match a cargo name defined in commodity.xml. Lua function parameter: string decription Description of the cargo to add. Lua function parameter:[opt=nil] table params Table of named parameters. Currently supported is "gfx_space". Lua return parameter: Commodity The newly created commodity or an existing temporary commodity with the same name.
| L | Lua State |
Lua function: new
Definition at line 531 of file nlua_commodity.c.
|
static |
Gets the base price of an commodity.
Lua usage parameter: print( c:price() ) – Prints the base price of the commodity
Lua function parameter: Commodity c Commodity to get information of. Lua return parameter: number The base price of the commodity.
| L | Lua State |
Lua function: price
Definition at line 322 of file nlua_commodity.c.
|
static |
Gets the base price of an commodity on a certain spob.
Lua usage parameter: if c:priceAt( spob.get("Polaris Prime") ) > 100 then – Checks price of a commodity at polaris prime
Lua function parameter: Commodity c Commodity to get information of. Lua function parameter: Spob p Spob to get price at. Lua return parameter: number The price of the commodity at the spob.
| L | Lua State |
Lua function: priceAt
Definition at line 340 of file nlua_commodity.c.
|
static |
Gets the price of an commodity on a certain spob at a certain time.
Lua usage parameter: if c:priceAtTime( spob.get("Polaris Prime"), time ) > 100 then – Checks price of a commodity at polaris prime
Lua function parameter: Commodity c Commodity to get information of. Lua function parameter: Spob p Spob to get price at. Lua function parameter: Time t Time to get the price at. Lua return parameter: number The price of the commodity at the spob.
| L | Lua State |
Lua function: priceAtTime
Definition at line 374 of file nlua_commodity.c.
| int lua_iscommodity | ( | lua_State * | L, |
| int | ind ) |
Checks to see if ind is a commodity.
| L | Lua state to check. |
| ind | Index position to check. |
Definition at line 164 of file nlua_commodity.c.
Pushes a commodity on the stack.
| L | Lua state to push commodity into. |
| commodity | Commodity to push. |
Definition at line 149 of file nlua_commodity.c.
| Commodity * lua_tocommodity | ( | lua_State * | L, |
| int | ind ) |
Lua bindings to interact with commodities.
This will allow you to create and manipulate commodities in-game.
An example would be:
Lua module: commodity
Gets commodity at index.
| L | Lua state to get commodity from. |
| ind | Index position to find the commodity. |
Definition at line 98 of file nlua_commodity.c.
| Commodity * luaL_checkcommodity | ( | lua_State * | L, |
| int | ind ) |
Gets commodity at index or raises error if there is no commodity at index.
| L | Lua state to get commodity from. |
| ind | Index position to find commodity. |
Definition at line 110 of file nlua_commodity.c.
| Commodity * luaL_validcommodity | ( | lua_State * | L, |
| int | ind ) |
Makes sure the commodity is valid or raises a Lua error.
| L | State currently running. |
| ind | Index of the commodity to validate. |
Definition at line 124 of file nlua_commodity.c.
| int nlua_loadCommodity | ( | nlua_env | env | ) |
Loads the commodity library.
| env | Environment to load commodity library into. |
Definition at line 70 of file nlua_commodity.c.
Definition at line 397 of file nlua_commodity.c.
|
static |
Commodity metatable methods.
Definition at line 44 of file nlua_commodity.c.