Skip to content

Commit

Permalink
Merge pull request #392 from KoboldCommando/emptying-trays
Browse files Browse the repository at this point in the history
Allows emptying nutrients from botany trays, fixes a couple minor bugs
  • Loading branch information
dwasint authored Oct 7, 2023
2 parents 34f7cc6 + 75913d1 commit efd883f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion code/modules/hydroponics/hydroitemdefines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
returned_message += "\nPest level: [span_notice("[scanned_tray.pestlevel] / [MAX_TRAY_PESTS]")]"
returned_message += "\nToxicity level: [span_notice("[scanned_tray.toxic] / [MAX_TRAY_TOXINS]")]"
returned_message += "\nWater level: [span_notice("[scanned_tray.waterlevel] / [scanned_tray.maxwater]")]"
returned_message += "\nNutrition level: [span_notice("[round(scanned_tray.reagents.total_volume)] / [scanned_tray.maxnutri]")]"
returned_message += "\nNutrition level: [span_notice("[round(scanned_tray.reagents.total_volume)] / [scanned_tray.maxnutri]")] Right-click to empty."
if(scanned_tray.yieldmod != 1)
returned_message += "\nYield modifier on harvest: [span_notice("[scanned_tray.yieldmod]x")]"

Expand Down
41 changes: 33 additions & 8 deletions code/modules/hydroponics/hydroponics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@
. += span_info("It's empty.")

. += span_info("Water: [waterlevel]/[maxwater].")
. += span_info("Nutrient: [round(reagents.total_volume)]/[maxnutri].")
. += span_info("Nutrient: [round(reagents.total_volume)]/[maxnutri]. Right-click to empty.")
if(self_sustaining)
. += span_info("The tray's self-sustenance is active, protecting it from species mutations, weeds, and pests.")
if(self_growing)
Expand Down Expand Up @@ -1032,12 +1032,13 @@
return
if(issilicon(user)) //How does AI know what plant is?
return
var/growth_mult = (1.01 ** -myseed.maturation)
if(growth >= myseed.harvest_age * growth_mult)
//if(myseed.harvest_age < age * max(myseed.production * 0.044, 0.5) && (myseed.harvest_age) < (age - lastproduce) * max(myseed.production * 0.044, 0.5) && (!harvest && !dead))
nutrimentMutation()
if(myseed && myseed.yield != -1) // Unharvestable shouldn't be harvested
set_plant_status(HYDROTRAY_PLANT_HARVESTABLE)
if(myseed)
var/growth_mult = (1.01 ** -myseed.maturation)
if(growth >= myseed.harvest_age * growth_mult)
//if(myseed.harvest_age < age * max(myseed.production * 0.044, 0.5) && (myseed.harvest_age) < (age - lastproduce) * max(myseed.production * 0.044, 0.5) && (!harvest && !dead))
nutrimentMutation()
if(myseed && myseed.yield != -1) // Unharvestable shouldn't be harvested
set_plant_status(HYDROTRAY_PLANT_HARVESTABLE)

if(plant_status == HYDROTRAY_PLANT_HARVESTABLE)
return myseed.harvest(user)
Expand All @@ -1051,6 +1052,30 @@
if(user)
user.examinate(src)

/obj/machinery/hydroponics/attack_hand_secondary(mob/user, list/modifiers)
. = ..()
if(. == SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN)
return
if(issilicon(user))
return

if(reagents.total_volume)
to_chat(user, span_notice("You begin to dump out the tray's nutrient mix."))
if(do_after(user, 4 SECONDS, target = src))
playsound(user.loc, 'sound/effects/slosh.ogg', 50, TRUE, -1)
//dump everything on the floor
var/turf/user_loc = user.loc
if(istype(user_loc, /turf/open))
user_loc.add_liquid_from_reagents(reagents)
else
user_loc = get_step_towards(user_loc, src)
user_loc.add_liquid_from_reagents(reagents)
adjust_plant_nutriments(100) //PURGE
else
to_chat(user, span_warning("The tray's nutrient mix is already empty!"))

return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN

/**
* Update Tray Proc
* Handles plant harvesting on the tray side, by clearing the seed, names, description, and dead stat.
Expand Down Expand Up @@ -1182,7 +1207,7 @@
///The usb port circuit

/obj/item/circuit_component/hydroponics
display_name = "Hydropnics Tray"
display_name = "Hydroponics Tray"
desc = "Automate the means of botanical production. Trigger to toggle auto-grow."
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL

Expand Down

0 comments on commit efd883f

Please sign in to comment.