Class ITEM.base_spawnable

Spawnable Item Base. The spawnable item base is used for items which can be used to produce an in-world entity. Therefore, this base defines helpers for common functions, such as setting maximum spawn distance.

Class Overview

Hooks

ITEM.base_spawnable.canUse(ply) Checks if a item can be used.
ITEM.base_spawnable.canGive(ply, to, amt) Checks if a item can be given.
ITEM.base_spawnable.canRemove(ply) Checks if a item can be removed.
ITEM.base_spawnable.canDrop(ply, pos, amt) Checks if a item can be dropped.
ITEM.base_spawnable.canDestroy(ply, amt) Checks if a item can be destroyed.
ITEM.base_spawnable.canPickup(ply) Checks if a item can be picked up.
ITEM.base_spawnable.canSell(ply, amt) Checks if a item can be sold up.
ITEM.base_spawnable.canPlace(ply, pos, amt) Checks if a item can be placed.

Fields

ITEM.base_spawnable.name Item Name.
ITEM.base_spawnable.description Description of the item.
ITEM.base_spawnable.size Item Size
ITEM.base_spawnable.cost Item Cost
ITEM.base_spawnable.model Model Path
ITEM.base_spawnable.store Market Availability
ITEM.base_spawnable.category Inventory / Market Category
ITEM.base_spawnable.skin Skin used in the F1 menu.
ITEM.base_spawnable.__index The lookup index for the item metatable.

Methods

ITEM.base_spawnable:SetMaxSpawnDist(data) Set the maximum distance away that this item can be spawned.
ITEM.base_spawnable:SetAutoOwner(data) Sets if the spawned entity is automatically owned by the player for prop protection.
ITEM.base_spawnable:SetClass(data) Sets the SENT ID which this item spawns.
ITEM.base_spawnable:SetLimiter(data) Sets the Limter class which limits the total count of this item.
ITEM.base_spawnable:SetInvLimited(data) Sets if this item is limited by the number of items currently available in the inventory.
ITEM.base_spawnable:SetLimit(data) Sets if a limited number of these items can be spawned.
ITEM.base_spawnable:SetSingleUse(data) Sets if this item is single use (removed from the inventory after placing)
ITEM.base_spawnable:canReduce(ply, action[, count=1]) Checks if a player can reduce the number of items in their inventory.
ITEM.base_spawnable:New(base, data) Create a new item.
ITEM.base_spawnable:Clone() Clone an item.
ITEM.base_spawnable:Merge(data) Merge a table of data into the item.
ITEM.base_spawnable:SetData(name, value) Set a single key on the item.
ITEM.base_spawnable:Register([id]) Register an item.
ITEM.base_spawnable:AutoFunction(name, key) Creates an automatically named setter function.
ITEM.base_spawnable:SetCost(cost) Sets the Market Cost.
ITEM.base_spawnable:SetPrice(data) Alias of ITEM:SetCost
ITEM.base_spawnable:SetDescription(data) Sets the Description of an item.
ITEM.base_spawnable:SetDesc(data) Alias of ITEM:SetDescription
ITEM.base_spawnable:SetCategory(data) Sets the category of an item.
ITEM.base_spawnable:SetCat(data) Alias of ITEM:SetCategory
ITEM.base_spawnable:SetTeam(data) Sets the team of an item.
ITEM.base_spawnable:SetBatch(data) Sets the number of items created in a press of the manufacture button.
ITEM.base_spawnable:SetMember(data) Sets the required membership level to use this item.
ITEM.base_spawnable:SetREPs(data) Sets the required REP count to use this item.
ITEM.base_spawnable:SetREP(data) Alias of ITEM:SetREPs
ITEM.base_spawnable:SetCanUse(data) Sets the canUse function on this item.
ITEM.base_spawnable:SetSize(data) Sets the inventory size of this item.
ITEM.base_spawnable:SetName(name[, Plural=s]) Sets the name of an item.
ITEM.base_spawnable:SetModel(model, skin[, Should]) Sets the model of the item.
ITEM.base_spawnable:SetStoreModel(model, skin) Sets the store model of the item.
ITEM.base_spawnable:SetStoreSkin(skin[, autoStore]) Sets the store skin of the item.
ITEM.base_spawnable:SetPlural([name]) Sets the item's plural.
ITEM.base_spawnable:SetStore(val) Set if the item is in store, and its batch amount.
ITEM.base_spawnable:Replaced([by]) Sets if a item is replaced.
ITEM.base_spawnable:Replacement(new, old) Create a simple replacement item.
ITEM.base_spawnable:CanUse(func) Sets the canUse function for this item.
ITEM.base_spawnable:OnUse(func) Sets the onUse function for this item.
ITEM.base_spawnable:CanGive(func) Sets the canGive function for this item.
ITEM.base_spawnable:OnGive(func) Sets the onGive function for this item.
ITEM.base_spawnable:CanRemove(func) Sets the canRemove function for this item.
ITEM.base_spawnable:OnRemove(func) Sets the onRemove function for this item.
ITEM.base_spawnable:CanDrop(func) Sets the canDrop function for this item.
ITEM.base_spawnable:OnDrop(func) Sets the onDrop function for this item.
ITEM.base_spawnable:CanDestroy(func) Sets the canDestroy function for this item.
ITEM.base_spawnable:OnDestroy(func) Sets the onDestroy function for this item.
ITEM.base_spawnable:CanPickup(func) Sets the canPickup function for this item.
ITEM.base_spawnable:OnPickup(func) Sets the onPickup function for this item.
ITEM.base_spawnable:CanSell(func) Sets the canSell function for this item.
ITEM.base_spawnable:OnSell(func) Sets the onSell function for this item.
ITEM.base_spawnable:CanPlace(func) Sets the canPlace function for this item.
ITEM.base_spawnable:onPlace(func) Sets the onPlace function for this item.

Hooks

ITEM.base_spawnable.canUse(ply)
Checks if a item can be used.

Parameters:

  • ply Player Player using the item.

Inhereted from:

ITEM.base_spawnable.canGive(ply, to, amt)
Checks if a item can be given.

Parameters:

  • ply Player Player giving the item.
  • to Player Player receiving the item.
  • amt int Number of items being given.

Inhereted from:

ITEM.base_spawnable.canRemove(ply)
Checks if a item can be removed.

Parameters:

  • ply Player Player removing the item.

Inhereted from:

ITEM.base_spawnable.canDrop(ply, pos, amt)
Checks if a item can be dropped.

Parameters:

  • ply Player Player dropping the item.
  • pos Vector Drop location.
  • amt int Number of items being dropped.

Inhereted from:

ITEM.base_spawnable.canDestroy(ply, amt)
Checks if a item can be destroyed.

Parameters:

  • ply Player Player destroying the item.
  • amt int Number of items being destroyed.

Inhereted from:

ITEM.base_spawnable.canPickup(ply)
Checks if a item can be picked up.

Parameters:

  • ply Player Player picking the items up.

Inhereted from:

ITEM.base_spawnable.canSell(ply, amt)
Checks if a item can be sold up.

Parameters:

  • ply Player Player selling items.
  • amt int Number of items being sold.

Inhereted from:

ITEM.base_spawnable.canPlace(ply, pos, amt)
Checks if a item can be placed.

Parameters:

  • ply Player Player placing items.
  • pos Vector Place location.
  • amt int Number of items being placed.

Inhereted from:

Fields

ITEM.base_spawnable.name
Item Name.
  • name string The localised name, as shown in the F1 menu.

Inhereted from:

ITEM.base_spawnable.description
Description of the item.

Inhereted from:

ITEM.base_spawnable.size
Item Size
  • size number The inventory space used per item.

Inhereted from:

ITEM.base_spawnable.cost
Item Cost
  • cost int The cost of the item as bought in the market. Also used for inventory valuations and refund sales.

Inhereted from:

ITEM.base_spawnable.model
Model Path
  • model string Path of the model used in the F1 menu / dropped states.

Inhereted from:

ITEM.base_spawnable.store
Market Availability
  • store bool

Inhereted from:

ITEM.base_spawnable.category
Inventory / Market Category

Inhereted from:

ITEM.base_spawnable.skin
Skin used in the F1 menu.
  • skin int

Inhereted from:

ITEM.base_spawnable.__index
The lookup index for the item metatable.

Inhereted from:

Methods

ITEM.base_spawnable:SetMaxSpawnDist(data)
Set the maximum distance away that this item can be spawned.

Parameters:

  • data int Maximum distance.

Returns:

    ITEM
ITEM.base_spawnable:SetAutoOwner(data)
Sets if the spawned entity is automatically owned by the player for prop protection.

Parameters:

  • data bool If the owner should be set.

Returns:

    ITEM
ITEM.base_spawnable:SetClass(data)
Sets the SENT ID which this item spawns.

Parameters:

Returns:

    ITEM
ITEM.base_spawnable:SetLimiter(data)
Sets the Limter class which limits the total count of this item. When set, spawning calls ply:GetCount(data). Could be more aptly defined as SetCounter.

Parameters:

Returns:

    ITEM
ITEM.base_spawnable:SetInvLimited(data)
Sets if this item is limited by the number of items currently available in the inventory. See fire alarms for example.

Parameters:

  • data bool Inventory limited?

Returns:

    ITEM
ITEM.base_spawnable:SetLimit(data)
Sets if a limited number of these items can be spawned. See fire alarms for example.

Parameters:

  • data function or int Numeric limit, or function(item, ply) which returns a number.

Returns:

    ITEM
ITEM.base_spawnable:SetSingleUse(data)
Sets if this item is single use (removed from the inventory after placing)

Parameters:

  • data bool Single Use?

Returns:

    ITEM
ITEM.base_spawnable:canReduce(ply, action[, count=1])
Checks if a player can reduce the number of items in their inventory.

Parameters:

  • ply Player Player reducing.
  • action string The action they're taking (giving, dropping, etc)
  • count int The number of items being removed. (default 1)

Returns:

  1. bool If the reduction was allowed.
  2. optional string Error message if reduction failed.
ITEM.base_spawnable:New(base, data)
Create a new item.

Parameters:

  • base string UniqueID of the baseclass.
  • data tab Optional data to fill into the item.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:Clone()
Clone an item. Returns a new ITEM, with base set to the first item.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:Merge(data)
Merge a table of data into the item.

Parameters:

  • data tab Key/Value pairs of data.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:SetData(name, value)
Set a single key on the item.

Parameters:

  • name string Key to set.
  • value Value to set.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:Register([id])
Register an item. This must be the last call in an item chain, as it does processing on the item.

Parameters:

  • id string UniqueID to set, not required if set prior. (optional)

Inhereted from:

ITEM.base_spawnable:AutoFunction(name, key)
Creates an automatically named setter function. It also returns a single param function, which sets a default value and returns the item.

Parameters:

  • name string Function Key (Resolves to Set).
  • key string Internal key to set.

Returns:

    function

Inhereted from:

See also:

Usage:

    local setDefault = ITEM:AutoFunction("SpecialValue", "internal_flag")
    -- This creates a function, ITEM:SetSpecialValue().
    -- Calling this function sets a value on ITEM.internal_flag.
    -- Calling setDefault, sets the value now, returning the item. This is useful for chaining.
    ITEM:AutoFunction("SomeValue", "this_defaults_to_false")(false)
ITEM.base_spawnable:SetCost(cost)
Sets the Market Cost.

Parameters:

  • cost int Cost.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:SetPrice(data)
Alias of ITEM:SetCost

Parameters:

  • data int Cost.

Returns:

    ITEM

Inhereted from:

See also:

ITEM.base_spawnable:SetDescription(data)
Sets the Description of an item.

Parameters:

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:SetDesc(data)
Alias of ITEM:SetDescription

Parameters:

Returns:

    ITEM

Inhereted from:

See also:

ITEM.base_spawnable:SetCategory(data)
Sets the category of an item.

Parameters:

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:SetCat(data)
Alias of ITEM:SetCategory

Parameters:

Returns:

    ITEM

Inhereted from:

See also:

ITEM.base_spawnable:SetTeam(data)
Sets the team of an item.

Parameters:

  • data int Team Index

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:SetBatch(data)
Sets the number of items created in a press of the manufacture button.

Parameters:

  • data int Batch

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:SetMember(data)
Sets the required membership level to use this item.

Parameters:

  • data int Membership Level

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:SetREPs(data)
Sets the required REP count to use this item.

Parameters:

  • data int REP Count

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:SetREP(data)
Alias of ITEM:SetREPs

Parameters:

Returns:

    ITEM

Inhereted from:

See also:

ITEM.base_spawnable:SetCanUse(data)
Sets the canUse function on this item.

Parameters:

  • data func canUse function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:SetSize(data)
Sets the inventory size of this item.

Parameters:

  • data int Size

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:SetName(name[, Plural=s])
Sets the name of an item. If plural is undefined, defaults to "s" If plural is true, it's set to ""

Parameters:

Inhereted from:

ITEM.base_spawnable:SetModel(model, skin[, Should])
Sets the model of the item. If model is true, the model and skin will be pulled from the store model. If autostore is true, model and skin will be pushed to the store model.

Parameters:

  • model string or true Model path.
  • skin int Skin index.
  • Should bool this also automatically set the store models. (optional)

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:SetStoreModel(model, skin)
Sets the store model of the item. If model is true, the model and skin will be pulled from the regular model.

Parameters:

  • model string or true Model path.
  • skin int Skin index.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:SetStoreSkin(skin[, autoStore])
Sets the store skin of the item. If skin is true, it is pulled from the item skin.

Parameters:

  • skin int or true skin
  • autoStore bool If skin should be pushed to item skin. (optional)

Inhereted from:

ITEM.base_spawnable:SetPlural([name])
Sets the item's plural. If nil/false, item's name + s is used. If true, item's name is used. Otherwise passed name is used.

Parameters:

  • name string or true (optional)

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:SetStore(val)
Set if the item is in store, and its batch amount. If boolean, store is directly set. If 0, store is set to false. Otherwise store is set true and the value

Parameters:

  • val bool or int Store Setting / Batch Amount

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:Replaced([by])
Sets if a item is replaced. If called with no args, replaced flag is cleared.

Parameters:

  • by string Unique ID of replaced item. (optional)

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:Replacement(new, old)
Create a simple replacement item. new's item must be registered before the replacement call.

Parameters:

  • new string Unique ID of the replacement.
  • old string Unique ID of the old item.

Inhereted from:

ITEM.base_spawnable:CanUse(func)
Sets the canUse function for this item.

Parameters:

  • func func [opt=function() return true end] Function to set as the canUse function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:OnUse(func)
Sets the onUse function for this item.

Parameters:

  • func func Function to set as the onUse function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:CanGive(func)
Sets the canGive function for this item.

Parameters:

  • func func [opt=function() return true end] Function to set as the canGive function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:OnGive(func)
Sets the onGive function for this item.

Parameters:

  • func func Function to set as the onGive function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:CanRemove(func)
Sets the canRemove function for this item.

Parameters:

  • func func [opt=function() return true end] Function to set as the canRemove function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:OnRemove(func)
Sets the onRemove function for this item.

Parameters:

  • func func Function to set as the onRemove function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:CanDrop(func)
Sets the canDrop function for this item.

Parameters:

  • func func [opt=function() return true end] Function to set as the canDrop function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:OnDrop(func)
Sets the onDrop function for this item.

Parameters:

  • func func Function to set as the onDrop function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:CanDestroy(func)
Sets the canDestroy function for this item.

Parameters:

  • func func [opt=function() return true end] Function to set as the canDestroy function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:OnDestroy(func)
Sets the onDestroy function for this item.

Parameters:

  • func func Function to set as the onDestroy function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:CanPickup(func)
Sets the canPickup function for this item.

Parameters:

  • func func [opt=function() return true end] Function to set as the canPickup function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:OnPickup(func)
Sets the onPickup function for this item.

Parameters:

  • func func Function to set as the onPickup function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:CanSell(func)
Sets the canSell function for this item.

Parameters:

  • func func [opt=function() return true end] Function to set as the canSell function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:OnSell(func)
Sets the onSell function for this item.

Parameters:

  • func func Function to set as the onSell function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:CanPlace(func)
Sets the canPlace function for this item.

Parameters:

  • func func [opt=function() return true end] Function to set as the canPlace function.

Returns:

    ITEM

Inhereted from:

ITEM.base_spawnable:onPlace(func)
Sets the onPlace function for this item.

Parameters:

  • func func Function to set as the onPlace function.

Returns:

    ITEM

Inhereted from: