diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 30abdbc24d7..c0fb78c1e57 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -167,6 +167,7 @@ GLOBAL_PROTECT(admin_verbs_debug) /client/proc/set_dynex_scale, /client/proc/cmd_display_del_log, /client/proc/outfit_manager, + /client/proc/generate_wikichem_list, /client/proc/modify_goals, /client/proc/debug_huds, /client/proc/map_template_load, diff --git a/code/modules/reagents/chemistry/chem_wiki_render.dm b/code/modules/reagents/chemistry/chem_wiki_render.dm new file mode 100644 index 00000000000..fb62a332f6c --- /dev/null +++ b/code/modules/reagents/chemistry/chem_wiki_render.dm @@ -0,0 +1,198 @@ +//Generates a wikitable txt file for use with the wiki - does not support productless reactions at the moment +/client/proc/generate_wikichem_list() + set category = "Debug" + set name = "Parse Wikichems" + + //If we're a reaction product + var/prefix_reaction = {"{| class=\"wikitable sortable\" style=\"width:100%; text-align:left; border: 3px solid #FFDD66; cellspacing=0; cellpadding=2; background-color:white;\" +! scope=\"col\" style='width:150px; background-color:#FFDD66;'|Name +! scope=\"col\" class=\"unsortable\" style='background-color:#FFDD66;'|Formula +! scope=\"col\" class=\"unsortable\" style='background-color:#FFDD66; width:170px;'|Reaction conditions +! scope=\"col\" class=\"unsortable\" style='background-color:#FFDD66;'|Description +! scope=\"col\" class=\"unsortable\" style='background-color:#FFDD66;'|Chemical properties +|- +"} + + var/input_text = stripped_input(usr, "Input a name of a reagent, or a series of reagents split with a comma (no spaces) to get it's wiki table entry", "Recipe") //95% of the time, the reagent type is a lowercase, no spaces / underscored version of the name + if(!input_text) + to_chat(usr, "Input was blank!") + return + text2file(prefix_reaction, "[GLOB.log_directory]/chem_parse.txt") + var/list/names = splittext("[input_text]", ",") + + for(var/name in names) + var/datum/reagent/reagent = find_reagent_object_from_type(get_chem_id(name)) + if(!reagent) + to_chat(usr, "Could not find [name]. Skipping.") + continue + //Get reaction + var/list/reactions = GLOB.chemical_reactions_list_product_index[reagent.type] + + if(!length(reactions)) + to_chat(usr, "Could not find [name] reaction! Continuing anyways.") + var/single_parse = generate_chemwiki_line(reagent, null) + text2file(single_parse, "[GLOB.log_directory]/chem_parse.txt") + continue + + for(var/datum/chemical_reaction/reaction as anything in reactions) + var/single_parse = generate_chemwiki_line(reagent, reaction) + text2file(single_parse, "[GLOB.log_directory]/chem_parse.txt") + text2file("|}", "[GLOB.log_directory]/chem_parse.txt") //Cap off the table + to_chat(usr, "Done! Saved file to (wherever your root folder is, i.e. where the DME is)/[GLOB.log_directory]/chem_parse.txt OR use the Get Current Logs verb under the Admin tab. (if you click Open, and it does nothing, that's because you've not set a .txt default program! Try downloading it instead, and use that file to set a default program! Have a nice day!") + + +/// Generate the big list of reagent based reactions. +/proc/generate_chemwiki_line(datum/reagent/reagent, datum/chemical_reaction/reaction) + //name | Reagent pH | reagents | reaction temp | Overheat temp | pH range | Kinetics | description | OD level | Addiction level | Metabolism rate | impure chem | inverse chem + + //NAME + //!style='background-color:#FFEE88;'|{{anchor|Synthetic-derived growth factor}}Synthetic-derived growth factor + var/outstring = "!style='background-color:#FFEE88;'|{{anchor|[reagent.name]}}[reagent.name]" + //Impurities + if(istype(reagent, /datum/reagent/impurity)) + outstring += "\n
Impure reagent" + + if(istype(reagent, /datum/reagent/inverse)) + outstring += "\n
Inverse reagent" + + else + var/datum/reagent/impure_reagent = GLOB.chemical_reagents_list[reagent.impure_chem] + if(impure_reagent) + outstring += "\n
Impurity: \[\[#[impure_reagent.name]|[impure_reagent.name]\]\]" + + var/datum/reagent/inverse_reagent = GLOB.chemical_reagents_list[reagent.inverse_chem] + if(inverse_reagent) + outstring += "\n
Inverse: \[\[#[inverse_reagent.name]|[inverse_reagent.name]\]\] <[reagent.inverse_chem_val*100]%" + + var/datum/reagent/failed_reagent = GLOB.chemical_reagents_list[reagent.failed_chem] + if(failed_reagent && reaction) + outstring += "\n
Failed: \[\[#[failed_reagent.name]|[failed_reagent.name]\]\] <[reaction.purity_min*100]%" + var/ph_color + CONVERT_PH_TO_COLOR(reagent.ph, ph_color) + outstring += "\n
pH: [reagent.ph]" + outstring += "\n|" + + //RECIPE + //|{{RecursiveChem/Oil}} + if(reaction) + outstring += "{{RecursiveChem/[reagent.name]}}" + outstring += "\n|" + + //Reaction conditions + //min temp + if(reaction.is_cold_recipe) + outstring += "Cold reaction\n
" + outstring += "Min temp: [reaction.required_temp]K\n
Overheat: [reaction.overheat_temp]K\n
Optimal pH: [reaction.optimal_ph_min] to [reaction.optimal_ph_max]" + + //Overly impure levels + if(reaction.purity_min) + outstring += "\n
Unstable purity: <[reaction.purity_min*100]%" + + //Kinetics + var/thermic = reaction.thermic_constant + if(reaction.reaction_flags & REACTION_HEAT_ARBITARY) + thermic *= 100 //Because arbitary is a lower scale + switch(thermic) + if(-INFINITY to -1500) + outstring += "\n
Overwhelmingly endothermic" + if(-1500 to -1000) + outstring += "\n
Extremely endothermic" + if(-1000 to -500) + outstring += "\n
Strongly endothermic" + if(-500 to -200) + outstring += "\n
Moderately endothermic" + if(-200 to -50) + outstring += "\n
Endothermic" + if(-50 to 0) + outstring += "\n
Weakly endothermic" + if(0) + outstring += "\n
" + if(0 to 50) + outstring += "\n
Weakly Exothermic" + if(50 to 200) + outstring += "\n
Exothermic" + if(200 to 500) + outstring += "\n
Moderately exothermic" + if(500 to 1000) + outstring += "\n
Strongly exothermic" + if(1000 to 1500) + outstring += "\n
Extremely exothermic" + if(1500 to INFINITY) + outstring += "\n
Overwhelmingly exothermic" + //if("cheesey") + //outstring += "
Dangerously Cheesey" + + //pH drift + if(reaction.results) + var/start_ph = 0 + var/reactant_vol = 0 + for(var/typepath in reaction.required_reagents) + var/datum/reagent/req_reagent = GLOB.chemical_reagents_list[typepath] + start_ph += req_reagent.ph * reaction.required_reagents[typepath] + reactant_vol += reaction.required_reagents[typepath] + + var/product_vol = 0 + var/end_ph = 0 + for(var/typepath in reaction.results) + var/datum/reagent/prod_reagent = GLOB.chemical_reagents_list[typepath] + end_ph += prod_reagent.ph * reaction.results[typepath] + product_vol += reaction.results[typepath] + + if(reactant_vol || product_vol) + start_ph = start_ph / reactant_vol + end_ph = end_ph / product_vol + var/sum_change = end_ph - start_ph + sum_change += reaction.H_ion_release + + if(sum_change > 0) + outstring += "\n
H+ consuming" + else if (sum_change < 0) + outstring += "\n
H+ producing" + else + to_chat(usr, "[reaction] doesn't have valid product and reagent volumes! Please tell Fermi.") + else + if(reaction.H_ion_release > 0) + outstring += "\n
H+ consuming" + else if (reaction.H_ion_release < 0) + outstring += "\n
H+ producing" + + //container + if(reaction.required_container) + var/list/names = splittext("[reaction.required_container]", "/") + var/container_name = "[names[names.len]] [names[names.len-1]]" + container_name = replacetext(container_name, "_", " ") + outstring += "\n
[container_name]" + + //Warn if it's dangerous + if(reaction.reaction_tags & REACTION_TAG_DANGEROUS) + outstring += "\n
Dangerous" + outstring += "\n|" + + //Description + outstring += "[reagent.description]" + outstring += "\n|" + + //Chemical properties - *2 because 1 tick is every 2s + outstring += "Rate: [reagent.metabolization_rate*2]u/tick\n
Unreacted purity: [reagent.creation_purity*100]%[(reagent.overdose_threshold ? "\n
OD: [reagent.overdose_threshold]u" : "")]" + + if(length(reagent.addiction_types)) + outstring += "\n
Addictions:" + for(var/entry in reagent.addiction_types) + var/datum/addiction/ref = SSaddiction.all_addictions[entry] + switch(reagent.addiction_types[entry]) + if(-INFINITY to 0) + continue + if(0 to 5) + outstring += "\n
Weak [ref.name]" + if(5 to 10) + outstring += "\n
[ref.name]" + if(10 to 20) + outstring += "\n
Strong [ref.name]" + if(20 to INFINITY) + outstring += "\n
Potent [ref.name]" + + if(reagent.chemical_flags & REAGENT_DEAD_PROCESS) + outstring += "\n
Works on the dead" + + outstring += "\n|-" + return outstring diff --git a/tgstation.dme b/tgstation.dme index 92e731ccd1f..c2c12d18cf0 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -3018,6 +3018,7 @@ #include "code\modules\reagents\chem_splash.dm" #include "code\modules\reagents\reagent_containers.dm" #include "code\modules\reagents\reagent_dispenser.dm" +#include "code\modules\reagents\chemistry\chem_wiki_render.dm" #include "code\modules\reagents\chemistry\colors.dm" #include "code\modules\reagents\chemistry\equilibrium.dm" #include "code\modules\reagents\chemistry\holder.dm"