Merge pull request #10832 from VOREStation/Arokha/vendlists

Have vendors be more tidy list-wise
This commit is contained in:
Aronai Sieyes
2021-07-03 17:15:03 -04:00
committed by Chompstation Bot
parent 654ef75433
commit ce296636f7

View File

@@ -36,7 +36,11 @@
var/list/products = list() // For each, use the following pattern:
var/list/contraband = list() // list(/type/path = amount,/type/path2 = amount2)
var/list/premium = list() // No specified amount = only one in stock
/// Set automatically, allows coin use
var/has_premium = FALSE
var/list/prices = list() // Prices for each item, list(/type/path = price), items not in the list don't have a price.
/// Set automatically, enables pricing
var/has_prices = FALSE
// List of vending_product items available.
var/list/product_records = list()
@@ -115,14 +119,23 @@ GLOBAL_LIST_EMPTY(vending_products)
product_records.Add(product)
GLOB.vending_products[entry] = 1
if(LAZYLEN(prices))
has_prices = TRUE
if(LAZYLEN(premium))
has_premium = TRUE
LAZYCLEARLIST(products)
LAZYCLEARLIST(contraband)
LAZYCLEARLIST(premium)
LAZYCLEARLIST(prices)
all_products.Cut()
/obj/machinery/vending/Destroy()
qdel(wires)
wires = null
qdel(coin)
coin = null
for(var/datum/stored_item/vending_product/R in product_records)
qdel(R)
product_records = null
QDEL_NULL_LIST(product_records)
return ..()
/obj/machinery/vending/ex_act(severity)
@@ -171,7 +184,7 @@ GLOBAL_LIST_EMPTY(vending_products)
if(panel_open)
attack_hand(user)
return
else if(istype(W, /obj/item/weapon/coin) && premium.len > 0)
else if(istype(W, /obj/item/weapon/coin) && has_premium)
user.drop_item()
W.forceMove(src)
coin = W
@@ -350,7 +363,7 @@ GLOBAL_LIST_EMPTY(vending_products)
var/list/data = list()
var/list/listed_products = list()
data["chargesMoney"] = length(prices) > 0 ? TRUE : FALSE
data["chargesMoney"] = has_prices ? TRUE : FALSE
for(var/key = 1 to product_records.len)
var/datum/stored_item/vending_product/I = product_records[key]