-
-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may not be viewable. --> <!-- You can view Contributing.MD for a detailed description of the pull request process. --> ## About The Pull Request I said I would do this long ago, then I failed because I made it too complex. This is a far simpler solution that mostly uses what we already have. An example is [here](https://shiptest.net/wiki/User:Mark/autochem-test) but the final result will be [here](https://shiptest.net/wiki/Template:Autowiki/Content/Reagents) no I'm not off of my hiatus I just got hit with inspiration and coded this ## Why It's Good For The Game Automatically updating and always complete reagents wiki with all the bells and whistles of recursive chems and additional info ## Changelog :cl: add: Autowiki generated reagents list page /:cl: <!-- Both :cl:'s are required for the changelog to work! You can put your name to the right of the first :cl: if you want to overwrite your GitHub username as author ingame. --> <!-- You can use multiple of the same prefix (they're only used for the icon ingame) and delete the unneeded ones. Despite some of the tags, changelogs should generally represent how a player might be affected by the changes rather than a summary of the PR's contents. -->
- Loading branch information
1 parent
9e629b3
commit 26a2f4d
Showing
9 changed files
with
124 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
Templates: | ||
Autowiki/Reaction | ||
{{{chems|ERROR}}} {{#if: {{{temperature|}}} | <br />Temperature {{{temperature}}} | }} {{#if: {{{container|}}} | <br />Needs container "{{{container}}}" | }} <br/>Makes {{{volume|1}}}u | ||
Autowiki/Reagent | ||
{{#if: {{{tooltip|}}} | {{Tooltip|{{{volume}}} part [[#{{{name}}}|{{{name}}}]]|{{{tooltip}}}|FEF6E7}} | {{{volume}}} part {{{name}}} }} | ||
*/ | ||
|
||
/datum/autowiki/reactions | ||
page = "Template:Autowiki/Content/Reactions" | ||
|
||
/datum/autowiki/reactions/generate() | ||
var/list/output = list() | ||
|
||
var/list/mixable_reagents = list() | ||
var/list/all_reactions = list() | ||
for(var/type in subtypesof(/datum/chemical_reaction)) | ||
var/datum/chemical_reaction/reaction = new type | ||
all_reactions += reaction | ||
mixable_reagents |= reaction.results | ||
|
||
for(var/datum/chemical_reaction/reaction as anything in all_reactions) | ||
var/required_chems = "" | ||
for(var/datum/reagent/required_chem_type as anything in reaction.required_reagents) | ||
var/has_tooltip = (required_chem_type in mixable_reagents) && !(required_chem_type in reaction.results) && !(required_chem_type in GLOB.base_reagents) | ||
required_chems += format_required_reagent(required_chem_type, reaction.required_reagents[required_chem_type], has_tooltip) | ||
|
||
for(var/datum/reagent/required_catalyst_type as anything in reaction.required_catalysts) | ||
var/has_tooltip = (required_catalyst_type in mixable_reagents) && !(required_catalyst_type in reaction.results) && !(required_catalyst_type in GLOB.base_reagents) | ||
required_chems += format_required_reagent(required_catalyst_type, reaction.required_catalysts[required_catalyst_type], has_tooltip, "Catalyst") | ||
|
||
for(var/datum/reagent/result_chem_type as anything in reaction.results) | ||
var/result_name = escape_value(initial(result_chem_type.name)) | ||
var/list/details = list("volume" = reaction.results[result_chem_type], "chems" = required_chems, "name" = result_name) | ||
|
||
if(reaction.required_temp > 0) | ||
details["temperature"] = "[reaction.is_cold_recipe ? "below" : "above"] [reaction.required_temp]K" | ||
|
||
if(reaction.required_container) | ||
details["container"] = "[escape_value(initial(reaction.required_container.name))]" | ||
|
||
var/description = include_template("Autowiki/Reaction", details) | ||
if(result_name in output) | ||
output[result_name] += "<br />OR<br />[description]" | ||
else | ||
output[result_name] = description | ||
|
||
return output | ||
|
||
/datum/autowiki/reactions/proc/format_required_reagent(datum/reagent/required_reagent_type, volume, has_tooltip = FALSE, type) | ||
var/list/details = list( | ||
"volume" = volume, | ||
"name" = escape_value(initial(required_reagent_type.name)) | ||
) | ||
|
||
if(has_tooltip) | ||
details["tooltip"] = include_template("Autowiki/Content/Reactions/[initial(required_reagent_type.name)]") | ||
|
||
if(type) | ||
details["type"] = type | ||
|
||
return include_template("Autowiki/Reagent", details) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,52 @@ | ||
/* | ||
Templates: | ||
Autowiki/Reaction | ||
{{{chems|ERROR}}} {{#if: {{{temperature|}}} | <br />Temperature {{{temperature}}} | }} {{#if: {{{container|}}} | <br />Needs container "{{{container}}}" | }} <br/>Makes {{{volume|1}}}u | ||
Autowiki/Reagent | ||
{{#if: {{{tooltip|}}} | {{Tooltip|{{{volume}}} part [[#{{{name}}}|{{{name}}}]]|{{{tooltip}}}|FEF6E7}} | {{{volume}}} part {{{name}}} }} | ||
*/ | ||
|
||
/datum/autowiki/reagents | ||
page = "Template:Autowiki/Content/Reactions" | ||
page = "Template:Autowiki/Content/Reagents" | ||
|
||
/datum/autowiki/reagents/generate() | ||
var/list/output = list() | ||
var/output = "" | ||
|
||
var/list/mixable_reagents = list() | ||
var/list/all_reactions = list() | ||
for(var/type in subtypesof(/datum/chemical_reaction)) | ||
var/datum/chemical_reaction/reaction = new type | ||
all_reactions += reaction | ||
mixable_reagents |= reaction.results | ||
qdel(reaction) | ||
|
||
for(var/datum/chemical_reaction/reaction as anything in all_reactions) | ||
var/required_chems = "" | ||
for(var/datum/reagent/required_chem_type as anything in reaction.required_reagents) | ||
var/has_tooltip = (required_chem_type in mixable_reagents) && !(required_chem_type in reaction.results) && !(required_chem_type in GLOB.base_reagents) | ||
required_chems += format_required_reagent(required_chem_type, reaction.required_reagents[required_chem_type], has_tooltip) | ||
var/list/categories = list() | ||
|
||
for(var/datum/reagent/required_catalyst_type as anything in reaction.required_catalysts) | ||
var/has_tooltip = (required_catalyst_type in mixable_reagents) && !(required_catalyst_type in reaction.results) && !(required_catalyst_type in GLOB.base_reagents) | ||
required_chems += format_required_reagent(required_catalyst_type, reaction.required_catalysts[required_catalyst_type], has_tooltip, "Catalyst") | ||
for(var/reagent in mixable_reagents) | ||
var/datum/reagent/chem = new reagent | ||
|
||
for(var/datum/reagent/result_chem_type as anything in reaction.results) | ||
var/result_name = escape_value(initial(result_chem_type.name)) | ||
var/list/details = list("volume" = reaction.results[result_chem_type], "chems" = required_chems, "name" = result_name) | ||
LAZYINITLIST(categories[chem.category]) | ||
categories[chem.category] += list(chem) | ||
|
||
if(reaction.required_temp > 0) | ||
details["temperature"] = "[reaction.is_cold_recipe ? "below" : "above"] [reaction.required_temp]K" | ||
for(var/category in sortList(categories)) | ||
output += generate_category(category, categories[category]) | ||
output += "\n" | ||
|
||
if(reaction.required_container) | ||
details["container"] = "[escape_value(initial(reaction.required_container.name))]" | ||
return output | ||
|
||
var/description = include_template("Autowiki/Reaction", details) | ||
if(result_name in output) | ||
output[result_name] += "<br />OR<br />[description]" | ||
else | ||
output[result_name] = description | ||
/datum/autowiki/reagents/proc/generate_category(name, list/datum/reagent/reagents) | ||
var/output = "== [escape_value(name)] ==\n" | ||
|
||
return output | ||
output += "{| class='wikitable sortable' style=width:100%; text-align:left; border: 3px solid #FFDD66; cellspacing=0; cellpadding=2; background-color:white;'\n" | ||
output += "! scope='col' style='width:150px; background-color:#FFDD66;' |Name\n" | ||
output += "! class='unsortable' scope='col' style='width:150px; background-color:#FFDD66;' |Recipe\n" | ||
output += "! class='unsortable' scope='col' style='background-color:#FFDD66;' |Description\n" | ||
output += "! scope='col' | Metabolization Rate\n" | ||
output += "! scope='col' | Overdose Threshold\n" | ||
output += "! scope='col' | Addiction Threshold\n" | ||
output += "|-\n" | ||
|
||
/datum/autowiki/reagents/proc/format_required_reagent(datum/reagent/required_reagent_type, volume, has_tooltip = FALSE, type) | ||
var/list/details = list( | ||
"volume" = volume, | ||
"name" = escape_value(initial(required_reagent_type.name)) | ||
) | ||
reagents = sortList(reagents, /proc/cmp_typepaths_asc) | ||
|
||
if(has_tooltip) | ||
details["tooltip"] = include_template("Autowiki/Content/Reactions/[initial(required_reagent_type.name)]") | ||
for(var/datum/reagent/reagent as anything in reagents) | ||
output += "! style='background-color: #FFEE88;' | [include_template("anchor", list("1" = escape_value(reagent.name)))][escape_value(reagent.name)] <span style='color:[escape_value(reagent.color)];background-color:[escape_value(reagent.color)]'>_</span>\n" | ||
output += "|[include_template("Autowiki/Content/Reactions/[escape_value(reagent.name)]")]\n" | ||
output += "|[escape_value(reagent.description)]\n" | ||
output += "|data-sort-value=[reagent.metabolization_rate]|[reagent.metabolization_rate] units per tick\n" | ||
output += "|[reagent.overdose_threshold || "data-sort-value=0|N/A"]\n" | ||
output += "|[reagent.addiction_threshold || "data-sort-value=0|N/A"]\n" | ||
output += "|-\n" | ||
|
||
if(type) | ||
details["type"] = type | ||
output += "|}\n" | ||
|
||
return include_template("Autowiki/Reagent", details) | ||
return output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters