mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-19 20:15:47 +01:00
Autowiki Stock Parts Template (#76765)
## About The Pull Request
Autowiki functionality for stock parts
stockparts.dm extends the autowiki datum, implementing multiple
functions to upload images of and parse information about all the
craftable stock parts in the game a player is likely to encounter.
The template can be called on the wiki by using
`{{Autowiki/Content/StockParts}}`
[VIEW OUTPUT
HERE](https://tgstation13.org/wiki/Template:Autowiki/Content/StockParts)
## Why It's Good For The Game
Better documentation means lower learning curve, items that are properly
up-to-date is a good start.
This will probably branch into a few other autowiki additions for the
other various items from research, has the potential to lead to a full
documentation of the autolathe if done correctly.
## Changelog
:cl:Senefi
code: Autowiki module for stock parts
fix: Emergency lights no longer runtime when created in nullspace
/🆑
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
/// Automtically generated string list of stock part templates and relevant data for the /tg/station wiki
|
||||
/datum/autowiki/stock_parts
|
||||
page = "Template:Autowiki/Content/StockParts"
|
||||
|
||||
var/list/battery_whitelist = list(
|
||||
/obj/item/stock_parts/cell,
|
||||
/obj/item/stock_parts/cell/high,
|
||||
/obj/item/stock_parts/cell/super,
|
||||
/obj/item/stock_parts/cell/hyper,
|
||||
/obj/item/stock_parts/cell/bluespace,
|
||||
)
|
||||
|
||||
/datum/autowiki/stock_parts/generate()
|
||||
var/output = ""
|
||||
|
||||
for(var/part_type in subtypesof(/obj/item/stock_parts))
|
||||
var/obj/item/stock_parts/type_to_check = part_type
|
||||
if(initial(type_to_check.abstract_type) == part_type)
|
||||
continue
|
||||
|
||||
if(!battery_whitelist.Find(part_type) && ispath(part_type, /obj/item/stock_parts/cell))
|
||||
continue
|
||||
|
||||
var/obj/item/stock_parts/stock_part = new part_type()
|
||||
|
||||
var/datum/design/recipe = find_design(stock_part)
|
||||
|
||||
if(!recipe)
|
||||
continue
|
||||
|
||||
var/datum/techweb_node/required_node = find_research(recipe)
|
||||
|
||||
var/list/entry_contents = list()
|
||||
|
||||
entry_contents["name"] = escape_value(format_text(stock_part.name))
|
||||
entry_contents["icon"] = escape_value(format_text(create_icon(stock_part)))
|
||||
entry_contents["desc"] = escape_value(format_text(stock_part.desc))
|
||||
entry_contents["tier"] = escape_value(format_text("[stock_part.rating]"))
|
||||
entry_contents["sources"] = escape_value(format_text(generate_source_list(recipe)))
|
||||
entry_contents["node"] = escape_value(format_text(required_node.display_name))
|
||||
entry_contents["materials"] = escape_value(format_text(generate_material_list(recipe)))
|
||||
|
||||
output += include_template("Autowiki/StockPart", entry_contents)
|
||||
|
||||
return output
|
||||
|
||||
/datum/autowiki/stock_parts/proc/find_design(obj/item/stock_parts/stock_part)
|
||||
for(var/design_type in subtypesof(/datum/design))
|
||||
var/datum/design/recipe = new design_type()
|
||||
|
||||
if(ispath(recipe.build_path, stock_part.type))
|
||||
return recipe
|
||||
|
||||
/datum/autowiki/stock_parts/proc/find_research(datum/design/recipe)
|
||||
for(var/node_type in subtypesof(/datum/techweb_node))
|
||||
var/datum/techweb_node/node = new node_type()
|
||||
|
||||
if(node.design_ids.Find(recipe.id))
|
||||
return node
|
||||
|
||||
/datum/autowiki/stock_parts/proc/create_icon(obj/item/stock_parts/stock_part)
|
||||
var/filename = SANITIZE_FILENAME(escape_value(stock_part.icon_state))
|
||||
upload_icon(icon(stock_part.icon, stock_part.icon_state, SOUTH, 1, FALSE), filename)
|
||||
|
||||
return "Autowiki-[filename].png"
|
||||
|
||||
/datum/autowiki/stock_parts/proc/generate_source_list(datum/design/recipe)
|
||||
var/list/source_list = list()
|
||||
|
||||
if(recipe.build_type & PROTOLATHE)
|
||||
source_list.Add("Protolathe")
|
||||
|
||||
if(recipe.build_type & AWAY_LATHE)
|
||||
source_list.Add("Ancient Protolathe")
|
||||
|
||||
if(recipe.build_type & AUTOLATHE)
|
||||
source_list.Add("Autolathe")
|
||||
|
||||
return source_list.Join(", ")
|
||||
|
||||
/datum/autowiki/stock_parts/proc/generate_material_list(datum/design/recipe)
|
||||
var/list/materials = list()
|
||||
|
||||
for(var/ingredient_type in recipe.materials)
|
||||
var/datum/material/ingredient = new ingredient_type()
|
||||
|
||||
materials += "[recipe.materials[ingredient_type]] [ingredient.name]"
|
||||
|
||||
return materials.Join("<br>")
|
||||
@@ -461,9 +461,10 @@
|
||||
|
||||
/obj/item/stock_parts/cell/emergency_light/Initialize(mapload)
|
||||
. = ..()
|
||||
var/area/A = get_area(src)
|
||||
if(!A.lightswitch || !A.light_power)
|
||||
charge = 0 //For naturally depowered areas, we start with no power
|
||||
var/area/area = get_area(src)
|
||||
if(area)
|
||||
if(!area.lightswitch || !area.light_power)
|
||||
charge = 0 //For naturally depowered areas, we start with no power
|
||||
|
||||
/obj/item/stock_parts/cell/crystal_cell
|
||||
name = "crystal power cell"
|
||||
|
||||
@@ -232,6 +232,8 @@ If you create T5+ please take a pass at mech_fabricator.dm. The parts being good
|
||||
///Used when a base part has a different name to higher tiers of part. For example, machine frames want any servo and not just a micro-servo.
|
||||
var/base_name
|
||||
var/energy_rating = 1
|
||||
///The generic category type that the stock part belongs to. Generic objects that should not be instantiated should have the same type and abstract_type
|
||||
var/abstract_type = /obj/item/stock_parts
|
||||
|
||||
/obj/item/stock_parts/Initialize(mapload)
|
||||
. = ..()
|
||||
@@ -402,6 +404,11 @@ If you create T5+ please take a pass at mech_fabricator.dm. The parts being good
|
||||
|
||||
// Subspace stock parts
|
||||
|
||||
/obj/item/stock_parts/subspace
|
||||
name = "subspace stock part"
|
||||
desc = "What?"
|
||||
abstract_type = /obj/item/stock_parts/subspace
|
||||
|
||||
/obj/item/stock_parts/subspace/ansible
|
||||
name = "subspace ansible"
|
||||
icon_state = "subspace_ansible"
|
||||
|
||||
@@ -3008,6 +3008,7 @@
|
||||
#include "code\modules\autowiki\autowiki.dm"
|
||||
#include "code\modules\autowiki\pages\base.dm"
|
||||
#include "code\modules\autowiki\pages\soup.dm"
|
||||
#include "code\modules\autowiki\pages\stockparts.dm"
|
||||
#include "code\modules\autowiki\pages\techweb.dm"
|
||||
#include "code\modules\autowiki\pages\vending.dm"
|
||||
#include "code\modules\awaymissions\away_props.dm"
|
||||
|
||||
Reference in New Issue
Block a user