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

Autolathe Stuff #19194

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
9 changes: 9 additions & 0 deletions aurorastation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,15 @@
#include "code\game\machinery\atmoalter\scrubber.dm"
#include "code\game\machinery\autolathe\autolathe.dm"
#include "code\game\machinery\autolathe\autolathe_datums.dm"
#include "code\game\machinery\autolathe\designs\ammunition.dm"
#include "code\game\machinery\autolathe\designs\armaments.dm"
#include "code\game\machinery\autolathe\designs\components.dm"
#include "code\game\machinery\autolathe\designs\dinnerware.dm"
#include "code\game\machinery\autolathe\designs\engineering.dm"
#include "code\game\machinery\autolathe\designs\general.dm"
#include "code\game\machinery\autolathe\designs\materials.dm"
#include "code\game\machinery\autolathe\designs\medical.dm"
#include "code\game\machinery\autolathe\designs\tools.dm"
#include "code\game\machinery\bots\bots.dm"
#include "code\game\machinery\camera\camera.dm"
#include "code\game\machinery\camera\camera_assembly.dm"
Expand Down
27 changes: 24 additions & 3 deletions code/game/machinery/autolathe/autolathe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@
SSmaterials.autolathe_categories |= "All"
SSmaterials.autolathe_categories = sort_list(SSmaterials.autolathe_categories, GLOBAL_PROC_REF(cmp_text_asc))

/obj/machinery/autolathe/proc/can_print_item(var/singleton/autolathe_recipe/recipe)
var/ship_security_level = seclevel2num(get_security_level())
var/is_on_ship = isStationLevel(z) // since ship security levels are global FOR NOW, we'll ignore the alert check for offship autolathes

if(!hacked)
if(recipe.hack_only)
return FALSE
else if(is_on_ship && ship_security_level < recipe.security_level)
return FALSE

return TRUE

/obj/machinery/autolathe/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
Expand All @@ -86,6 +98,7 @@

/obj/machinery/autolathe/ui_data(mob/user)
. = ..()

var/list/data = list()
data["disabled"] = disabled
data["material_efficiency"] = mat_efficiency
Expand All @@ -95,14 +108,19 @@
for(var/material in stored_material)
data["materials"] += list(list("material" = material, "stored" = stored_material[material], "max_capacity" = storage_capacity[material]))
data["recipes"] = list()

for(var/recipe in GET_SINGLETON_SUBTYPE_LIST(/singleton/autolathe_recipe))
var/singleton/autolathe_recipe/R = recipe
if(R.hidden && !hacked)
if(R.IsAbstract())
continue

var/list/recipe_data = list()
recipe_data["name"] = R.name
recipe_data["recipe"] = R.type
recipe_data["hidden"] = R.hidden
recipe_data["security_level"] = R.security_level ? capitalize(num2seclevel(R.security_level)) : "None"
recipe_data["hack_only"] = R.hack_only
recipe_data["enabled"] = can_print_item(R)

var/list/resources = list()
for(var/resource in R.resources)
resources += "[R.resources[resource] * mat_efficiency] [resource]"
Expand Down Expand Up @@ -185,7 +203,10 @@
var/multiplier = text2num(params["multiplier"])
var/singleton/autolathe_recipe/R = GET_SINGLETON(text2path(params["recipe"]))
if(!istype(R))
CRASH("Unknown recipe given! [R], param is [params["recipe"]].")
CRASH("([usr.ckey]) tried to print an unknown recipe! [R], param is [params["recipe"]].")

if(!can_print_item(R))
CRASH("([usr.ckey]) tried to print an un-enabled recipe! [R], param is [params["recipe"]].")

intent_message(MACHINE_SOUND)

Expand Down
Loading
Loading