Skip to content

Commit

Permalink
Merge pull request #62 from Starfly-13/makes-plant-analyzer-usable
Browse files Browse the repository at this point in the history
makes-plant-analyzer-usable
  • Loading branch information
lectronyx authored Jun 13, 2024
2 parents a0ae6ee + d0d0fc0 commit 4bb50ce
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 50 deletions.
9 changes: 4 additions & 5 deletions code/modules/hydroponics/grown.dm
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,19 @@
/obj/item/reagent_containers/food/snacks/grown/attackby(obj/item/O, mob/user, params)
..()
if (istype(O, /obj/item/plant_analyzer))
var/msg = "<span class='info'>*---------*\n This is \a <span class='name'>[src]</span>.\n"
var/msg = "This is \a <span class='name'>[src]</span>.\n"
if(seed)
msg += seed.get_analyzer_text()
msg += "[seed.get_analyzer_text()]\n"
var/reag_txt = ""
if(seed)
for(var/reagent_id in seed.reagents_add)
var/datum/reagent/R = GLOB.chemical_reagents_list[reagent_id]
var/amt = reagents.get_reagent_amount(reagent_id)
reag_txt += "\n<span class='info'>- [R.name]: [amt]</span>"
reag_txt += "<span class='info'>- [R.name]: [amt]</span>\n"

if(reag_txt)
msg += reag_txt
msg += "<br><span class='info'>*---------*</span>"
to_chat(user, msg)
to_chat(user, examine_block(msg))
else
if(seed)
for(var/datum/plant_gene/trait/T in seed.genes)
Expand Down
5 changes: 2 additions & 3 deletions code/modules/hydroponics/growninedible.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@
/obj/item/grown/attackby(obj/item/O, mob/user, params)
..()
if (istype(O, /obj/item/plant_analyzer))
var/msg = "<span class='info'>*---------*\n This is \a <span class='name'>[src]</span>\n"
var/msg = "This is \a <span class='name'>[src]</span>\n"
if(seed)
msg += seed.get_analyzer_text()
msg += "</span>"
to_chat(usr, msg)
to_chat(usr, examine_block(msg))
return

/obj/item/grown/proc/add_juice()
Expand Down
49 changes: 29 additions & 20 deletions code/modules/hydroponics/hydroponics.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#define HYDRO_MAX_PEST 10
#define HYDRO_MAX_WEED 10
#define HYDRO_MAX_TOXIC 100
/obj/machinery/hydroponics
name = "hydroponics tray"
icon = 'icons/obj/hydroponics/equipment.dmi'
Expand All @@ -6,7 +9,9 @@
pixel_z = 1
obj_flags = CAN_BE_HIT | UNIQUE_RENAME
circuit = /obj/item/circuitboard/machine/hydroponics
idle_power_usage = 0
use_power = IDLE_POWER_USE
idle_power_usage = IDLE_DRAW_LOW
active_power_usage = ACTIVE_DRAW_HIGH
var/waterlevel = 100 //The amount of water in the tray (max 100)
var/maxwater = 100 //The maximum amount of water in the tray
var/nutridrain = 1 // How many units of nutrient will be drained in the tray
Expand Down Expand Up @@ -114,7 +119,7 @@

if(!powered() && self_sustaining)
visible_message("<span class='warning'>[name]'s auto-grow functionality shuts off!</span>")
idle_power_usage = 0
set_idle_power()
self_sustaining = FALSE
update_appearance()

Expand Down Expand Up @@ -253,7 +258,7 @@
adjustWeeds(1 / rating)

// Weeeeeeeeeeeeeeedddssss
if(weedlevel >= 10 && prob(50)) // At this point the plant is kind of fucked. Weeds can overtake the plant spot.
if(weedlevel >= HYDRO_MAX_WEED && prob(50)) // At this point the plant is kind of fucked. Weeds can overtake the plant spot.
if(myseed)
if(!myseed.get_gene(/datum/plant_gene/trait/plant_type/weed_hardy) && !myseed.get_gene(/datum/plant_gene/trait/plant_type/fungal_metabolism)) // If a normal plant
weedinvasion()
Expand Down Expand Up @@ -549,25 +554,26 @@

else if(istype(O, /obj/item/plant_analyzer))
var/obj/item/plant_analyzer/P_analyzer = O
var/msg = ""
if(myseed)
if(P_analyzer.scan_mode == PLANT_SCANMODE_STATS)
to_chat(user, examine_block("<B>[myseed.plantname]</B>"))
to_chat(user, examine_block("Plant Age: <span class='notice'>[age]</span>"))
msg += "<B>[myseed.plantname]</B>\n"
msg += "- Plant Age: [span_notice("[age]\n")]"
var/list/text_string = myseed.get_analyzer_text()
if(text_string)
to_chat(user, examine_block(text_string))
msg += "[text_string]\n"
if(myseed.reagents_add && P_analyzer.scan_mode == PLANT_SCANMODE_CHEMICALS)
to_chat(user, examine_block("<B>Plant Reagents</B>"))
msg += "<B>Plant Reagents</B>\n"
for(var/datum/plant_gene/reagent/Gene in myseed.genes)
to_chat(user, examine_block("<span class='notice'>- [Gene.get_name()] -</span>"))
msg += "[span_notice("- [Gene.get_name()] -")]\n"
else
to_chat(user, examine_block( "<B>No plant found.</B>"))
to_chat(user, examine_block("\nWeed level: <span class='notice'>[weedlevel] / 10</span>"))
to_chat(user, examine_block("\nPest level: <span class='notice'>[pestlevel] / 10</span>"))
to_chat(user, examine_block("\nToxicity level: <span class='notice'>[toxic] / 100</span>"))
to_chat(user, examine_block("\nWater level: <span class='notice'>[waterlevel] / [maxwater]</span>"))
to_chat(user, examine_block("\nNutrition level: <span class='notice'>[reagents.total_volume] / [maxnutri]</span>"))
to_chat(user, examine_block("<br/>"))
msg += "<B>No plant found.</B>\n"
msg += "Weed level: [span_notice("[weedlevel] / [HYDRO_MAX_WEED]")]\n"
msg += "Pest level: [span_notice("[pestlevel] / [HYDRO_MAX_PEST]")]\n"
msg += "Toxicity level: [span_notice("[toxic] / [HYDRO_MAX_TOXIC]")]\n"
msg += "Water level: [span_notice("[waterlevel] / [maxwater]")]\n"
msg += "Nutrition level: [span_notice("[reagents.total_volume] / [maxnutri]")]\n"
to_chat(user, examine_block(msg))
return

else if(istype(O, /obj/item/cultivator))
Expand Down Expand Up @@ -671,7 +677,10 @@
if(!anchored)
return
self_sustaining = !self_sustaining
idle_power_usage = self_sustaining ? 1250 : 0
if(self_sustaining)
set_active_power()
else
set_idle_power()
to_chat(user, "<span class='notice'>You [self_sustaining ? "activate" : "deactivated"] [src]'s autogrow function[self_sustaining ? ", maintaining the tray's health while using high amounts of power" : ""].")
update_appearance()

Expand Down Expand Up @@ -702,7 +711,7 @@
desc = initial(desc)
TRAY_NAME_UPDATE
if(self_sustaining) //No reason to pay for an empty tray.
idle_power_usage = 0
set_idle_power()
self_sustaining = FALSE
update_appearance()

Expand All @@ -718,13 +727,13 @@
plant_health = clamp(plant_health + adjustamt, 0, myseed.endurance)

/obj/machinery/hydroponics/proc/adjustToxic(adjustamt)
toxic = clamp(toxic + adjustamt, 0, 100)
toxic = clamp(toxic + adjustamt, 0, HYDRO_MAX_TOXIC)

/obj/machinery/hydroponics/proc/adjustPests(adjustamt)
pestlevel = clamp(pestlevel + adjustamt, 0, 10)
pestlevel = clamp(pestlevel + adjustamt, 0, HYDRO_MAX_PEST)

/obj/machinery/hydroponics/proc/adjustWeeds(adjustamt)
weedlevel = clamp(weedlevel + adjustamt, 0, 10)
weedlevel = clamp(weedlevel + adjustamt, 0, HYDRO_MAX_WEED)

/obj/machinery/hydroponics/proc/spawnplant() // why would you put strange reagent in a hydro tray you monster I bet you also feed them blood
var/list/livingplants = list(/mob/living/simple_animal/hostile/tree, /mob/living/simple_animal/hostile/killertomato)
Expand Down
44 changes: 22 additions & 22 deletions code/modules/hydroponics/seeds.dm
Original file line number Diff line number Diff line change
Expand Up @@ -390,29 +390,29 @@
/obj/item/seeds/proc/get_analyzer_text() //in case seeds have something special to tell to the analyzer
var/text = ""
if(!get_gene(/datum/plant_gene/trait/plant_type/weed_hardy) && !get_gene(/datum/plant_gene/trait/plant_type/fungal_metabolism) && !get_gene(/datum/plant_gene/trait/plant_type/alien_properties))
text += "- Plant type: Normal plant\n"
text += "- Plant type: [span_notice("Normal plant\n")]"
if(get_gene(/datum/plant_gene/trait/plant_type/weed_hardy))
text += "- Plant type: Weed. Can grow in nutrient-poor soil.\n"
text += "- Plant type: [span_notice("Weed. Can grow in nutrient-poor soil.\n")]"
if(get_gene(/datum/plant_gene/trait/plant_type/fungal_metabolism))
text += "- Plant type: Mushroom. Can grow in dry soil.\n"
text += "- Plant type: [span_notice("Mushroom. Can grow in dry soil.\n")]"
if(get_gene(/datum/plant_gene/trait/plant_type/crystal))
text += "- Plant type: Crystal. Revitalizes soil.\n"
text += "- Plant type: [span_notice("Crystal. Revitalizes soil.\n")]"
if(get_gene(/datum/plant_gene/trait/plant_type/alien_properties))
text += "- Plant type: <span class='warning'>UNKNOWN</span> \n"
text += "- Plant type: [span_warning("UNKNOWN\n")]"
if(potency != UNHARVESTABLE)
text += "- Potency: [potency]\n"
text += "- Potency: [span_notice("[potency]\n")]"
if(yield != UNHARVESTABLE)
text += "- Yield: [yield]\n"
text += "- Maturation speed: [maturation]\n"
text += "- Yield: [span_notice("[yield]\n")]"
text += "- Maturation speed: [span_notice("[maturation]\n")]"
if(yield != UNHARVESTABLE)
text += "- Production speed: [production]\n"
text += "- Endurance: [endurance]\n"
text += "- Lifespan: [lifespan]\n"
text += "- Instability: [instability]\n"
text += "- Weed Growth Rate: [weed_rate]\n"
text += "- Weed Vulnerability: [weed_chance]\n"
text += "- Production speed: [span_notice("[production]\n")]"
text += "- Endurance: [span_notice("[endurance]\n")]"
text += "- Lifespan: [span_notice("[lifespan]\n")]"
text += "- Instability: [span_notice("[instability]\n")]"
text += "- Weed Growth Rate: [span_notice("[weed_rate]\n")]"
text += "- Weed Vulnerability: [span_notice("[weed_chance]\n")]"
if(rarity)
text += "- Species Discovery Value: [rarity]\n"
text += "- Species Discovery Value: [span_notice("[rarity]\n")]"
var/all_traits = ""
for(var/datum/plant_gene/trait/traits in genes)
if(istype(traits, /datum/plant_gene/trait/plant_type))
Expand All @@ -427,20 +427,20 @@

/obj/item/seeds/attackby(obj/item/O, mob/user, params)
if (istype(O, /obj/item/plant_analyzer))
to_chat(user, "<span class='info'>*---------*\n This is \a <span class='name'>[src]</span>.</span>")
var/msg = "This is \a <span class='name'>[src]</span>."
var/text
var/obj/item/plant_analyzer/P_analyzer = O
if(P_analyzer.scan_mode == PLANT_SCANMODE_STATS)
text = get_analyzer_text()
if(text)
to_chat(user, "<span class='notice'>[text]</span>")
msg += "\n[text]"
if(reagents_add && P_analyzer.scan_mode == PLANT_SCANMODE_CHEMICALS)
to_chat(user, "<span class='notice'>- Plant Reagents -</span>")
to_chat(user, "<span class='notice'>*---------*</span>")
msg += "\n- Plant Reagents -"
msg += "\n*---------*"
for(var/datum/plant_gene/reagent/Gene in genes)
to_chat(user, "<span class='notice'>- [Gene.get_name()] -</span>")
to_chat(user, "<span class='notice'>*---------*</span>")

msg += "\n<span class='notice'>- [Gene.get_name()] -</span>"
msg += "\n*---------*"
to_chat(user, examine_block(msg))

return

Expand Down

0 comments on commit 4bb50ce

Please sign in to comment.