Protolathe queue support

This commit is contained in:
Rob Nelson
2013-12-04 13:37:47 -08:00
parent 1fb6f3b3c4
commit 83a567d0e0
7 changed files with 448 additions and 501 deletions

View File

@@ -81,7 +81,7 @@ a.notsmelting {
<th>Controls</th>
</tr>"}
for(var/ore_id in machine.ore)
var/datum/processable_ore/ore_info=machine.ore[ore_id]
var/datum/material/ore_info=machine.ore[ore_id]
if(ore_info.stored)
// Can't do squat unless we have at least one.
if(ore_info.stored<1)
@@ -133,7 +133,7 @@ a.notsmelting {
var/ore_id=href_list["toggle_select"]
if (!(ore_id in machine.ore))
error("Unknown ore ID [ore_id]!")
var/datum/processable_ore/ore_info=machine.ore[ore_id]
var/datum/material/ore_info=machine.ore[ore_id]
ore_info.selected = !ore_info.selected
machine.ore[ore_id]=ore_info
if(href_list["set_on"])
@@ -146,77 +146,80 @@ a.notsmelting {
/*************************** ORES *********************************/
/datum/processable_ore
/datum/material
var/name=""
var/processed_name=""
var/id=""
var/stored=0
var/selected=0
var/cc_per_sheet=CC_PER_SHEET_MISC
var/oretype=null
var/sheettype=null
var/cointype=null
/datum/processable_ore/New()
/datum/material/New()
if(processed_name=="")
processed_name=name
/datum/processable_ore/iron
/datum/material/iron
name="Iron"
id="iron"
cc_per_sheet=CC_PER_SHEET_METAL
oretype=/obj/item/weapon/ore/iron
sheettype=/obj/item/stack/sheet/metal
cointype=/obj/item/weapon/coin/iron
/datum/processable_ore/glass
/datum/material/glass
name="Sand"
processed_name="Glass"
id="glass"
cc_per_sheet=CC_PER_SHEET_GLASS
oretype=/obj/item/weapon/ore/glass
sheettype=/obj/item/stack/sheet/glass
/datum/processable_ore/diamond
/datum/material/diamond
name="Diamond"
id="diamond"
oretype=/obj/item/weapon/ore/diamond
sheettype=/obj/item/stack/sheet/mineral/diamond
cointype=/obj/item/weapon/coin/diamond
/datum/processable_ore/plasma
/datum/material/plasma
name="Plasma"
id="plasma"
oretype=/obj/item/weapon/ore/plasma
sheettype=/obj/item/stack/sheet/mineral/plasma
cointype=/obj/item/weapon/coin/plasma
/datum/processable_ore/gold
/datum/material/gold
name="Gold"
id="gold"
oretype=/obj/item/weapon/ore/gold
sheettype=/obj/item/stack/sheet/mineral/gold
cointype=/obj/item/weapon/coin/gold
/datum/processable_ore/silver
/datum/material/silver
name="Silver"
id="silver"
oretype=/obj/item/weapon/ore/silver
sheettype=/obj/item/stack/sheet/mineral/silver
cointype=/obj/item/weapon/coin/silver
/datum/processable_ore/uranium
/datum/material/uranium
name="Uranium"
id="uranium"
oretype=/obj/item/weapon/ore/uranium
sheettype=/obj/item/stack/sheet/mineral/uranium
cointype=/obj/item/weapon/coin/uranium
/datum/processable_ore/clown
/datum/material/clown
name="Bananium"
id="clown"
oretype=/obj/item/weapon/ore/clown
sheettype=/obj/item/stack/sheet/mineral/clown
cointype=/obj/item/weapon/coin/clown
/datum/processable_ore/phazon
/datum/material/phazon
name="Phazon"
id="phazon"
oretype=/obj/item/weapon/ore/phazon
@@ -250,8 +253,8 @@ a.notsmelting {
if(src.output) break
processing_objects.Add(src)
for(var/oredata in typesof(/datum/processable_ore) - /datum/processable_ore)
var/datum/processable_ore/ore_datum = new oredata
for(var/oredata in typesof(/datum/material) - /datum/material)
var/datum/material/ore_datum = new oredata
ore[ore_datum.id]=ore_datum
for(var/recipetype in typesof(/datum/smelting_recipe) - /datum/smelting_recipe)
@@ -269,7 +272,7 @@ a.notsmelting {
if(!(ore_id in ore))
warning("addMaterial(): Unknown material [ore_id]!")
return
var/datum/processable_ore/po=ore[ore_id]
var/datum/material/po=ore[ore_id]
po.stored += amount
ore[ore_id]=po
@@ -299,7 +302,7 @@ a.notsmelting {
// Take ingredients
for(var/ore_id in recipe.ingredients)
// Oh how I wish ore[ore_id].stored-- worked.
var/datum/processable_ore/po=ore[ore_id]
var/datum/material/po=ore[ore_id]
po.stored--
ore[ore_id]=po
@@ -319,7 +322,7 @@ a.notsmelting {
// Take one of every ore selected
for(var/ore_id in ore)
var/datum/processable_ore/po=ore[ore_id]
var/datum/material/po=ore[ore_id]
if(po.stored>0 && po.selected)
po.stored--
ore[ore_id]=po
@@ -333,7 +336,7 @@ a.notsmelting {
O = locate(/obj/item, input.loc)
if (O)
for(var/ore_id in ore)
var/datum/processable_ore/po=ore[ore_id]
var/datum/material/po=ore[ore_id]
if (istype(O,po.oretype))
po.stored++
ore[ore_id]=po
@@ -382,7 +385,7 @@ a.notsmelting {
// Take ingredients
for(var/ore_id in recipe.ingredients)
// Oh how I wish ore[ore_id].stored-- worked.
var/datum/processable_ore/po=ore[ore_id]
var/datum/material/po=ore[ore_id]
po.stored--
ore[ore_id]=po
@@ -402,7 +405,7 @@ a.notsmelting {
// Take one of every ore selected
for(var/ore_id in ore)
var/datum/processable_ore/po=ore[ore_id]
var/datum/material/po=ore[ore_id]
if(po.stored>0 && po.selected)
po.stored--
ore[ore_id]=po
@@ -494,7 +497,7 @@ a.notsmelting {
<th>Controls</th>
</tr>"}
for(var/ore_id in machine.ore)
var/datum/processable_ore/ore_info=machine.ore[ore_id]
var/datum/material/ore_info=machine.ore[ore_id]
if(ore_info.stored)
// Can't do squat unless we have at least one.
if(ore_info.stored<1)

View File

@@ -26,8 +26,8 @@
src.output = locate(/obj/machinery/mineral/output, get_step(src, dir))
if(src.output) break
for(var/oredata in typesof(/datum/processable_ore) - /datum/processable_ore)
var/datum/processable_ore/ore_datum = new oredata
for(var/oredata in typesof(/datum/material) - /datum/material)
var/datum/material/ore_datum = new oredata
// Only add ores that can be run through the minter.
if(ore_datum.cointype)
ore[ore_datum.id]=ore_datum
@@ -43,7 +43,7 @@
O = locate(/obj/item/stack/sheet, input.loc)
if(O)
for(var/ore_id in ore)
var/datum/processable_ore/po =ore[ore_id]
var/datum/material/po =ore[ore_id]
if (istype(O,po.sheettype))
po.stored += 5 * O.amount // 100/20 = 5 coins per sheet.
del(O)
@@ -112,7 +112,7 @@ a.notsmelting {
var/nloaded=0
for(var/ore_id in ore)
var/datum/processable_ore/ore_info=ore[ore_id]
var/datum/material/ore_info=ore[ore_id]
if(ore_info.stored)
html += {"
<tr>
@@ -172,7 +172,7 @@ a.notsmelting {
processing = 1
icon_state = "coinpress1"
var/obj/item/weapon/moneybag/M
var/datum/processable_ore/po=ore[chosen]
var/datum/material/po=ore[chosen]
if(!po)
chosen=null
processing=0

View File

@@ -11,19 +11,19 @@
/obj/item/weapon/moneybag/attack_hand(user as mob)
var/list/ore=list()
for(var/oredata in typesof(/datum/processable_ore) - /datum/processable_ore)
var/datum/processable_ore/ore_datum = new oredata
for(var/oredata in typesof(/datum/material) - /datum/material)
var/datum/material/ore_datum = new oredata
ore[ore_datum.id]=ore_datum
for (var/obj/item/weapon/coin/C in contents)
if (istype(C,/obj/item/weapon/coin))
var/datum/processable_ore/ore_info=ore[C.material]
var/datum/material/ore_info=ore[C.material]
ore_info.stored++
ore[C.material]=ore_info
var/dat = text("<b>The contents of the moneybag reveal...</b><br>")
for(var/ore_id in ore)
var/datum/processable_ore/ore_info=ore[ore_id]
var/datum/material/ore_info=ore[ore_id]
if(ore_info.stored)
dat += "[ore_info.processed_name] coins: [ore_info.stored] <A href='?src=\ref[src];remove=[ore_id]'>Remove one</A><br>"
user << browse("[dat]", "window=moneybag")

View File

@@ -8,7 +8,7 @@
var/sufficient_ore=1
var/matching_ingredient_count=0
for(var/ore_id in P.ore)
var/datum/processable_ore/po=P.ore[ore_id]
var/datum/material/po=P.ore[ore_id]
var/required=(ore_id in ingredients)
// Selected but not in ingredients

File diff suppressed because it is too large Load Diff

View File

@@ -3,26 +3,26 @@ Protolathe
Similar to an autolathe, you load glass and metal sheets (but not other objects) into it to be used as raw materials for the stuff
it creates. All the menus and other manipulation commands are in the R&D console.
Note: Must be placed west/left of and R&D console to function.
*/
/datum/protolathe_queue_item
var/key
var/datum/design/thing
New(var/K,var/datum/design/D)
key=K
thing=D
/obj/machinery/r_n_d/protolathe
name = "Protolathe"
icon_state = "protolathe"
flags = OPENCONTAINER
var/max_material_storage = 100000 //All this could probably be done better with a list but meh.
var/m_amount = 0.0
var/g_amount = 0.0
var/gold_amount = 0.0
var/silver_amount = 0.0
var/plasma_amount = 0.0
var/uranium_amount = 0.0
var/diamond_amount = 0.0
var/clown_amount = 0.0
var/adamantine_amount = 0.0
var/list/production_queue = list()
var/list/datum/materials = list()
var/stopped=1
var/obj/output=null
/obj/machinery/r_n_d/protolathe/New()
..()
@@ -36,8 +36,23 @@ Note: Must be placed west/left of and R&D console to function.
component_parts += new /obj/item/weapon/reagent_containers/glass/beaker(src)
RefreshParts()
for(var/oredata in typesof(/datum/material) - /datum/material)
var/datum/material/ore_datum = new oredata
materials[ore_datum.id]=ore_datum
output=src
for(var/direction in cardinal)
var/O = locate(/obj/machinery/mineral/output) in get_turf(src, direction)
if(O)
output=O
break
/obj/machinery/r_n_d/protolathe/proc/TotalMaterials() //returns the total of all the stored materials. Makes code neater.
return m_amount + g_amount + gold_amount + silver_amount + plasma_amount + uranium_amount + diamond_amount + clown_amount
var/total=0
for(var/id in materials)
var/datum/material/material=materials[id]
total += material.stored
return total
/obj/machinery/r_n_d/protolathe/RefreshParts()
var/T = 0
@@ -51,6 +66,74 @@ Note: Must be placed west/left of and R&D console to function.
T += M.rating
max_material_storage = T * 75000
/obj/machinery/r_n_d/protolathe/proc/enqueue(var/key, var/datum/design/thing_to_build)
production_queue.Add(new /datum/protolathe_queue_item(key,thing_to_build))
//stopped=0
/obj/machinery/r_n_d/protolathe/proc/queue_pop()
var/datum/protolathe_queue_item/I = production_queue[1]
production_queue.Remove(I)
return I
/obj/machinery/r_n_d/protolathe/process()
if(busy || stopped)
return
if(production_queue.len==0)
stopped=1
return
busy=1
spawn(0)
var/datum/protolathe_queue_item/I = queue_pop()
if(!build_thing(I))
production_queue.Add(I)
busy=0
/obj/machinery/r_n_d/protolathe/proc/build_thing(var/datum/protolathe_queue_item/I)
var/key=I.key
var/datum/design/being_built=I.thing
flick("protolathe_n",src)
for(var/M in being_built.materials)
if(!check_mat(being_built, M))
src.visible_message("<font color='blue'>The [src.name] beeps, \"Not enough materials to complete prototype.\"</font>")
stopped=1
return 0
if(copytext(M,1,2) == "$")
var/matID=copytext(M,2)
var/datum/material/material=materials[matID]
material.stored = max(0, (material.stored-being_built.materials[M]))
materials[matID]=material
else
reagents.remove_reagent(M, being_built.materials[M])
if(being_built.build_path)
var/obj/new_item = new being_built.build_path(src)
if( new_item.type == /obj/item/weapon/storage/backpack/holding )
new_item.investigate_log("built by [key]","singulo")
new_item.reliability = being_built.reliability
if(hacked)
being_built.reliability = max((reliability / 2), 0)
if(being_built.locked)
var/obj/item/weapon/storage/lockbox/L = new/obj/item/weapon/storage/lockbox(output.loc)
new_item.loc = L
L.name += " ([new_item.name])"
else
new_item.loc = output.loc
return 1
return 0
/obj/machinery/r_n_d/protolathe/proc/check_mat(var/datum/design/being_built, var/M, var/num_requested=1)
if(copytext(M,1,2) == "$")
var/matID=copytext(M,2)
var/datum/material/material=materials[matID]
for(var/n=num_requested,n>=1,n--)
if ((material.stored-(being_built.materials[M]*n)) >= 0)
return n
else
for(var/n=num_requested,n>=1,n--)
if (reagents.has_reagent(M, being_built.materials[M]))
return n
return 0
/obj/machinery/r_n_d/protolathe/attackby(var/obj/item/O as obj, var/mob/user as mob)
if (shocked)
shock(user,50)
@@ -68,6 +151,29 @@ Note: Must be placed west/left of and R&D console to function.
opened = 0
icon_state = "protolathe"
user << "You close the maintenance hatch of [src]."
if (istype(O, /obj/item/device/multitool))
if(!opened)
var/result = input("Set your location as output?") in list("Yes","No","Machine Location")
switch(result)
if("Yes")
var/found=0
for(var/direction in cardinal)
if(locate(user) in get_step(src,direction))
found=1
if(!found)
user << "\red Cannot set this as the output location; You're too far away."
return
if(istype(output,/obj/machinery/mineral/output))
del(output)
output=new /obj/machinery/mineral/output(usr.loc)
user << "\blue Output set."
if("No")
return
if("Machine Location")
if(istype(output,/obj/machinery/mineral/output))
del(output)
output=src
user << "\blue Output set."
return
if (opened)
if(istype(O, /obj/item/weapon/crowbar))
@@ -81,33 +187,11 @@ Note: Must be placed west/left of and R&D console to function.
if(I.reliability != 100 && crit_fail)
I.crit_fail = 1
I.loc = src.loc
if(m_amount >= 3750)
var/obj/item/stack/sheet/metal/G = new /obj/item/stack/sheet/metal(src.loc)
G.amount = round(m_amount / G.perunit)
if(g_amount >= 3750)
var/obj/item/stack/sheet/glass/G = new /obj/item/stack/sheet/glass(src.loc)
G.amount = round(g_amount / G.perunit)
if(plasma_amount >= 2000)
var/obj/item/stack/sheet/mineral/plasma/G = new /obj/item/stack/sheet/mineral/plasma(src.loc)
G.amount = round(plasma_amount / G.perunit)
if(silver_amount >= 2000)
var/obj/item/stack/sheet/mineral/silver/G = new /obj/item/stack/sheet/mineral/silver(src.loc)
G.amount = round(silver_amount / G.perunit)
if(gold_amount >= 2000)
var/obj/item/stack/sheet/mineral/gold/G = new /obj/item/stack/sheet/mineral/gold(src.loc)
G.amount = round(gold_amount / G.perunit)
if(uranium_amount >= 2000)
var/obj/item/stack/sheet/mineral/uranium/G = new /obj/item/stack/sheet/mineral/uranium(src.loc)
G.amount = round(uranium_amount / G.perunit)
if(diamond_amount >= 2000)
var/obj/item/stack/sheet/mineral/diamond/G = new /obj/item/stack/sheet/mineral/diamond(src.loc)
G.amount = round(diamond_amount / G.perunit)
if(clown_amount >= 2000)
var/obj/item/stack/sheet/mineral/clown/G = new /obj/item/stack/sheet/mineral/clown(src.loc)
G.amount = round(clown_amount / G.perunit)
if(adamantine_amount >= 2000)
var/obj/item/stack/sheet/mineral/adamantine/G = new /obj/item/stack/sheet/mineral/adamantine(src.loc)
G.amount = round(adamantine_amount / G.perunit)
for(var/id in materials)
var/datum/material/material=materials[id]
if(material.stored >= material.cc_per_sheet)
var/obj/item/stack/sheet/S=new material.sheettype(src.loc)
S.amount = round(material.stored / material.cc_per_sheet)
del(src)
return 1
else
@@ -157,25 +241,11 @@ Note: Must be placed west/left of and R&D console to function.
if (do_after(user, 16))
user << "\blue You add [amount] sheets to the [src.name]."
icon_state = "protolathe"
switch(stacktype)
if(/obj/item/stack/sheet/metal)
m_amount += amount * 3750
if(/obj/item/stack/sheet/glass)
g_amount += amount * 3750
if(/obj/item/stack/sheet/mineral/gold)
gold_amount += amount * 2000
if(/obj/item/stack/sheet/mineral/silver)
silver_amount += amount * 2000
if(/obj/item/stack/sheet/mineral/plasma)
plasma_amount += amount * 2000
if(/obj/item/stack/sheet/mineral/uranium)
uranium_amount += amount * 2000
if(/obj/item/stack/sheet/mineral/diamond)
diamond_amount += amount * 2000
if(/obj/item/stack/sheet/mineral/clown)
clown_amount += amount * 2000
if(/obj/item/stack/sheet/mineral/adamantine)
adamantine_amount += amount * 2000
for(var/id in materials)
var/datum/material/material=materials[id]
if(stacktype == material.sheettype)
material.stored += (amount * material.cc_per_sheet)
materials[id]=material
else
new stacktype(src.loc, amount)
busy = 0

View File

@@ -302,8 +302,12 @@ won't update every console in existence) but it's more of a hassle to do. Also,
if(linked_destroy.loaded_item.reliability < 100 && linked_destroy.loaded_item.crit_fail)
files.UpdateDesign(linked_destroy.loaded_item.type)
if(linked_lathe) //Also sends salvaged materials to a linked protolathe, if any.
linked_lathe.m_amount += min((linked_lathe.max_material_storage - linked_lathe.TotalMaterials()), (linked_destroy.loaded_item.m_amt*linked_destroy.decon_mod))
linked_lathe.g_amount += min((linked_lathe.max_material_storage - linked_lathe.TotalMaterials()), (linked_destroy.loaded_item.g_amt*linked_destroy.decon_mod))
var/datum/material/metal = linked_lathe.materials["iron"]
var/datum/material/glass = linked_lathe.materials["glass"]
metal.stored += min((linked_lathe.max_material_storage - linked_lathe.TotalMaterials()), (linked_destroy.loaded_item.m_amt*linked_destroy.decon_mod))
glass.stored += min((linked_lathe.max_material_storage - linked_lathe.TotalMaterials()), (linked_destroy.loaded_item.g_amt*linked_destroy.decon_mod))
linked_lathe.materials["iron"]=metal
linked_lathe.materials["glass"]=glass
linked_destroy.loaded_item = null
for(var/obj/I in linked_destroy.contents)
for(var/mob/M in I.contents)
@@ -365,7 +369,6 @@ won't update every console in existence) but it's more of a hassle to do. Also,
sync = !sync
else if(href_list["build"]) //Causes the Protolathe to build something.
var/g2g = 1
if(linked_lathe)
var/datum/design/being_built = null
for(var/datum/design/D in files.known_designs)
@@ -377,53 +380,11 @@ won't update every console in existence) but it's more of a hassle to do. Also,
for(var/M in being_built.materials)
power += round(being_built.materials[M] / 5)
power = max(2000, power)
screen = 0.3
linked_lathe.busy = 1
flick("protolathe_n",linked_lathe)
var/key = usr.key //so we don't lose the info during the spawn delay
spawn(16)
//screen = 0.3
for(var/i=1;i<=text2num(href_list["n"]);i++)
use_power(power)
spawn(16)
for(var/M in being_built.materials)
if(!check_mat(being_built, M))
src.visible_message("<font color='blue'>The [src.name] beeps, \"Not enough materials to complete prototype.\"</font>")
g2g = 0
break
switch(M)
if("$metal")
linked_lathe.m_amount = max(0, (linked_lathe.m_amount-being_built.materials[M]))
if("$glass")
linked_lathe.g_amount = max(0, (linked_lathe.g_amount-being_built.materials[M]))
if("$gold")
linked_lathe.gold_amount = max(0, (linked_lathe.gold_amount-being_built.materials[M]))
if("$silver")
linked_lathe.silver_amount = max(0, (linked_lathe.silver_amount-being_built.materials[M]))
if("$plasma")
linked_lathe.plasma_amount = max(0, (linked_lathe.plasma_amount-being_built.materials[M]))
if("$uranium")
linked_lathe.uranium_amount = max(0, (linked_lathe.uranium_amount-being_built.materials[M]))
if("$diamond")
linked_lathe.diamond_amount = max(0, (linked_lathe.diamond_amount-being_built.materials[M]))
if("$clown")
linked_lathe.clown_amount = max(0, (linked_lathe.clown_amount-being_built.materials[M]))
else
linked_lathe.reagents.remove_reagent(M, being_built.materials[M])
if(being_built.build_path && g2g)
var/obj/new_item = new being_built.build_path(src)
if( new_item.type == /obj/item/weapon/storage/backpack/holding )
new_item.investigate_log("built by [key]","singulo")
new_item.reliability = being_built.reliability
if(linked_lathe.hacked) being_built.reliability = max((reliability / 2), 0)
if(being_built.locked)
var/obj/item/weapon/storage/lockbox/L = new/obj/item/weapon/storage/lockbox(linked_lathe.loc)
new_item.loc = L
L.name += " ([new_item.name])"
else
new_item.loc = linked_lathe.loc
linked_lathe.busy = 0
screen = 3.1
updateUsrDialog()
linked_lathe.enqueue(usr.key,being_built)
updateUsrDialog()
else if(href_list["imprint"]) //Causes the Circuit Imprinter to build something.
if(linked_imprinter)
@@ -474,42 +435,28 @@ won't update every console in existence) but it's more of a hassle to do. Also,
else if(href_list["disposeallP"] && linked_lathe) //Causes the protolathe to dispose of all it's reagents.
linked_lathe.reagents.clear_reagents()
else if(href_list["removeQItem"] && linked_lathe) //Causes the protolathe to dispose of all it's reagents.
var/i=text2num(href_list["removeQItem"])
linked_lathe.production_queue.Cut(i,i+1)
else if(href_list["clearQ"] && linked_lathe) //Causes the protolathe to dispose of all it's reagents.
linked_lathe.production_queue.Cut()
else if(href_list["setProtolatheStopped"] && linked_lathe) //Causes the protolathe to dispose of all it's reagents.
linked_lathe.stopped=(href_list["setProtolatheStopped"]=="1")
else if(href_list["lathe_ejectsheet"] && linked_lathe) //Causes the protolathe to eject a sheet of material
var/desired_num_sheets = text2num(href_list["lathe_ejectsheet_amt"])
if (desired_num_sheets <= 0) return
var/res_amount, type
switch(href_list["lathe_ejectsheet"])
if("metal")
type = /obj/item/stack/sheet/metal
res_amount = "m_amount"
if("glass")
type = /obj/item/stack/sheet/glass
res_amount = "g_amount"
if("gold")
type = /obj/item/stack/sheet/mineral/gold
res_amount = "gold_amount"
if("silver")
type = /obj/item/stack/sheet/mineral/silver
res_amount = "silver_amount"
if("plasma")
type = /obj/item/stack/sheet/mineral/plasma
res_amount = "plasma_amount"
if("uranium")
type = /obj/item/stack/sheet/mineral/uranium
res_amount = "uranium_amount"
if("diamond")
type = /obj/item/stack/sheet/mineral/diamond
res_amount = "diamond_amount"
if("clown")
type = /obj/item/stack/sheet/mineral/clown
res_amount = "clown_amount"
if(ispath(type) && hasvar(linked_lathe, res_amount))
var/obj/item/stack/sheet/sheet = new type(linked_lathe.loc)
var/available_num_sheets = round(linked_lathe.vars[res_amount]/sheet.perunit)
var/matID=href_list["lathe_ejectsheet"]
var/datum/material/M=linked_lathe.materials[matID]
if(istype(M))
var/obj/item/stack/sheet/sheet = new M.sheettype(linked_lathe.output.loc)
var/available_num_sheets = round(M.stored/sheet.perunit)
if(available_num_sheets>0)
sheet.amount = min(available_num_sheets, desired_num_sheets)
linked_lathe.vars[res_amount] = max(0, (linked_lathe.vars[res_amount]-sheet.amount * sheet.perunit))
M.stored = max(0, (M.stored-sheet.amount * sheet.perunit))
linked_lathe.materials[M.id]=M
else
del sheet
else if(href_list["imprinter_ejectsheet"] && linked_imprinter) //Causes the protolathe to eject a sheet of material
@@ -571,26 +518,20 @@ won't update every console in existence) but it's more of a hassle to do. Also,
updateUsrDialog()
return
/obj/machinery/computer/rdconsole/proc/check_mat(datum/design/being_built, var/M)
switch(M)
if("$metal")
return (linked_lathe.m_amount - being_built.materials[M] >= 0) ? 1 : 0
if("$glass")
return (linked_lathe.g_amount - being_built.materials[M] >= 0) ? 1 : 0
if("$gold")
return (linked_lathe.gold_amount - being_built.materials[M] >= 0) ? 1 : 0
if("$silver")
return (linked_lathe.silver_amount - being_built.materials[M] >= 0) ? 1 : 0
if("$plasma")
return (linked_lathe.plasma_amount - being_built.materials[M] >= 0) ? 1 : 0
if("$uranium")
return (linked_lathe.uranium_amount - being_built.materials[M] >= 0) ? 1 : 0
if("$diamond")
return (linked_lathe.diamond_amount - being_built.materials[M] >= 0) ? 1 : 0
if("$clown")
return (linked_lathe.clown_amount - being_built.materials[M] >= 0) ? 1 : 0
else
return linked_lathe.reagents.remove_reagent(M, being_built.materials[M])
/obj/machinery/computer/rdconsole/proc/protolathe_header()
var/list/options=list()
if(screen!=3.1)
options += "<A href='?src=\ref[src];menu=3.1'>Design Selection</A>"
if(screen!=3.2)
options += "<A href='?src=\ref[src];menu=3.2'>Material Storage</A>"
if(screen!=3.3)
options += "<A href='?src=\ref[src];menu=3.3'>Chemical Storage</A>"
if(screen!=3.4)
options += "<A href='?src=\ref[src];menu=3.4'>Production Queue</A> ([linked_lathe.production_queue.len])"
var/dat = "\[<A href='?src=\ref[src];menu=1.0'>Main Menu</A>\]<div class=\"header\">"
dat += dd_list2text(options," || ")
dat += "</div><hr />"
return dat
/obj/machinery/computer/rdconsole/attack_hand(mob/user as mob)
if(stat & (BROKEN|NOPOWER))
@@ -634,7 +575,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
<A href='?src=\ref[src];lock=1.6'>Unlock</A>"}
// END AUTOFIX
if(0.3)
dat += "Constructing Prototype. Please Wait..."
dat += "Constructing Prototypes. Please Wait..."
if(0.4)
dat += "Imprinting Circuit. Please Wait..."
@@ -851,148 +792,59 @@ won't update every console in existence) but it's more of a hassle to do. Also,
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\research\rdconsole.dm:724: dat += "<A href='?src=\ref[src];menu=1.0'>Main Menu</A> || "
dat += {"<A href='?src=\ref[src];menu=1.0'>Main Menu</A> ||
<A href='?src=\ref[src];menu=3.2'>Material Storage</A> ||
<A href='?src=\ref[src];menu=3.3'>Chemical Storage</A><HR>
Protolathe Menu:<BR><BR>
dat += protolathe_header()+{"Protolathe Menu:<BR>
<B>Material Amount:</B> [linked_lathe.TotalMaterials()] cm<sup>3</sup> (MAX: [linked_lathe.max_material_storage])<BR>
<B>Chemical Volume:</B> [linked_lathe.reagents.total_volume] (MAX: [linked_lathe.reagents.maximum_volume])<HR>"}
<B>Chemical Volume:</B> [linked_lathe.reagents.total_volume] (MAX: [linked_lathe.reagents.maximum_volume])<HR><ul>"}
// END AUTOFIX
for(var/datum/design/D in files.known_designs)
if(!(D.build_type & PROTOLATHE))
continue
var/temp_dat = "[D.name]"
var/check_materials = 1
var/upTo=10
for(var/M in D.materials)
temp_dat += " [D.materials[M]] [CallMaterialName(M)]"
if(copytext(M, 1, 2) == "$")
switch(M)
if("$glass")
if(D.materials[M] > linked_lathe.g_amount) check_materials = 0
if("$metal")
if(D.materials[M] > linked_lathe.m_amount) check_materials = 0
if("$gold")
if(D.materials[M] > linked_lathe.gold_amount) check_materials = 0
if("$silver")
if(D.materials[M] > linked_lathe.silver_amount) check_materials = 0
if("$plasma")
if(D.materials[M] > linked_lathe.plasma_amount) check_materials = 0
if("$uranium")
if(D.materials[M] > linked_lathe.uranium_amount) check_materials = 0
if("$diamond")
if(D.materials[M] > linked_lathe.diamond_amount) check_materials = 0
if("$clown")
if(D.materials[M] > linked_lathe.clown_amount) check_materials = 0
else if (!linked_lathe.reagents.has_reagent(M, D.materials[M]))
check_materials = 0
if (check_materials)
dat += "* <A href='?src=\ref[src];build=[D.id]'>[temp_dat]</A><BR>"
var/num_units_avail=linked_lathe.check_mat(D,M,upTo)
if(num_units_avail<upTo)
upTo=num_units_avail
if(!upTo)
break
if (upTo)
dat += "<li><A href='?src=\ref[src];build=[D.id];n=1'>[temp_dat]</A> "
if(upTo>=5)
dat += "<A href='?src=\ref[src];build=[D.id];n=5'>(&times;5)</A>"
if(upTo>=10)
dat += "<A href='?src=\ref[src];build=[D.id];n=10'>(&times;10)</A>"
dat += "</li>"
else
dat += "* [temp_dat]<BR>"
dat += "<li>[temp_dat]</li>"
dat += "</ul>"
if(3.2) //Protolathe Material Storage Sub-menu
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\research\rdconsole.dm:763: dat += "<A href='?src=\ref[src];menu=1.0'>Main Menu</A> || "
dat += {"<A href='?src=\ref[src];menu=1.0'>Main Menu</A> ||
<A href='?src=\ref[src];menu=3.1'>Protolathe Menu</A><HR>
Material Storage<BR><HR>"}
dat += protolathe_header()+{"Material Storage<ul>"}
// END AUTOFIX
//Metal
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\research\rdconsole.dm:767: dat += "* [linked_lathe.m_amount] cm<sup>3</sup> of Metal || "
dat += {"* [linked_lathe.m_amount] cm<sup>3</sup> of Metal ||
Eject: "}
// END AUTOFIX
if(linked_lathe.m_amount >= 3750) dat += "<A href='?src=\ref[src];lathe_ejectsheet=metal;lathe_ejectsheet_amt=1'>(1 Sheet)</A> "
if(linked_lathe.m_amount >= 18750) dat += "<A href='?src=\ref[src];lathe_ejectsheet=metal;lathe_ejectsheet_amt=5'>(5 Sheets)</A> "
if(linked_lathe.m_amount >= 3750) dat += "<A href='?src=\ref[src];lathe_ejectsheet=metal;lathe_ejectsheet_amt=50'>(Max Sheets)</A>"
dat += "<BR>"
//Glass
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\research\rdconsole.dm:774: dat += "* [linked_lathe.g_amount] cm<sup>3</sup> of Glass || "
dat += {"* [linked_lathe.g_amount] cm<sup>3</sup> of Glass ||
Eject: "}
// END AUTOFIX
if(linked_lathe.g_amount >= 3750) dat += "<A href='?src=\ref[src];lathe_ejectsheet=glass;lathe_ejectsheet_amt=1'>(1 Sheet)</A> "
if(linked_lathe.g_amount >= 18750) dat += "<A href='?src=\ref[src];lathe_ejectsheet=glass;lathe_ejectsheet_amt=5'>(5 Sheets)</A> "
if(linked_lathe.g_amount >= 3750) dat += "<A href='?src=\ref[src];lathe_ejectsheet=glass;lathe_ejectsheet_amt=50'>(Max Sheets)</A>"
dat += "<BR>"
//Gold
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\research\rdconsole.dm:781: dat += "* [linked_lathe.gold_amount] cm<sup>3</sup> of Gold || "
dat += {"* [linked_lathe.gold_amount] cm<sup>3</sup> of Gold ||
Eject: "}
// END AUTOFIX
if(linked_lathe.gold_amount >= 2000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=gold;lathe_ejectsheet_amt=1'>(1 Sheet)</A> "
if(linked_lathe.gold_amount >= 10000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=gold;lathe_ejectsheet_amt=5'>(5 Sheets)</A> "
if(linked_lathe.gold_amount >= 2000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=gold;lathe_ejectsheet_amt=50'>(Max Sheets)</A>"
dat += "<BR>"
//Silver
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\research\rdconsole.dm:788: dat += "* [linked_lathe.silver_amount] cm<sup>3</sup> of Silver || "
dat += {"* [linked_lathe.silver_amount] cm<sup>3</sup> of Silver ||
Eject: "}
// END AUTOFIX
if(linked_lathe.silver_amount >= 2000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=silver;lathe_ejectsheet_amt=1'>(1 Sheet)</A> "
if(linked_lathe.silver_amount >= 10000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=silver;lathe_ejectsheet_amt=5'>(5 Sheets)</A> "
if(linked_lathe.silver_amount >= 2000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=silver;lathe_ejectsheet_amt=50'>(Max Sheets)</A>"
dat += "<BR>"
//Plasma
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\research\rdconsole.dm:795: dat += "* [linked_lathe.plasma_amount] cm<sup>3</sup> of Solid Plasma || "
dat += {"* [linked_lathe.plasma_amount] cm<sup>3</sup> of Solid Plasma ||
Eject: "}
// END AUTOFIX
if(linked_lathe.plasma_amount >= 2000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=plasma;lathe_ejectsheet_amt=1'>(1 Sheet)</A> "
if(linked_lathe.plasma_amount >= 10000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=plasma;lathe_ejectsheet_amt=5'>(5 Sheets)</A> "
if(linked_lathe.plasma_amount >= 2000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=plasmalathe_ejectsheet_amt=50'>(Max Sheets)</A>"
dat += "<BR>"
//Uranium
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\research\rdconsole.dm:802: dat += "* [linked_lathe.uranium_amount] cm<sup>3</sup> of Uranium || "
dat += {"* [linked_lathe.uranium_amount] cm<sup>3</sup> of Uranium ||
Eject: "}
// END AUTOFIX
if(linked_lathe.uranium_amount >= 2000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=uranium;lathe_ejectsheet_amt=1'>(1 Sheet)</A> "
if(linked_lathe.uranium_amount >= 10000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=uranium;lathe_ejectsheet_amt=5'>(5 Sheets)</A> "
if(linked_lathe.uranium_amount >= 2000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=uranium;lathe_ejectsheet_amt=50'>(Max Sheets)</A>"
dat += "<BR>"
//Diamond
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\research\rdconsole.dm:809: dat += "* [linked_lathe.diamond_amount] cm<sup>3</sup> of Diamond || "
dat += {"* [linked_lathe.diamond_amount] cm<sup>3</sup> of Diamond ||
Eject: "}
// END AUTOFIX
if(linked_lathe.diamond_amount >= 2000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=diamond;lathe_ejectsheet_amt=1'>(1 Sheet)</A> "
if(linked_lathe.diamond_amount >= 10000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=diamond;lathe_ejectsheet_amt=5'>(5 Sheets)</A> "
if(linked_lathe.diamond_amount >= 2000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=diamond;lathe_ejectsheet_amt=50'>(Max Sheets)</A>"
dat += "<BR>"
//Bananium
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\research\rdconsole.dm:816: dat += "* [linked_lathe.clown_amount] cm<sup>3</sup> of Bananium || "
dat += {"* [linked_lathe.clown_amount] cm<sup>3</sup> of Bananium ||
Eject: "}
// END AUTOFIX
if(linked_lathe.clown_amount >= 2000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=clown;lathe_ejectsheet_amt=1'>(1 Sheet)</A> "
if(linked_lathe.clown_amount >= 10000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=clown;lathe_ejectsheet_amt=5'>(5 Sheets)</A> "
if(linked_lathe.clown_amount >= 2000) dat += "<A href='?src=\ref[src];lathe_ejectsheet=clown;lathe_ejectsheet_amt=50'>(Max Sheets)</A>"
for(var/matID in linked_lathe.materials)
var/datum/material/M=linked_lathe.materials[matID]
dat += "<li>[M.stored] cm<sup>3</sup> of [M.processed_name]"
if(M.stored >= M.cc_per_sheet)
dat += " - <A href='?src=\ref[src];lathe_ejectsheet=metal;lathe_ejectsheet_amt=1'>(1 Sheet)</A> "
if(M.stored >= (M.cc_per_sheet*5))
dat += "<A href='?src=\ref[src];lathe_ejectsheet=metal;lathe_ejectsheet_amt=5'>(5 Sheets)</A> "
dat += "<A href='?src=\ref[src];lathe_ejectsheet=metal;lathe_ejectsheet_amt=50'>(Max Sheets)</A>"
else
dat += "(Empty)"
dat += "</li>"
dat += "</ul>"
if(3.3) //Protolathe Chemical Storage Submenu
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\research\rdconsole.dm:823: dat += "<A href='?src=\ref[src];menu=1.0'>Main Menu</A> || "
dat += {"<A href='?src=\ref[src];menu=1.0'>Main Menu</A> ||
<A href='?src=\ref[src];menu=3.1'>Protolathe Menu</A><HR>
Chemical Storage<BR><HR>"}
dat += protolathe_header()+{"Chemical Storage<BR><HR>"}
// END AUTOFIX
for(var/datum/reagent/R in linked_lathe.reagents.reagent_list)
@@ -1002,6 +854,20 @@ won't update every console in existence) but it's more of a hassle to do. Also,
<A href='?src=\ref[src];disposeP=[R.id]'>(Purge)</A><BR>
<A href='?src=\ref[src];disposeallP=1'><U>Disposal All Chemicals in Storage</U></A><BR>"}
// END AUTOFIX
if(3.4) //Protolathe Queue Management
dat += protolathe_header()+"Production Queue<BR><HR><ul>"
for(var/i=1;i<=linked_lathe.production_queue.len;i++)
var/datum/protolathe_queue_item/I=linked_lathe.production_queue[i]
dat += "<li>Name: [I.thing.name]"
if(linked_lathe.stopped)
dat += "<A href='?src=\ref[src];removeQItem=[i]'>(Remove)</A></li>"
dat += "</ul><A href='?src=\ref[src];clearQ=1'>Remove All Queued Items</A><br />"
if(linked_lathe.stopped)
dat += "<A href='?src=\ref[src];setProtolatheStopped=0' style='color:green'>Start Production</A>"
else
dat += "<A href='?src=\ref[src];setProtolatheStopped=1' style='color:red'>Stop Production</A>"
///////////////////CIRCUIT IMPRINTER SCREENS////////////////////
if(4.0)