/tg/ Station 13 - Modules - TypesVar Details - Proc Details

vending machines

Captalism in the year 2525, everything in a vending machine, even love

Vars

ad_listList of ads built from product_ads upon Iniitialize()
age_restrictionsWhether our age check is currently functional
all_products_freeIf this is set to TRUE, all products sold by the vending machine are free (cost nothing). If unset, this will get automatically set to TRUE during init if the machine originates from off-station during mapload. Defaults to null, set it to TRUE or FALSE explicitly on a per-machine basis if you want to force it to be a certain value.
allow_customWhether this vendor can be selected when building a custom vending machine
coin_recordsList of premium product records
contrabandList of products this machine sells when you hack it
credits_containedHow many credits does this vending machine have? 20% of all sales go to this pool, and are given freely when the machine is restocked, or successfully tilted. Lost on deconstruction.
crit_chanceThe chance, in percent, of this vendor performing a critical hit on anything it crushes via [tilt].
default_priceDefault price of items if not overridden
displayed_currency_iconfontawesome icon name to use in to display the user's balance in the vendor UI
displayed_currency_nameString of the used currency to display in the vendor UI
extended_inventorycan we access the hidden inventory?
extra_priceDefault price of premium items if not overridden
hidden_recordsList of contraband product records
icon_denyIcon to flash when user is denied a vend
icon_vendIcon when vending an item to the user
last_replyLast world tick we sent a vent reply
last_shopperThe ref of the last mob to shop with us
last_sloganLast world tick we sent a slogan message out
light_maskName of lighting mask for the vending machine
onstationIs this item on station or not
onstation_overrideDO NOT APPLY THIS GLOBALLY. For mapping var edits only. A variable to change on a per instance basis that allows the instance to avoid having onstation set for them during mapload. Setting this to TRUE means that the vending machine is treated as if it were still onstation if it spawns off-station during mapload. Useful to specify an off-station machine that will be affected by machine-brand intelligence for whatever reason.
panel_typeIcon for the maintenance panel overlay
pinned_mobsList of mobs stuck under the vendor
premiumList of premium products this machine sells
product_adsString of small ad messages in the vending screen - random chance
product_categoriesList of products this machine sells, categorized. Can only be used as an alternative to products, not alongside it.
product_recordsList of standard product records
product_slogansString of slogans separated by semicolons, optional
productsList of products this machine sells
purchase_message_cooldownNext world time to send a purchase message
scan_idAre we checking the users ID
seconds_electrifiedWorld ticks the machine is electified for
shoot_inventoryWhen this is TRUE, we fire items at customers! We're broken!
shoot_inventory_chanceHow likely this is to happen (prob 100) per second
slogan_delayHow many ticks until we can send another
slogan_listList of slogans to scream at potential customers; built upon Iniitialize() of the vendor from product_slogans
squish_damageDamage this vendor does when tilting onto an atom
tiltableWhether this vendor can be tilted over or not
tiltedWhether the vendor is tilted or not
tilted_rotationIf tilted, this variable should always be the rotation that was applied when we were tilted. Stored for the purposes of unapplying it.
vend_replyMessage sent post vend (Thank you for shopping!)

Procs

InitializeInitialize the vending machine
_vend_greyscaleVends a greyscale modified item. arguments: menu - greyscale config menu that has been used to vend the item
build_inventoriesBuilds all available inventories for the vendor - standard, contraband and premium
build_inventoryBuild the inventory of the vending machine from its product and record lists
canLoadItemAre we able to load the item passed in
collect_records_for_static_dataReturns a list of given product records of the vendor to be used in UI. arguments: records - list of records available categories - list of categories available premium - bool of whether a record should be priced by a custom/premium price or not
compartmentLoadAccessCheckIs the passed in user allowed to load this vending machines compartments? This only is ran if we are using a /obj/item/storage/bag to load the vending machine, and not a dedicated restocker.
dispenseCommon proc that dispenses an item. Called when the item is vended, or gotten some other way.
fetch_balance_to_useReturns the balance that the vendor will use for proceeding payment. Most vendors would want to use the user's card's account credits balance. arguments: passed_id - the id card that will be billed for the product
freebieDispenses free items from the standard stock.
loadingAttemptTries to insert the item into the vendor, and depending on whether the product is a part of the vendor's stock or not, increments an already present product entry's available amount or creates a new entry. arguments: inserted_item - the item we're trying to insert user - mob who's trying to insert the item
on_dispenseA proc meant to perform custom behavior on newly dispensed items.
post_restockAfter-effects of refilling a vending machine from a refill canister
pre_throwA callback called before an item is tossed out
proceed_paymentHandles payment processing: discounts, logging, balance change etc. arguments: paying_id_card - the id card that will be billed for the product. mob_paying - the mob that is trying to purchase the item. product_to_vend - the product record of the item we're trying to vend. price_to_use - price of the item we're trying to vend. discountless - whether or not to apply discounts
reset_pricesReassign the prices of the vending machine as a result of the inflation value, as provided by SSeconomy
restockRefill a vending machine from a refill canister
shockShock the passed in user
speakSpeak the given message verbally Checks if the machine is powered and the message exists
throw_impactCrush the mob that the vending machine got thrown at
throw_itemThrow an item from our internal inventory out in front of us
tiltTilts ontop of the atom supplied, if crit is true some extra shit can happen. See [fall_and_crush] for return values. Arguments: fatty - atom to tilt the vendor onto local_crit_chance - percent chance of a critical hit forced_crit - specific critical hit case to use, if any range - the range of the machine when thrown if not adjacent
total_stockReturns the total loaded & max amount of items i.e list(total_loaded, total_maximum) in the vending machine based on the product records and premium records
untiltRights the vendor up, unpinning mobs under it, if any. Arguments: user - mob that has untilted the vendor
vendThe entire shebang of vending the picked item. Processes the vending and initiates the payment for the item. arguments: greyscale_colors - greyscale config for the item we're about to vend, if any

Var Details

ad_list

List of ads built from product_ads upon Iniitialize()

age_restrictions

Whether our age check is currently functional

all_products_free

If this is set to TRUE, all products sold by the vending machine are free (cost nothing). If unset, this will get automatically set to TRUE during init if the machine originates from off-station during mapload. Defaults to null, set it to TRUE or FALSE explicitly on a per-machine basis if you want to force it to be a certain value.

allow_custom

Whether this vendor can be selected when building a custom vending machine

coin_records

List of premium product records

contraband

List of products this machine sells when you hack it

form should be list(/type/path = amount, /type/path2 = amount2)

credits_contained

How many credits does this vending machine have? 20% of all sales go to this pool, and are given freely when the machine is restocked, or successfully tilted. Lost on deconstruction.

crit_chance

The chance, in percent, of this vendor performing a critical hit on anything it crushes via [tilt].

default_price

Default price of items if not overridden

displayed_currency_icon

fontawesome icon name to use in to display the user's balance in the vendor UI

displayed_currency_name

String of the used currency to display in the vendor UI

extended_inventory

can we access the hidden inventory?

extra_price

Default price of premium items if not overridden

hidden_records

List of contraband product records

icon_deny

Icon to flash when user is denied a vend

icon_vend

Icon when vending an item to the user

last_reply

Last world tick we sent a vent reply

last_shopper

The ref of the last mob to shop with us

last_slogan

Last world tick we sent a slogan message out

light_mask

Name of lighting mask for the vending machine

onstation

Is this item on station or not

if it doesn't originate from off-station during mapload, all_products_free gets automatically set to TRUE if it was unset previously. if it's off-station during mapload, it's also safe from the brand intelligence event

onstation_override

DO NOT APPLY THIS GLOBALLY. For mapping var edits only. A variable to change on a per instance basis that allows the instance to avoid having onstation set for them during mapload. Setting this to TRUE means that the vending machine is treated as if it were still onstation if it spawns off-station during mapload. Useful to specify an off-station machine that will be affected by machine-brand intelligence for whatever reason.

panel_type

Icon for the maintenance panel overlay

pinned_mobs

List of mobs stuck under the vendor

premium

List of premium products this machine sells

form should be list(/type/path = amount, /type/path2 = amount2)

product_ads

String of small ad messages in the vending screen - random chance

product_categories

List of products this machine sells, categorized. Can only be used as an alternative to products, not alongside it.

Form should be list( "name" = "Category Name", "icon" = "UI Icon (Font Awesome or tgfont)", "products" = list(/type/path = amount, ...), )

product_records

List of standard product records

product_slogans

String of slogans separated by semicolons, optional

products

List of products this machine sells

form should be list(/type/path = amount, /type/path2 = amount2)

purchase_message_cooldown

Next world time to send a purchase message

scan_id

Are we checking the users ID

seconds_electrified

World ticks the machine is electified for

shoot_inventory

When this is TRUE, we fire items at customers! We're broken!

shoot_inventory_chance

How likely this is to happen (prob 100) per second

slogan_delay

How many ticks until we can send another

slogan_list

List of slogans to scream at potential customers; built upon Iniitialize() of the vendor from product_slogans

squish_damage

Damage this vendor does when tilting onto an atom

tiltable

Whether this vendor can be tilted over or not

tilted

Whether the vendor is tilted or not

tilted_rotation

If tilted, this variable should always be the rotation that was applied when we were tilted. Stored for the purposes of unapplying it.

vend_reply

Message sent post vend (Thank you for shopping!)

Proc Details

Initialize

Initialize the vending machine

Builds the vending machine inventory, sets up slogans and other such misc work

This also sets the onstation var to:

_vend_greyscale

Vends a greyscale modified item. arguments: menu - greyscale config menu that has been used to vend the item

build_inventories

Builds all available inventories for the vendor - standard, contraband and premium

Arguments start_empty - bool to pass into build_inventory that determines whether a product entry starts with available stock or not

build_inventory

Build the inventory of the vending machine from its product and record lists

This builds up a full set of /datum/data/vending_products from the product list of the vending machine type Arguments:

canLoadItem

Are we able to load the item passed in

Arguments:

collect_records_for_static_data

Returns a list of given product records of the vendor to be used in UI. arguments: records - list of records available categories - list of categories available premium - bool of whether a record should be priced by a custom/premium price or not

compartmentLoadAccessCheck

Is the passed in user allowed to load this vending machines compartments? This only is ran if we are using a /obj/item/storage/bag to load the vending machine, and not a dedicated restocker.

Arguments:

dispense

Common proc that dispenses an item. Called when the item is vended, or gotten some other way.

Arguments

fetch_balance_to_use

Returns the balance that the vendor will use for proceeding payment. Most vendors would want to use the user's card's account credits balance. arguments: passed_id - the id card that will be billed for the product

freebie

Dispenses free items from the standard stock.

Arguments: freebies - number of free items to vend

loadingAttempt

Tries to insert the item into the vendor, and depending on whether the product is a part of the vendor's stock or not, increments an already present product entry's available amount or creates a new entry. arguments: inserted_item - the item we're trying to insert user - mob who's trying to insert the item

on_dispense

A proc meant to perform custom behavior on newly dispensed items.

Arguments

post_restock

After-effects of refilling a vending machine from a refill canister

This takes the amount of products restocked and gives the user our contained credits if needed, sending the user a fitting message.

Arguments:

pre_throw

A callback called before an item is tossed out

Override this if you need to do any special case handling

Arguments:

proceed_payment

Handles payment processing: discounts, logging, balance change etc. arguments: paying_id_card - the id card that will be billed for the product. mob_paying - the mob that is trying to purchase the item. product_to_vend - the product record of the item we're trying to vend. price_to_use - price of the item we're trying to vend. discountless - whether or not to apply discounts

reset_prices

Reassign the prices of the vending machine as a result of the inflation value, as provided by SSeconomy

This rebuilds both /datum/data/vending_products lists for premium and standard products based on their most relevant pricing values. Arguments:

restock

Refill a vending machine from a refill canister

This takes the products from the refill canister and then fills the products, contraband and premium product categories

Arguments:

shock

Shock the passed in user

This checks we have power and that the passed in prob is passed, then generates some sparks and calls electrocute_mob on the user

Arguments:

speak

Speak the given message verbally Checks if the machine is powered and the message exists

Arguments:

throw_impact

Crush the mob that the vending machine got thrown at

throw_item

Throw an item from our internal inventory out in front of us

This is called when we are hacked, it selects a random product from the records that has an amount > 0 This item is then created and tossed out in front of us with a visible message

tilt

Tilts ontop of the atom supplied, if crit is true some extra shit can happen. See [fall_and_crush] for return values. Arguments: fatty - atom to tilt the vendor onto local_crit_chance - percent chance of a critical hit forced_crit - specific critical hit case to use, if any range - the range of the machine when thrown if not adjacent

total_stock

Returns the total loaded & max amount of items i.e list(total_loaded, total_maximum) in the vending machine based on the product records and premium records

Arguments

untilt

Rights the vendor up, unpinning mobs under it, if any. Arguments: user - mob that has untilted the vendor

vend

The entire shebang of vending the picked item. Processes the vending and initiates the payment for the item. arguments: greyscale_colors - greyscale config for the item we're about to vend, if any