Reagents Holder
The holder is the datum that holds a list of all reagents currently in the object.
By default, all atom have an empty reagents var. If you want to use an object for the chemistry system you'll need to add something like this in its new proc:
// Create a new datum, 100 is the maximum_volume of the new holder datum.
var/datum/reagents/R = new/datum/reagents(100)
reagents = R // Assign the new datum to the objects reagents var
R.my_atom = src // set the holders my_atom to src so that we know where we are.
This can also be done by calling a convenience proc e.g. /atom/proc/create_reagents(max_volume)
Vars | |
maximum_volume | This is the maximum volume of the holder. |
---|---|
my_atom | This is the atom the holder is 'in'. Useful if you need to find the location. (i.e. for explosions) |
reagent_list | All contained reagents. More specifically, references to the reagent datums. |
total_volume | The total volume of all reagents in this holder. |
Procs | |
add_reagent | Attempts to add X of the matching reagent to the holder. |
clear_reagents | Remove all reagents from the holder. |
del_reagent | Completely remove the reagent with the matching ID. |
get_master_reagent_id | Get the id of the reagent there is the most of in this holder |
get_reagent_amount | Returns the amount of the matching reagent inside the holder. |
handle_reactions | Check all recipes and, on a match, uses them. |
has_reagent | Return whether the holder contains the reagent. |
isolate_reagent | Remove all reagents but the specified one. |
metabolize | Called by /mob/living/proc/Life . You shouldn't have to use this one directly. |
overdose_list | Returns a list of all the chemical IDs in the reagent holder that are overdosing. |
reaction | Calls the appropriate reaction procs of the reagents. |
remove_any | Removes reagents from the holder until the passed amount is matched. |
remove_reagent | The exact opposite of the add_reagent proc. |
trans_id_to | Same as /datum/reagents/proc/trans_to but only for a specific reagent in the reagent list. If the specified amount is greater than what is available, it will use the amount of the reagent that is available. If no reagent exists, returns null. |
trans_to | Equally transfer the contents of the holder to another objects holder. |
update_total | Update the total volume of the holder (the volume of all reagents added together). |
Var Details
maximum_volume
This is the maximum volume of the holder.
my_atom
This is the atom the holder is 'in'. Useful if you need to find the location. (i.e. for explosions)
reagent_list
All contained reagents. More specifically, references to the reagent datums.
total_volume
The total volume of all reagents in this holder.
Proc Details
add_reagent
Attempts to add X of the matching reagent to the holder.
You won't use this much. Mostly in new procs for pre-filled objects.
clear_reagents
Remove all reagents from the holder.
del_reagent
Completely remove the reagent with the matching ID.
get_master_reagent_id
Get the id of the reagent there is the most of in this holder
get_reagent_amount
Returns the amount of the matching reagent inside the holder.
Returns FALSE if the reagent is missing.
handle_reactions
Check all recipes and, on a match, uses them.
It will also call the recipe's on_reaction proc (for explosions or w/e). Currently, this proc is automatically called by /datum/reagents/proc/trans_to. Modified from the original to preserve reagent data across reactions (originally for xenoarchaeology).
has_reagent
Return whether the holder contains the reagent.
If you pass it an amount it will additionally check if the amount is matched.
isolate_reagent
Remove all reagents but the specified one.
metabolize
Called by /mob/living/proc/Life
. You shouldn't have to use this one directly.
overdose_list
Returns a list of all the chemical IDs in the reagent holder that are overdosing.
reaction
Calls the appropriate reaction procs of the reagents.
I.e. if A is an object, it will call the reagent's reaction_obj proc. The method var is used for reaction on mobs. It simply tells us if the mob TOUCHed the reagent or if it INGESTed the reagent.
Since the volume can be checked in a reagents proc, you might want to use the volume_modifier var to modifiy the passed value without actually changing the volume of the reagents.
If you're not sure if you need to use this the answer is very most likely 'No'.
You'll want to use this proc whenever an atom first comes in contact with the reagents of a holder. (in the 'splash' part of a beaker i.e.)
remove_any
Removes reagents from the holder until the passed amount is matched.
It'll try to remove some of ALL reagents contained.
remove_reagent
The exact opposite of the add_reagent proc.
Modified from original to return the reagent's data, in order to preserve reagent data across reactions (originally for xenoarchaeology).
trans_id_to
Same as /datum/reagents/proc/trans_to but only for a specific reagent in the reagent list. If the specified amount is greater than what is available, it will use the amount of the reagent that is available. If no reagent exists, returns null.
trans_to
Equally transfer the contents of the holder to another objects holder.
You need to pass it the object (not the holder) you want to transfer to and the amount you want to transfer. Its return value is the actual amount transfered (if one of the objects is full/empty).
If preserve_data = FALSE
, the reagents data will be lost. Useful if you use
data for some strange stuff and don't want it to be transferred.
update_total
Update the total volume of the holder (the volume of all reagents added together).