diff --git a/code/modules/vending/_vending.dm b/code/modules/vending/_vending.dm index 37179dd36f4..f3f7e9c355c 100644 --- a/code/modules/vending/_vending.dm +++ b/code/modules/vending/_vending.dm @@ -1039,10 +1039,10 @@ LAZYADD(product_datum.returned_products, inserted_item) return - if(vending_machine_input[format_text(inserted_item.name)]) - vending_machine_input[format_text(inserted_item.name)]++ + if(vending_machine_input[inserted_item.type]) + vending_machine_input[inserted_item.type]++ else - vending_machine_input[format_text(inserted_item.name)] = 1 + vending_machine_input[inserted_item.type] = 1 loaded_items++ /obj/machinery/vending/unbuckle_mob(mob/living/buckled_mob, force = FALSE, can_fall = TRUE) @@ -1210,7 +1210,7 @@ colorable = product_record.colorable, ) - .["stock"][product_record.name] = product_data + .["stock"] += list(product_data) .["extended_inventory"] = extended_inventory @@ -1599,12 +1599,12 @@ . = ..() .["access"] = compartmentLoadAccessCheck(user) .["vending_machine_input"] = list() - for (var/stocked_item in vending_machine_input) + for (var/obj/item/stocked_item as anything in vending_machine_input) if(vending_machine_input[stocked_item] > 0) var/base64 var/price = 0 for(var/obj/item/stored_item in contents) - if(format_text(stored_item.name) == stocked_item) + if(stored_item.type == stocked_item) price = stored_item.custom_price if(!base64) //generate an icon of the item to use in UI if(base64_cache[stored_item.type]) @@ -1614,7 +1614,8 @@ base64_cache[stored_item.type] = base64 break var/list/data = list( - name = stocked_item, + path = stocked_item, + name = initial(stocked_item.name), price = price, img = base64, amount = vending_machine_input[stocked_item], @@ -1629,8 +1630,8 @@ switch(action) if("dispense") if(isliving(usr)) - vend_act(usr, params["item"]) - vend_ready = TRUE + vend_act(usr, params) + vend_ready = TRUE return TRUE /obj/machinery/vending/custom/attackby(obj/item/attack_item, mob/user, params) @@ -1668,9 +1669,10 @@ * Updating stock, account transactions, alerting users. * @return -- TRUE if a valid condition was met, FALSE otherwise. */ -/obj/machinery/vending/custom/proc/vend_act(mob/living/user, choice) +/obj/machinery/vending/custom/proc/vend_act(mob/living/user, list/params) if(!vend_ready) return + var/obj/item/choice = text2path(params["item"]) // typepath is a string coming from javascript, we need to convert it back var/obj/item/dispensed_item var/obj/item/card/id/id_card = user.get_idcard(TRUE) vend_ready = FALSE @@ -1679,8 +1681,8 @@ flick(icon_deny, src) return TRUE var/datum/bank_account/payee = id_card.registered_account - for(var/obj/stock in contents) - if(format_text(stock.name) == choice) + for(var/obj/item/stock in contents) + if(istype(stock, choice)) dispensed_item = stock break if(!dispensed_item) diff --git a/tgui/packages/tgui/interfaces/Vending.tsx b/tgui/packages/tgui/interfaces/Vending.tsx index 942e0680290..0311f3555a1 100644 --- a/tgui/packages/tgui/interfaces/Vending.tsx +++ b/tgui/packages/tgui/interfaces/Vending.tsx @@ -65,6 +65,7 @@ type StockItem = { }; type CustomInput = { + path: string; name: string; price: number; img: string; @@ -217,12 +218,12 @@ const ProductDisplay = (props: { return true; } }) - .map((product) => ( + .map((product, index) => ( ))} @@ -350,7 +351,7 @@ const ProductButton = (props) => { disabled={disabled} onClick={() => act('dispense', { - item: product.name, + item: product.path, }) } >