Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allergen bugfix #4252

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion code/datums/quirks/negative_quirks/allergic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
/datum/reagent/medicine/omnizine/godblood,
/datum/reagent/medicine/cordiolis_hepatico,
/datum/reagent/medicine/synaphydramine,
/datum/reagent/medicine/diphenhydramine
/datum/reagent/medicine/diphenhydramine,
/datum/reagent/medicine/changelingadrenaline,
/datum/reagent/medicine/spaceacillin
)
var/allergy_string

Expand Down
79 changes: 79 additions & 0 deletions monkestation/code/modules/wiki_templater/chemistry_templates.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/datum/wiki_template/chemical_reaction/proc/generate_output(datum/chemical_reaction/recipe)
var/name_string = "" // The reaction name
var/reqs_string = "" // List of required reagents and quantities
var/results_string = "" // List of resulting chemicals and quantities
var/temp_string = "" // Temperature details
// Reaction name from results or chemical reaction itself
for (var/atom/item_type as anything in recipe.results)
name_string = item_type.name // Accessing the name of the instantiated item

// Process the results (produced chemicals and quantities)
if (istype(recipe.results, /list))
for (var/atom/item_type as anything in recipe.results)
var/quantity = recipe.results[item_type] // Quantity produced
var/item_name = item_type.name // Access the 'name' of the reagent
results_string += "- [quantity]u [item_name]<br>"
else
results_string = "No results defined for this reaction.<br>"

// Process the required reagents (needed chemicals and quantities)
if (istype(recipe.required_reagents, /list)) // Ensure required_reagents is defined
for (var/atom/item_type as anything in recipe.required_reagents)
var/quantity = recipe.required_reagents[item_type] // Quantity required
var/item_name = item_type.name // Access the 'name' of the reagent
reqs_string += "- [quantity]u [item_name]<br>"
else
reqs_string = "No required reagents defined for this reaction.<br>"

// Set temperature details
temp_string = "Required Temp: [recipe.required_temp]°C<br>Optimal Temp: [recipe.optimal_temp]°C<br>Overheat Temp: [recipe.overheat_temp]°C<br>"

// Finalize the template with the desired structure
var/created_template = "### [name_string] \n"
created_template += "| --- | --- | --- | \n"
created_template += "<a name=\"[name_string]\"></a><td rowspan=2 width=300px height=150px> <center> <img src=\"/wrench.png\" width=96 height=96> <br>[name_string] <td width=225> <center> Chemical Reaction Category | \n"
created_template += "| | Required Temp: [recipe.required_temp]°C<br>Optimal Temp: [recipe.optimal_temp]°C<br>Overheat Temp: [recipe.overheat_temp]°C<br> | \n"
created_template += "| | Required Reagents: <br>[reqs_string] |||\n"
created_template += " <td colspan=2> <center> Resulting Chemicals | \n"
created_template += "| | [results_string] |||\n"

// Ensure all required fields are non-empty before generating template
if (reqs_string == "" || results_string == "" || temp_string == "")
return null // Skip this entry if any required string is empty

// If no results, then no name to display
if (results_string == "")
return null

return created_template

// Test proc to verify individual recipe templates
/proc/test_generate_chemical_reaction_wiki()
var/datum/chemical_reaction/medicine/helbital = new /datum/chemical_reaction/medicine/helbital // Example chemical reaction (helbital)
var/datum/wiki_template/chemical_reaction/wiki_template = new /datum/wiki_template/chemical_reaction
var/test_output = wiki_template.generate_output(helbital)
return test_output

GLOBAL_VAR_INIT(chemical_reaction_wiki, "")
GLOBAL_VAR_INIT(chemical_reaction_wiki_failed, "")

/proc/generate_chemical_reaction_wiki_templates()
var/mega_string = ""
var/failed_templates = ""
var/datum/wiki_template/chemical_reaction/wiki_template = new /datum/wiki_template/chemical_reaction

// Loop through all chemical reactions to generate templates
for (var/type in typesof(/datum/chemical_reaction)) // Search for medicine reactions only
var/datum/chemical_reaction/medicine/new_recipe = new type
var/output = wiki_template.generate_output(new_recipe)

if (output == null) // Check for failed templates
failed_templates += "Failed to generate.<br>"
else
mega_string += "[output] \n"

GLOB.chemical_reaction_wiki = mega_string
GLOB.chemical_reaction_wiki_failed = failed_templates
mega_string += "This many templates failed to build: [length(failed_templates)] \n"
// Display or log results
return mega_string
68 changes: 68 additions & 0 deletions monkestation/code/modules/wiki_templater/construction_templates.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/datum/wiki_template/construction/proc/generate_output(obj/machinery/machine)
var/name_string = ""
var/reqs_string = ""
var/cat_string = ""

// Use the machine name and description directly
name_string = capitalize(machine.name)
cat_string = "[initial(machine.desc)]<br>"

// Iterate over component_parts if available for construction requirements
if (istype(machine.component_parts, /list))
for (var/atom/item_type as anything in machine.component_parts)
var/quantity = machine.component_parts[item_type]
var/part_name = capitalize(item_type.name)
reqs_string += "- [quantity]x [part_name]<br>"

// Finalize requirements and category strings
var/generated_requirements = ""
if (reqs_string)
generated_requirements += "**Required Components:** <br>[reqs_string]"

var/generated_category = ""
if (cat_string)
generated_category += "[cat_string]"

// Create the wiki template for output
var/created_template = "## [name_string] \n"
created_template += "| --- | --- | --- | \n"
created_template += "<a name=\"[name_string]\"></a><td rowspan=2 width=300px height=150px> <center> <img src=\"/sink.png\" width=96 height=96> <br>[name_string] <td width=225> <center> Machine Category | <center>Requirements | \n"
created_template += "| | [generated_category] | N/A \n"
created_template += " <td colspan=2> <center> Construction Requirements | \n"
created_template += " | | [generated_requirements] |||\n"

// Ensure all required fields are non-empty before generating template
if (name_string == "" || generated_requirements == "" || generated_category == "")
return null // Skip this entry if any required string is empty
return created_template

// Test proc to verify individual machine templates
/proc/test_generate_machine_wiki()
var/obj/machinery/machine = new /obj/machinery/dna_scannernew // Example machine
var/datum/wiki_template/construction/wiki_template = new /datum/wiki_template/construction
var/test_output = wiki_template.generate_output(machine)
return test_output

GLOBAL_VAR_INIT(machine_wiki, "")
GLOBAL_VAR_INIT(machine_wiki_failed, "")

proc/generate_machine_wiki_templates()

Check warning on line 49 in monkestation/code/modules/wiki_templater/construction_templates.dm

View workflow job for this annotation

GitHub Actions / Run Linters

relatively pathed proc defined here
var/mega_string = ""
var/failed_templates = ""
var/datum/wiki_template/construction/wiki_template = new /datum/wiki_template/construction

// Loop through all machinery types to generate templates
for (var/type in typesof(/obj/machinery))
var/obj/machinery/new_machine = new type
var/output = wiki_template.generate_output(new_machine)

if (output == null) // Check for failed templates
failed_templates += "[new_machine.name] failed to generate.<br>"
else
mega_string += "[output] \n"

GLOB.machine_wiki = mega_string
GLOB.machine_wiki_failed = failed_templates
mega_string += "This many templates failed to build: [length(failed_templates)] \n"
// Display or log results
return mega_string
73 changes: 73 additions & 0 deletions monkestation/code/modules/wiki_templater/food_templates.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/datum/wiki_template/food/proc/generate_output(datum/crafting_recipe/food/recipe)
var/name_string = ""
var/reqs_string = ""
var/cat_string = ""
name_string = capitalize(recipe.name)
// Iterate over reqs to create a readable list of ingredients
if (istype(recipe.reqs, /list))
for (var/atom/item_type as anything in recipe.reqs)

var/quantity = recipe.reqs[item_type]
var/liquidornot = new item_type

// Only add "units" if the item is a reagent
if (istype(liquidornot, /datum/reagent))
var/item_name = capitalize(item_type.name)
reqs_string += "- [quantity]u [item_name]<br>"
else
var/item_name = capitalize(item_type.name)
reqs_string += "- [quantity]x [item_name]<br>"

// Set the category string directly without looping, since category is a single value
cat_string = "[initial(recipe.category)]<br>"

// Check for missing components in requirements and category strings
var/generated_requirements = ""
if (reqs_string)
generated_requirements += "**Required Ingredients:** <br>[reqs_string]"

var/generated_category = ""
if (cat_string)
generated_category += "[cat_string]"

// Create the template for output
var/created_template = "## [name_string] \n"
created_template += "| --- | --- | --- | \n"
created_template += "<a name=\"[name_string]\"></a><td rowspan=2 width = 300px height=150px> <center> <img src =\"/wrench.png\" width = 96 height = 96> <br>[name_string] <td width=225> <center> Food Category | <center>Machine Required | \n"
created_template += "| | [generated_category] | N/A \n"
created_template += " <td colspan=2> <center> Recipe Requirements | \n"
created_template += " | | [generated_requirements] |||\n"
// Ensure all required fields are non-empty before generating template
if (name_string == "" || generated_requirements == "" || generated_category == "")
return null // Skip this entry if any required string is empty
return created_template

// Test proc to verify individual recipe templates
/proc/test_generate_food_wiki()
var/datum/crafting_recipe/food/recipe = new /datum/crafting_recipe/food/birthdaycake
var/datum/wiki_template/food/wiki_template = new /datum/wiki_template/food
var/test_output = wiki_template.generate_output(recipe)
return test_output

GLOBAL_VAR_INIT(food_wiki, "")
GLOBAL_VAR_INIT(food_wiki_failed, "")

/proc/generate_food_wiki_templates()
var/mega_string = ""
var/failed_templates = ""
var/datum/wiki_template/food/wiki_template = new /datum/wiki_template/food

for (var/type in typesof(/datum/crafting_recipe/food))
var/datum/crafting_recipe/food/new_recipe = new type
var/output = wiki_template.generate_output(new_recipe)

if (output == null) // Check for failed templates
failed_templates += "[new_recipe.name] failed to generate.<br>"
else
mega_string += "[output] \n"

GLOB.food_wiki = mega_string
GLOB.food_wiki_failed = failed_templates
mega_string += "This many templates failed to build: [length(failed_templates)] \n"
// Display or log results
return mega_string
3 changes: 3 additions & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -8378,6 +8378,9 @@
#include "monkestation\code\modules\visual_changes\explosions.dm"
#include "monkestation\code\modules\visual_changes\gun_smoke.dm"
#include "monkestation\code\modules\visual_changes\splatter.dm"
#include "monkestation\code\modules\wiki_templater\chemistry_templates.dm"
#include "monkestation\code\modules\wiki_templater\construction_templates.dm"
#include "monkestation\code\modules\wiki_templater\food_templates.dm"
#include "monkestation\code\modules\wiki_templater\templates.dm"
#include "monkestation\code\modules\wiki_templater\test_generate.dm"
#include "monkestation\code\modules\wiremod_chem\chemical_list.dm"
Expand Down
Loading