mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-21 03:59:59 +01:00
Chemmaster reagent transfer runtime fix (#84939)
## About The Pull Request Fixes #84938 by adding a check for whether a beaker is inserted into the machine, and added a feedback message. ## Why It's Good For The Game Fixes #84938. ## Changelog 🆑 fix: deleting reagents from the chemmaster buffer works without a beaker inserted /🆑 --------- Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
@@ -365,32 +365,18 @@
|
||||
* Transfers a single reagent between buffer & beaker
|
||||
* Arguments
|
||||
*
|
||||
* * mob/user - the player who is attempting the transfer
|
||||
* * datum/reagents/source - the holder we are transferring from
|
||||
* * datum/reagents/target - the holder we are transferring to
|
||||
* * datum/reagent/path - the reagent typepath we are transfering
|
||||
* * amount - volume to transfer -1 means custom amount
|
||||
* * amount - volume to transfer
|
||||
* * do_transfer - transfer the reagents else destroy them
|
||||
*/
|
||||
/obj/machinery/chem_master/proc/transfer_reagent(mob/user, datum/reagents/source, datum/reagents/target, datum/reagent/path, amount, do_transfer)
|
||||
/obj/machinery/chem_master/proc/transfer_reagent(datum/reagents/source, datum/reagents/target, datum/reagent/path, amount, do_transfer)
|
||||
PRIVATE_PROC(TRUE)
|
||||
|
||||
//sanity checks for transfer amount
|
||||
if(isnull(amount))
|
||||
if(isnull(amount) || amount <= 0)
|
||||
return FALSE
|
||||
amount = text2num(amount)
|
||||
if(isnull(amount))
|
||||
return FALSE
|
||||
if(amount == -1)
|
||||
var/target_amount = tgui_input_number(user, "Enter amount to transfer", "Transfer amount")
|
||||
if(!target_amount)
|
||||
return FALSE
|
||||
amount = text2num(target_amount)
|
||||
if(isnull(amount))
|
||||
return FALSE
|
||||
if(amount <= 0)
|
||||
return FALSE
|
||||
|
||||
//sanity checks for reagent path
|
||||
var/datum/reagent/reagent = text2path(path)
|
||||
if (!reagent)
|
||||
@@ -425,18 +411,34 @@
|
||||
|
||||
if("transfer")
|
||||
if(is_printing)
|
||||
say("buffer locked while printing!")
|
||||
say("The buffer is locked while printing.")
|
||||
return
|
||||
|
||||
var/reagent_ref = params["reagentRef"]
|
||||
var/amount = params["amount"]
|
||||
var/target = params["target"]
|
||||
|
||||
if(amount == -1) // Set custom amount
|
||||
var/mob/user = ui.user //Hold a reference of the user if the UI is closed
|
||||
amount = tgui_input_number(user, "Enter amount to transfer", "Transfer amount")
|
||||
if(!amount || !user.can_perform_action(src))
|
||||
return FALSE
|
||||
|
||||
var/should_transfer = is_transfering || (target == "buffer") // we should always transfer if target is the buffer
|
||||
if(should_transfer && isnull(beaker)) // if there's no beaker, we cannot transfer
|
||||
say("No reagent container is inserted.")
|
||||
return FALSE
|
||||
|
||||
var/reagents_from
|
||||
var/reagents_to = null
|
||||
if(target == "buffer")
|
||||
return transfer_reagent(ui.user, beaker.reagents, reagents, reagent_ref, amount, TRUE)
|
||||
reagents_from = beaker.reagents
|
||||
reagents_to = reagents // buffer
|
||||
else if(target == "beaker")
|
||||
return transfer_reagent(ui.user, reagents, beaker.reagents, reagent_ref, amount, is_transfering)
|
||||
return FALSE
|
||||
reagents_from = reagents // buffer
|
||||
if(should_transfer)
|
||||
reagents_to = beaker.reagents
|
||||
return transfer_reagent(reagents_from, reagents_to, reagent_ref, amount, should_transfer)
|
||||
|
||||
if("toggleTransferMode")
|
||||
is_transfering = !is_transfering
|
||||
|
||||
Reference in New Issue
Block a user