This commit is contained in:
Fox McCloud
2018-04-21 20:25:14 -04:00
parent e82bc17904
commit 32e3a25070
15 changed files with 117 additions and 310 deletions
+2 -1
View File
@@ -450,8 +450,9 @@
visible_message("<span class='warning'>[src]'s crushing mechanism slowly and smoothly descends, flattening the [exp_on]!</span>")
new /obj/item/stack/sheet/plasteel(get_turf(pick(oview(1,src))))
if(linked_console.linked_lathe)
GET_COMPONENT_FROM(linked_materials, /datum/component/material_container, linked_console.linked_lathe)
for(var/material in exp_on.materials)
linked_console.linked_lathe.materials.insert_amount( min((linked_console.linked_lathe.materials.max_amount - linked_console.linked_lathe.materials.total_amount), (exp_on.materials[material])), material)
linked_materials.insert_amount( min((linked_materials.max_amount - linked_materials.total_amount), (exp_on.materials[material])), material)
if(prob(EFFECT_PROB_VERYLOW-badThingCoeff))
visible_message("<span class='danger'>[src]'s crusher goes way too many levels too high, crushing right through space-time!</span>")
playsound(src.loc, 'sound/effects/supermatter.ogg', 50, 1, -3)
+43 -42
View File
@@ -13,7 +13,6 @@ Note: Must be placed west/left of and R&D console to function.
icon_state = "protolathe"
flags = OPENCONTAINER
var/datum/material_container/materials
var/efficiency_coeff
var/list/categories = list(
@@ -28,11 +27,15 @@ Note: Must be placed west/left of and R&D console to function.
"Stock Parts",
"Weapons"
)
var/datum/component/material_container/materials //Store for hyper speed!
reagents = new()
/obj/machinery/r_n_d/protolathe/New()
materials = AddComponent(/datum/component/material_container,
list(MAT_METAL, MAT_GLASS, MAT_SILVER, MAT_GOLD, MAT_DIAMOND, MAT_PLASMA, MAT_URANIUM, MAT_BANANIUM, MAT_TRANQUILLITE, MAT_TITANIUM, MAT_BLUESPACE, MAT_PLASTIC), 0,
FALSE, list(/obj/item/stack, /obj/item/ore/bluespace_crystal), CALLBACK(src, .proc/is_insertion_ready), CALLBACK(src, .proc/AfterMaterialInsert))
materials.precise_insertion = TRUE
..()
component_parts = list()
component_parts += new /obj/item/circuitboard/protolathe(null)
@@ -42,7 +45,6 @@ Note: Must be placed west/left of and R&D console to function.
component_parts += new /obj/item/stock_parts/manipulator(null)
component_parts += new /obj/item/reagent_containers/glass/beaker/large(null)
component_parts += new /obj/item/reagent_containers/glass/beaker/large(null)
materials = new(src, list(MAT_METAL=1, MAT_GLASS=1, MAT_SILVER=1, MAT_GOLD=1, MAT_DIAMOND=1, MAT_PLASMA=1, MAT_URANIUM=1, MAT_BANANIUM=1, MAT_TRANQUILLITE=1, MAT_TITANIUM=1))
RefreshParts()
reagents.my_atom = src
@@ -61,10 +63,6 @@ Note: Must be placed west/left of and R&D console to function.
reagents.my_atom = src
/obj/machinery/r_n_d/protolathe/Destroy()
QDEL_NULL(materials)
return ..()
/obj/machinery/r_n_d/protolathe/RefreshParts()
var/T = 0
for(var/obj/item/reagent_containers/glass/G in component_parts)
@@ -88,7 +86,8 @@ Note: Must be placed west/left of and R&D console to function.
/obj/machinery/r_n_d/protolathe/attackby(var/obj/item/O as obj, var/mob/user as mob, params)
if(shocked)
shock(user,50)
if(shock(user,50))
return TRUE
if(default_deconstruction_screwdriver(user, "protolathe_t", "protolathe", O))
if(linked_console)
linked_console.linked_lathe = null
@@ -112,39 +111,41 @@ Note: Must be placed west/left of and R&D console to function.
else
to_chat(user, "<span class='warning'>You can't load the [src.name] while it's opened.</span>")
return 1
if(disabled)
return
if(!linked_console)
to_chat(user, "<span class='warning'> The [src.name] must be linked to an R&D console first!</span>")
return 1
if(busy)
to_chat(user, "<span class='warning'>The [src.name] is busy. Please wait for completion of previous operation.</span>")
return 1
if(O.is_open_container())
return
if(stat)
return 1
if(!istype(O,/obj/item/stack/sheet))
return 1
if(!materials.has_space( materials.get_item_material_amount(O) ))
to_chat(user, "<span class='warning'>The [src.name]'s material bin is full! Please remove material before adding more.</span>")
return 1
var/obj/item/stack/sheet/stack = O
var/amount = round(input("How many sheets do you want to add?") as num)//No decimals
if(!in_range(src, stack) || !user.Adjacent(src))
return
var/amount_inserted = materials.insert_stack(O,amount)
if(!amount_inserted)
return 1
return FALSE
else
busy = 1
use_power(max(1000, (MINERAL_MATERIAL_AMOUNT*amount_inserted/10)))
to_chat(user, "<span class='notice'>You add [amount_inserted] sheets to the [src.name].</span>")
var/stackname = stack.name
src.overlays += "protolathe_[stackname]"
sleep(10)
src.overlays -= "protolathe_[stackname]"
busy = 0
updateUsrDialog()
return ..()
//whether the machine can have an item inserted in its current state.
/obj/machinery/r_n_d/protolathe/proc/is_insertion_ready(mob/user)
if(panel_open)
to_chat(user, "<span class='warning'>You can't load [src] while it's opened!</span>")
return FALSE
if(disabled)
return FALSE
if(!linked_console)
to_chat(user, "<span class='warning'>[src] must be linked to an R&D console first!</span>")
return FALSE
if(busy)
to_chat(user, "<span class='warning'>[src] is busy right now.</span>")
return FALSE
if(stat & BROKEN)
to_chat(user, "<span class='warning'>[src] is broken.</span>")
return FALSE
if(stat & NOPOWER)
to_chat(user, "<span class='warning'>[src] has no power.</span>")
return FALSE
return TRUE
/obj/machinery/r_n_d/protolathe/proc/AfterMaterialInsert(type_inserted, id_inserted, amount_inserted)
var/stack_name
if(ispath(type_inserted, /obj/item/ore/bluespace_crystal))
stack_name = "bluespace polycrystal"
use_power(MINERAL_MATERIAL_AMOUNT / 10)
else
var/obj/item/stack/S = type_inserted
stack_name = initial(S.name)
use_power(min(1000, (amount_inserted / 100)))
overlays += "protolathe_[stack_name]"
sleep(10)
overlays -= "protolathe_[stack_name]"
+7 -1
View File
@@ -100,6 +100,10 @@ won't update every console in existence) but it's more of a hassle to do. Also,
return_name = "Tranquillite"
if("titanium")
return_name = "Titanium"
if("bluespace")
return_name = "Bluespace Mesh"
if("plastic")
return_name = "Plastic"
return return_name
else
for(var/R in subtypesof(/datum/reagent))
@@ -805,12 +809,14 @@ won't update every console in existence) but it's more of a hassle to do. Also,
materials_list[++materials_list.len] = list("name" = "Glass", "id" = MAT_GLASS, "amount" = linked_lathe.materials.amount(MAT_GLASS))
materials_list[++materials_list.len] = list("name" = "Gold", "id" = MAT_GOLD, "amount" = linked_lathe.materials.amount(MAT_GOLD))
materials_list[++materials_list.len] = list("name" = "Silver", "id" = MAT_SILVER, "amount" = linked_lathe.materials.amount(MAT_SILVER))
materials_list[++materials_list.len] = list("name" = "Plasma", "id" = MAT_PLASMA, "amount" = linked_lathe.materials.amount(MAT_PLASMA))
materials_list[++materials_list.len] = list("name" = "Solid Plasma", "id" = MAT_PLASMA, "amount" = linked_lathe.materials.amount(MAT_PLASMA))
materials_list[++materials_list.len] = list("name" = "Uranium", "id" = MAT_URANIUM, "amount" = linked_lathe.materials.amount(MAT_URANIUM))
materials_list[++materials_list.len] = list("name" = "Diamond", "id" = MAT_DIAMOND, "amount" = linked_lathe.materials.amount(MAT_DIAMOND))
materials_list[++materials_list.len] = list("name" = "Bananium", "id" = MAT_BANANIUM, "amount" = linked_lathe.materials.amount(MAT_BANANIUM))
materials_list[++materials_list.len] = list("name" = "Tranquillite", "id" = MAT_TRANQUILLITE, "amount" = linked_lathe.materials.amount(MAT_TRANQUILLITE))
materials_list[++materials_list.len] = list("name" = "Titanium", "id" = MAT_TITANIUM, "amount" = linked_lathe.materials.amount(MAT_TITANIUM))
materials_list[++materials_list.len] = list("name" = "Plastic", "id" = MAT_PLASTIC, "amount" = linked_lathe.materials.amount(MAT_PLASTIC))
materials_list[++materials_list.len] = list("name" = "Bluespace Mesh", "id" = MAT_BLUESPACE, "amount" = linked_lathe.materials.amount(MAT_BLUESPACE))
if(submenu == 3)
var/list/loaded_chemicals = list()
data["loaded_chemicals"] = loaded_chemicals