mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Brings vending machine datums under a subtype of smartfridge datums.
This commit is contained in:
58
code/datums/vending/stored_item.dm
Normal file
58
code/datums/vending/stored_item.dm
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Datum that holds the instances and information about the items stored. Currently used in SmartFridges and Vending Machines.
|
||||||
|
*/
|
||||||
|
/datum/stored_item
|
||||||
|
var/item_name = "name" //Name of the item(s) displayed
|
||||||
|
var/item_path = null
|
||||||
|
var/amount = 0
|
||||||
|
var/list/instances //What items are actually stored
|
||||||
|
var/stored //The thing holding it is
|
||||||
|
|
||||||
|
/datum/stored_item/New(var/stored, var/path, var/name = null, var/amount = 0)
|
||||||
|
src.item_path = path
|
||||||
|
|
||||||
|
if(!name)
|
||||||
|
var/atom/tmp = path
|
||||||
|
src.item_name = initial(tmp.name)
|
||||||
|
else
|
||||||
|
src.item_name = name
|
||||||
|
|
||||||
|
src.amount = amount
|
||||||
|
src.stored = stored
|
||||||
|
|
||||||
|
..()
|
||||||
|
|
||||||
|
/datum/stored_item/Destroy()
|
||||||
|
stored = null
|
||||||
|
if(instances)
|
||||||
|
for(var/product in instances)
|
||||||
|
qdel(product)
|
||||||
|
instances.Cut()
|
||||||
|
. = ..()
|
||||||
|
|
||||||
|
/datum/stored_item/proc/get_amount()
|
||||||
|
return instances ? instances.len : amount
|
||||||
|
|
||||||
|
/datum/stored_item/proc/get_product(var/product_location)
|
||||||
|
if(!get_amount() || !product_location)
|
||||||
|
return
|
||||||
|
init_products()
|
||||||
|
|
||||||
|
var/atom/movable/product = instances[instances.len] // Remove the last added product
|
||||||
|
instances -= product
|
||||||
|
product.forceMove(product_location)
|
||||||
|
|
||||||
|
/datum/stored_item/proc/add_product(var/atom/movable/product)
|
||||||
|
if(product.type != item_path)
|
||||||
|
return 0
|
||||||
|
init_products()
|
||||||
|
product.forceMove(stored)
|
||||||
|
instances += product
|
||||||
|
|
||||||
|
/datum/stored_item/proc/init_products()
|
||||||
|
if(instances)
|
||||||
|
return
|
||||||
|
instances = list()
|
||||||
|
for(var/i = 1 to amount)
|
||||||
|
var/new_product = new item_path(stored)
|
||||||
|
instances += new_product
|
||||||
13
code/datums/vending/vending.dm
Normal file
13
code/datums/vending/vending.dm
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Datum used to hold further information about a product in a vending machine
|
||||||
|
*/
|
||||||
|
/datum/stored_item/vending_product
|
||||||
|
var/price = 0 // Price to buy one
|
||||||
|
var/display_color = null // Display color for vending machine listing
|
||||||
|
var/category = CAT_NORMAL // CAT_HIDDEN for contraband, CAT_COIN for premium
|
||||||
|
|
||||||
|
/datum/stored_item/vending_product/New(var/stored, var/path, var/name = null, var/amount = 1, var/price = 0, var/color = null, var/category = CAT_NORMAL)
|
||||||
|
..(stored, path, name, amount)
|
||||||
|
src.price = price
|
||||||
|
src.display_color = color
|
||||||
|
src.category = category
|
||||||
@@ -1,63 +1,3 @@
|
|||||||
/*
|
|
||||||
* Datum that holds the instances and information about the items in the smartfridge.
|
|
||||||
*/
|
|
||||||
/datum/data/stored_item
|
|
||||||
var/item_name = "name" //Name of the item(s) displayed
|
|
||||||
var/item_path = null
|
|
||||||
var/amount = 0
|
|
||||||
var/list/instances //What items are actually stored
|
|
||||||
var/fridge //The attatched fridge
|
|
||||||
|
|
||||||
/datum/data/stored_item/New(var/fridge, var/path, var/name = null, var/amount = 0)
|
|
||||||
..()
|
|
||||||
|
|
||||||
src.item_path = path
|
|
||||||
|
|
||||||
if(!name)
|
|
||||||
var/atom/tmp = path
|
|
||||||
src.item_name = initial(tmp.name)
|
|
||||||
else
|
|
||||||
src.item_name = name
|
|
||||||
|
|
||||||
src.amount = amount
|
|
||||||
src.fridge = fridge
|
|
||||||
|
|
||||||
/datum/data/stored_item/Destroy()
|
|
||||||
fridge = null
|
|
||||||
if(instances)
|
|
||||||
for(var/product in instances)
|
|
||||||
qdel(product)
|
|
||||||
instances.Cut()
|
|
||||||
. = ..()
|
|
||||||
|
|
||||||
/datum/data/stored_item/proc/get_amount()
|
|
||||||
return instances ? instances.len : amount
|
|
||||||
|
|
||||||
/datum/data/stored_item/proc/get_product(var/product_location)
|
|
||||||
if(!get_amount() || !product_location)
|
|
||||||
return
|
|
||||||
init_products()
|
|
||||||
|
|
||||||
var/atom/movable/product = instances[instances.len] // Remove the last added product
|
|
||||||
instances -= product
|
|
||||||
product.forceMove(product_location)
|
|
||||||
|
|
||||||
/datum/data/stored_item/proc/add_product(var/atom/movable/product)
|
|
||||||
if(product.type != item_path)
|
|
||||||
return 0
|
|
||||||
init_products()
|
|
||||||
product.forceMove(fridge)
|
|
||||||
instances += product
|
|
||||||
|
|
||||||
/datum/data/stored_item/proc/init_products()
|
|
||||||
if(instances)
|
|
||||||
return
|
|
||||||
instances = list()
|
|
||||||
for(var/i = 1 to amount)
|
|
||||||
var/new_product = new item_path(fridge)
|
|
||||||
instances += new_product
|
|
||||||
|
|
||||||
|
|
||||||
/* SmartFridge. Much todo
|
/* SmartFridge. Much todo
|
||||||
*/
|
*/
|
||||||
/obj/machinery/smartfridge
|
/obj/machinery/smartfridge
|
||||||
@@ -76,7 +16,7 @@
|
|||||||
var/icon_off = "smartfridge-off"
|
var/icon_off = "smartfridge-off"
|
||||||
var/icon_panel = "smartfridge-panel"
|
var/icon_panel = "smartfridge-panel"
|
||||||
var/list/item_records = list()
|
var/list/item_records = list()
|
||||||
var/datum/data/stored_item/currently_vending = null //What we're putting out of the machine.
|
var/datum/stored_item/currently_vending = null //What we're putting out of the machine.
|
||||||
var/seconds_electrified = 0;
|
var/seconds_electrified = 0;
|
||||||
var/shoot_inventory = 0
|
var/shoot_inventory = 0
|
||||||
var/locked = 0
|
var/locked = 0
|
||||||
@@ -96,6 +36,8 @@
|
|||||||
|
|
||||||
/obj/machinery/smartfridge/Destroy()
|
/obj/machinery/smartfridge/Destroy()
|
||||||
qdel(wires)
|
qdel(wires)
|
||||||
|
for(var/A in item_records) //Get rid of item records.
|
||||||
|
qdel(A)
|
||||||
wires = null
|
wires = null
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
@@ -129,7 +71,7 @@
|
|||||||
|
|
||||||
/obj/machinery/smartfridge/secure/extract/New()
|
/obj/machinery/smartfridge/secure/extract/New()
|
||||||
..()
|
..()
|
||||||
var/datum/data/stored_item/I = new(src, /obj/item/xenoproduct/slime/core)
|
var/datum/stored_item/I = new(src, /obj/item/xenoproduct/slime/core)
|
||||||
item_records.Add(I)
|
item_records.Add(I)
|
||||||
for(var/i=1 to 5)
|
for(var/i=1 to 5)
|
||||||
var/obj/item/xenoproduct/slime/core/C = new(src)
|
var/obj/item/xenoproduct/slime/core/C = new(src)
|
||||||
@@ -226,17 +168,17 @@
|
|||||||
overlays += "drying_rack_drying"
|
overlays += "drying_rack_drying"
|
||||||
|
|
||||||
/obj/machinery/smartfridge/drying_rack/proc/dry()
|
/obj/machinery/smartfridge/drying_rack/proc/dry()
|
||||||
for(var/datum/data/stored_item/I in item_records)
|
for(var/datum/stored_item/I in item_records)
|
||||||
for(var/obj/item/weapon/reagent_containers/food/snacks/S in I.instances)
|
for(var/obj/item/weapon/reagent_containers/food/snacks/S in I.instances)
|
||||||
if(S.dry) continue
|
if(S.dry) continue
|
||||||
if(S.dried_type == S.type)
|
if(S.dried_type == S.type)
|
||||||
S.dry = 1
|
S.dry = 1
|
||||||
S.name = "dried [S.name]"
|
S.name = "dried [S.name]"
|
||||||
S.color = "#AAAAAA"
|
S.color = "#AAAAAA"
|
||||||
I.get_product(loc)
|
stock(S)
|
||||||
else
|
else
|
||||||
var/D = S.dried_type
|
var/D = S.dried_type
|
||||||
new D(loc)
|
new D(get_turf(src))
|
||||||
qdel(S)
|
qdel(S)
|
||||||
return
|
return
|
||||||
return
|
return
|
||||||
@@ -286,46 +228,22 @@
|
|||||||
|
|
||||||
if(accept_check(O))
|
if(accept_check(O))
|
||||||
user.remove_from_mob(O)
|
user.remove_from_mob(O)
|
||||||
var/hasRecord = FALSE //Check to see if this passes or not.
|
stock(O)
|
||||||
for(var/datum/data/stored_item/I in item_records)
|
|
||||||
if(istype(O, I.item_path))
|
|
||||||
stock(O, I)
|
|
||||||
qdel(O)
|
|
||||||
return
|
|
||||||
if(!hasRecord)
|
|
||||||
var/datum/data/stored_item/item = new/datum/data/stored_item(src, O.type)
|
|
||||||
stock(O, item)
|
|
||||||
item_records.Add(item)
|
|
||||||
|
|
||||||
user.visible_message("<span class='notice'>[user] has added \the [O] to \the [src].</span>", "<span class='notice'>You add \the [O] to \the [src].</span>")
|
user.visible_message("<span class='notice'>[user] has added \the [O] to \the [src].</span>", "<span class='notice'>You add \the [O] to \the [src].</span>")
|
||||||
|
|
||||||
nanomanager.update_uis(src)
|
|
||||||
|
|
||||||
else if(istype(O, /obj/item/weapon/storage/bag))
|
else if(istype(O, /obj/item/weapon/storage/bag))
|
||||||
var/obj/item/weapon/storage/bag/P = O
|
var/obj/item/weapon/storage/bag/P = O
|
||||||
var/plants_loaded = 0
|
var/plants_loaded = 0
|
||||||
for(var/obj/G in P.contents)
|
for(var/obj/G in P.contents)
|
||||||
if(accept_check(G))
|
if(accept_check(G))
|
||||||
plants_loaded++
|
stock(G)
|
||||||
var/hasRecord = FALSE //Check to see if this passes or not.
|
plants_loaded = 1
|
||||||
for(var/datum/data/stored_item/I in item_records)
|
|
||||||
if(istype(G, I.item_path))
|
|
||||||
if(G.name == I.item_name)
|
|
||||||
stock(G, I)
|
|
||||||
hasRecord = TRUE
|
|
||||||
if(!hasRecord)
|
|
||||||
var/datum/data/stored_item/item = new/datum/data/stored_item(src, G.type, G.name)
|
|
||||||
stock(G, item)
|
|
||||||
item_records.Add(item)
|
|
||||||
|
|
||||||
if(plants_loaded)
|
if(plants_loaded)
|
||||||
|
|
||||||
user.visible_message("<span class='notice'>[user] loads \the [src] with \the [P].</span>", "<span class='notice'>You load \the [src] with \the [P].</span>")
|
user.visible_message("<span class='notice'>[user] loads \the [src] with \the [P].</span>", "<span class='notice'>You load \the [src] with \the [P].</span>")
|
||||||
if(P.contents.len > 0)
|
if(P.contents.len > 0)
|
||||||
user << "<span class='notice'>Some items are refused.</span>"
|
user << "<span class='notice'>Some items are refused.</span>"
|
||||||
|
|
||||||
nanomanager.update_uis(src)
|
|
||||||
|
|
||||||
else
|
else
|
||||||
user << "<span class='notice'>\The [src] smartly refuses [O].</span>"
|
user << "<span class='notice'>\The [src] smartly refuses [O].</span>"
|
||||||
return 1
|
return 1
|
||||||
@@ -337,11 +255,20 @@
|
|||||||
user << "You short out the product lock on [src]."
|
user << "You short out the product lock on [src]."
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
/obj/machinery/smartfridge/proc/stock(obj/item/O, var/datum/data/stored_item/I)
|
/obj/machinery/smartfridge/proc/stock(obj/item/O)
|
||||||
I.add_product(O)
|
var/hasRecord = FALSE //Check to see if this passes or not.
|
||||||
|
for(var/datum/stored_item/I in item_records)
|
||||||
|
if((O.type == I.item_path) && (O.name == I.item_name))
|
||||||
|
I.add_product(O)
|
||||||
|
hasRecord = TRUE
|
||||||
|
break
|
||||||
|
if(!hasRecord)
|
||||||
|
var/datum/stored_item/item = new/datum/stored_item(src, O.type, O.name)
|
||||||
|
item.add_product(O)
|
||||||
|
item_records.Add(item)
|
||||||
nanomanager.update_uis(src)
|
nanomanager.update_uis(src)
|
||||||
|
|
||||||
/obj/machinery/smartfridge/proc/vend(datum/data/stored_item/I)
|
/obj/machinery/smartfridge/proc/vend(datum/stored_item/I)
|
||||||
I.get_product(get_turf(src))
|
I.get_product(get_turf(src))
|
||||||
nanomanager.update_uis(src)
|
nanomanager.update_uis(src)
|
||||||
|
|
||||||
@@ -370,7 +297,7 @@
|
|||||||
|
|
||||||
var/list/items[0]
|
var/list/items[0]
|
||||||
for (var/i=1 to length(item_records))
|
for (var/i=1 to length(item_records))
|
||||||
var/datum/data/stored_item/I = item_records[i]
|
var/datum/stored_item/I = item_records[i]
|
||||||
var/count = I.get_amount()
|
var/count = I.get_amount()
|
||||||
if(count > 0)
|
if(count > 0)
|
||||||
items.Add(list(list("display_name" = html_encode(capitalize(I.item_name)), "vend" = i, "quantity" = count)))
|
items.Add(list(list("display_name" = html_encode(capitalize(I.item_name)), "vend" = i, "quantity" = count)))
|
||||||
@@ -400,7 +327,7 @@
|
|||||||
if(href_list["vend"])
|
if(href_list["vend"])
|
||||||
var/index = text2num(href_list["vend"])
|
var/index = text2num(href_list["vend"])
|
||||||
var/amount = text2num(href_list["amount"])
|
var/amount = text2num(href_list["amount"])
|
||||||
var/datum/data/stored_item/I = item_records[index]
|
var/datum/stored_item/I = item_records[index]
|
||||||
var/count = I.get_amount()
|
var/count = I.get_amount()
|
||||||
|
|
||||||
// Sanity check, there are probably ways to press the button when it shouldn't be possible.
|
// Sanity check, there are probably ways to press the button when it shouldn't be possible.
|
||||||
@@ -419,8 +346,8 @@
|
|||||||
if(!target)
|
if(!target)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
for(var/datum/data/stored_item/I in src.item_records)
|
for(var/datum/stored_item/I in item_records)
|
||||||
throw_item = I.get_product(loc)
|
throw_item = I.get_product(get_turf(src))
|
||||||
if (!throw_item)
|
if (!throw_item)
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -1,69 +1,3 @@
|
|||||||
/**
|
|
||||||
* Datum used to hold information about a product in a vending machine
|
|
||||||
*/
|
|
||||||
/datum/data/vending_product
|
|
||||||
var/product_name = "generic" // Display name for the product
|
|
||||||
var/product_path = null
|
|
||||||
var/amount = 0 // The original amount held in the vending machine
|
|
||||||
var/list/instances
|
|
||||||
var/price = 0 // Price to buy one
|
|
||||||
var/display_color = null // Display color for vending machine listing
|
|
||||||
var/category = CAT_NORMAL // CAT_HIDDEN for contraband, CAT_COIN for premium
|
|
||||||
var/vending_machine // The vending machine we belong to
|
|
||||||
|
|
||||||
/datum/data/vending_product/New(var/vending_machine, var/path, var/name = null, var/amount = 1, var/price = 0, var/color = null, var/category = CAT_NORMAL)
|
|
||||||
..()
|
|
||||||
|
|
||||||
src.product_path = path
|
|
||||||
|
|
||||||
if(!name)
|
|
||||||
var/atom/tmp = path
|
|
||||||
src.product_name = initial(tmp.name)
|
|
||||||
else
|
|
||||||
src.product_name = name
|
|
||||||
|
|
||||||
src.amount = amount
|
|
||||||
src.price = price
|
|
||||||
src.display_color = color
|
|
||||||
src.category = category
|
|
||||||
src.vending_machine = vending_machine
|
|
||||||
|
|
||||||
/datum/data/vending_product/Destroy()
|
|
||||||
vending_machine = null
|
|
||||||
if(instances)
|
|
||||||
for(var/product in instances)
|
|
||||||
qdel(product)
|
|
||||||
instances.Cut()
|
|
||||||
. = ..()
|
|
||||||
|
|
||||||
/datum/data/vending_product/proc/get_amount()
|
|
||||||
return instances ? instances.len : amount
|
|
||||||
|
|
||||||
/datum/data/vending_product/proc/add_product(var/atom/movable/product)
|
|
||||||
if(product.type != product_path)
|
|
||||||
return 0
|
|
||||||
init_products()
|
|
||||||
product.forceMove(vending_machine)
|
|
||||||
instances += product
|
|
||||||
|
|
||||||
/datum/data/vending_product/proc/get_product(var/product_location)
|
|
||||||
if(!get_amount() || !product_location)
|
|
||||||
return
|
|
||||||
init_products()
|
|
||||||
|
|
||||||
var/atom/movable/product = instances[instances.len] // Remove the last added product
|
|
||||||
instances -= product
|
|
||||||
product.forceMove(product_location)
|
|
||||||
return product
|
|
||||||
|
|
||||||
/datum/data/vending_product/proc/init_products()
|
|
||||||
if(instances)
|
|
||||||
return
|
|
||||||
instances = list()
|
|
||||||
for(var/i = 1 to amount)
|
|
||||||
var/new_product = new product_path(vending_machine)
|
|
||||||
instances += new_product
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A vending machine
|
* A vending machine
|
||||||
*/
|
*/
|
||||||
@@ -89,7 +23,7 @@
|
|||||||
var/vend_ready = 1 //Are we ready to vend?? Is it time??
|
var/vend_ready = 1 //Are we ready to vend?? Is it time??
|
||||||
var/vend_delay = 10 //How long does it take to vend?
|
var/vend_delay = 10 //How long does it take to vend?
|
||||||
var/categories = CAT_NORMAL // Bitmask of cats we're currently showing
|
var/categories = CAT_NORMAL // Bitmask of cats we're currently showing
|
||||||
var/datum/data/vending_product/currently_vending = null // What we're requesting payment for right now
|
var/datum/stored_item/vending_product/currently_vending = null // What we're requesting payment for right now
|
||||||
var/status_message = "" // Status screen messages like "insufficient funds", displayed in NanoUI
|
var/status_message = "" // Status screen messages like "insufficient funds", displayed in NanoUI
|
||||||
var/status_error = 0 // Set to 1 if status_message is an error
|
var/status_error = 0 // Set to 1 if status_message is an error
|
||||||
|
|
||||||
@@ -169,7 +103,7 @@
|
|||||||
var/category = current_list[2]
|
var/category = current_list[2]
|
||||||
|
|
||||||
for(var/entry in current_list[1])
|
for(var/entry in current_list[1])
|
||||||
var/datum/data/vending_product/product = new/datum/data/vending_product(src, entry)
|
var/datum/stored_item/vending_product/product = new/datum/stored_item/vending_product(src, entry)
|
||||||
|
|
||||||
product.price = (entry in src.prices) ? src.prices[entry] : 0
|
product.price = (entry in src.prices) ? src.prices[entry] : 0
|
||||||
product.amount = (current_list[1][entry]) ? current_list[1][entry] : 1
|
product.amount = (current_list[1][entry]) ? current_list[1][entry] : 1
|
||||||
@@ -182,7 +116,7 @@
|
|||||||
wires = null
|
wires = null
|
||||||
qdel(coin)
|
qdel(coin)
|
||||||
coin = null
|
coin = null
|
||||||
for(var/datum/data/vending_product/R in product_records)
|
for(var/datum/stored_item/vending_product/R in product_records)
|
||||||
qdel(R)
|
qdel(R)
|
||||||
product_records = null
|
product_records = null
|
||||||
return ..()
|
return ..()
|
||||||
@@ -276,10 +210,9 @@
|
|||||||
return
|
return
|
||||||
else
|
else
|
||||||
|
|
||||||
for(var/datum/data/vending_product/R in product_records)
|
for(var/datum/stored_item/vending_product/R in product_records)
|
||||||
if(istype(W, R.product_path))
|
if(istype(W, R.item_path) && (W.name == R.item_name))
|
||||||
stock(W, R, user)
|
stock(W, R, user)
|
||||||
qdel(W)
|
|
||||||
return
|
return
|
||||||
..()
|
..()
|
||||||
|
|
||||||
@@ -374,7 +307,7 @@
|
|||||||
// create entry in the purchaser's account log
|
// create entry in the purchaser's account log
|
||||||
var/datum/transaction/T = new()
|
var/datum/transaction/T = new()
|
||||||
T.target_name = "[vendor_account.owner_name] (via [src.name])"
|
T.target_name = "[vendor_account.owner_name] (via [src.name])"
|
||||||
T.purpose = "Purchase of [currently_vending.product_name]"
|
T.purpose = "Purchase of [currently_vending.item_name]"
|
||||||
if(currently_vending.price > 0)
|
if(currently_vending.price > 0)
|
||||||
T.amount = "([currently_vending.price])"
|
T.amount = "([currently_vending.price])"
|
||||||
else
|
else
|
||||||
@@ -400,7 +333,7 @@
|
|||||||
|
|
||||||
var/datum/transaction/T = new()
|
var/datum/transaction/T = new()
|
||||||
T.target_name = target
|
T.target_name = target
|
||||||
T.purpose = "Purchase of [currently_vending.product_name]"
|
T.purpose = "Purchase of [currently_vending.item_name]"
|
||||||
T.amount = "[currently_vending.price]"
|
T.amount = "[currently_vending.price]"
|
||||||
T.source_terminal = src.name
|
T.source_terminal = src.name
|
||||||
T.date = current_date_string
|
T.date = current_date_string
|
||||||
@@ -432,7 +365,7 @@
|
|||||||
var/list/data = list()
|
var/list/data = list()
|
||||||
if(currently_vending)
|
if(currently_vending)
|
||||||
data["mode"] = 1
|
data["mode"] = 1
|
||||||
data["product"] = currently_vending.product_name
|
data["product"] = currently_vending.item_name
|
||||||
data["price"] = currently_vending.price
|
data["price"] = currently_vending.price
|
||||||
data["message_err"] = 0
|
data["message_err"] = 0
|
||||||
data["message"] = src.status_message
|
data["message"] = src.status_message
|
||||||
@@ -442,14 +375,14 @@
|
|||||||
var/list/listed_products = list()
|
var/list/listed_products = list()
|
||||||
|
|
||||||
for(var/key = 1 to src.product_records.len)
|
for(var/key = 1 to src.product_records.len)
|
||||||
var/datum/data/vending_product/I = src.product_records[key]
|
var/datum/stored_item/vending_product/I = src.product_records[key]
|
||||||
|
|
||||||
if(!(I.category & src.categories))
|
if(!(I.category & src.categories))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
listed_products.Add(list(list(
|
listed_products.Add(list(list(
|
||||||
"key" = key,
|
"key" = key,
|
||||||
"name" = I.product_name,
|
"name" = I.item_name,
|
||||||
"price" = I.price,
|
"price" = I.price,
|
||||||
"color" = I.display_color,
|
"color" = I.display_color,
|
||||||
"amount" = I.get_amount())))
|
"amount" = I.get_amount())))
|
||||||
@@ -497,7 +430,7 @@
|
|||||||
return
|
return
|
||||||
|
|
||||||
var/key = text2num(href_list["vend"])
|
var/key = text2num(href_list["vend"])
|
||||||
var/datum/data/vending_product/R = product_records[key]
|
var/datum/stored_item/vending_product/R = product_records[key]
|
||||||
|
|
||||||
// This should not happen unless the request from NanoUI was bad
|
// This should not happen unless the request from NanoUI was bad
|
||||||
if(!(R.category & src.categories))
|
if(!(R.category & src.categories))
|
||||||
@@ -526,7 +459,7 @@
|
|||||||
src.add_fingerprint(usr)
|
src.add_fingerprint(usr)
|
||||||
nanomanager.update_uis(src)
|
nanomanager.update_uis(src)
|
||||||
|
|
||||||
/obj/machinery/vending/proc/vend(datum/data/vending_product/R, mob/user)
|
/obj/machinery/vending/proc/vend(datum/stored_item/vending_product/R, mob/user)
|
||||||
if((!allowed(usr)) && !emagged && scan_id) //For SECURE VENDING MACHINES YEAH
|
if((!allowed(usr)) && !emagged && scan_id) //For SECURE VENDING MACHINES YEAH
|
||||||
usr << "<span class='warning'>Access denied.</span>" //Unless emagged of course
|
usr << "<span class='warning'>Access denied.</span>" //Unless emagged of course
|
||||||
flick(src.icon_deny,src)
|
flick(src.icon_deny,src)
|
||||||
@@ -581,7 +514,7 @@
|
|||||||
* Checks if item is vendable in this machine should be performed before
|
* Checks if item is vendable in this machine should be performed before
|
||||||
* calling. W is the item being inserted, R is the associated vending_product entry.
|
* calling. W is the item being inserted, R is the associated vending_product entry.
|
||||||
*/
|
*/
|
||||||
/obj/machinery/vending/proc/stock(obj/item/weapon/W, var/datum/data/vending_product/R, var/mob/user)
|
/obj/machinery/vending/proc/stock(obj/item/weapon/W, var/datum/stored_item/vending_product/R, var/mob/user)
|
||||||
if(!user.unEquip(W))
|
if(!user.unEquip(W))
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -635,7 +568,7 @@
|
|||||||
|
|
||||||
//Oh no we're malfunctioning! Dump out some product and break.
|
//Oh no we're malfunctioning! Dump out some product and break.
|
||||||
/obj/machinery/vending/proc/malfunction()
|
/obj/machinery/vending/proc/malfunction()
|
||||||
for(var/datum/data/vending_product/R in src.product_records)
|
for(var/datum/stored_item/vending_product/R in src.product_records)
|
||||||
while(R.get_amount()>0)
|
while(R.get_amount()>0)
|
||||||
R.get_product(loc)
|
R.get_product(loc)
|
||||||
break
|
break
|
||||||
@@ -651,7 +584,7 @@
|
|||||||
if(!target)
|
if(!target)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
for(var/datum/data/vending_product/R in src.product_records)
|
for(var/datum/stored_item/vending_product/R in src.product_records)
|
||||||
throw_item = R.get_product(loc)
|
throw_item = R.get_product(loc)
|
||||||
if (!throw_item)
|
if (!throw_item)
|
||||||
continue
|
continue
|
||||||
@@ -930,7 +863,7 @@
|
|||||||
for(var/entry in current_list[1])
|
for(var/entry in current_list[1])
|
||||||
var/obj/item/seeds/S = new entry(src)
|
var/obj/item/seeds/S = new entry(src)
|
||||||
var/name = S.name
|
var/name = S.name
|
||||||
var/datum/data/vending_product/product = new/datum/data/vending_product(src, entry, name)
|
var/datum/stored_item/vending_product/product = new/datum/stored_item/vending_product(src, entry, name)
|
||||||
|
|
||||||
product.price = (entry in src.prices) ? src.prices[entry] : 0
|
product.price = (entry in src.prices) ? src.prices[entry] : 0
|
||||||
product.amount = (current_list[1][entry]) ? current_list[1][entry] : 1
|
product.amount = (current_list[1][entry]) ? current_list[1][entry] : 1
|
||||||
|
|||||||
@@ -215,6 +215,8 @@
|
|||||||
#include "code\datums\uplink\uplink_categories.dm"
|
#include "code\datums\uplink\uplink_categories.dm"
|
||||||
#include "code\datums\uplink\uplink_items.dm"
|
#include "code\datums\uplink\uplink_items.dm"
|
||||||
#include "code\datums\uplink\visible_weapons.dm"
|
#include "code\datums\uplink\visible_weapons.dm"
|
||||||
|
#include "code\datums\vending\stored_item.dm"
|
||||||
|
#include "code\datums\vending\vending.dm"
|
||||||
#include "code\datums\wires\airlock.dm"
|
#include "code\datums\wires\airlock.dm"
|
||||||
#include "code\datums\wires\alarm.dm"
|
#include "code\datums\wires\alarm.dm"
|
||||||
#include "code\datums\wires\apc.dm"
|
#include "code\datums\wires\apc.dm"
|
||||||
|
|||||||
Reference in New Issue
Block a user