mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2026-01-02 21:43:22 +00:00
Merge pull request #2859 from Neerti/12/17/2016_vending_throw_fix
Vending machines now correctly throw products
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
*/
|
||||
/datum/stored_item
|
||||
var/item_name = "name" //Name of the item(s) displayed
|
||||
var/item_path = null
|
||||
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
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
src.item_name = initial(tmp.name)
|
||||
else
|
||||
src.item_name = name
|
||||
|
||||
|
||||
src.amount = amount
|
||||
src.stored = stored
|
||||
|
||||
|
||||
..()
|
||||
|
||||
/datum/stored_item/Destroy()
|
||||
@@ -29,10 +29,10 @@
|
||||
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
|
||||
@@ -41,14 +41,15 @@
|
||||
var/atom/movable/product = instances[instances.len] // Remove the last added product
|
||||
instances -= product
|
||||
product.forceMove(product_location)
|
||||
|
||||
return product
|
||||
|
||||
/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
|
||||
|
||||
Reference in New Issue
Block a user