Skip to content

Commit

Permalink
Protolathe & circuit imprinter can multi-queue items (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorDinamit authored Feb 16, 2024
1 parent 5ffa57e commit ebbdd6d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
14 changes: 7 additions & 7 deletions code/modules/research/circuitprinter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using metal and glass, it uses glass and reagents (usually sulphuric acid).

idle_power_usage = 30
active_power_usage = 2500

machine_name = "circuit imprinter"
machine_desc = "Creates circuit boards by etching raw sheets of material with sulphuric acid. Part of an R&D network."

Expand Down Expand Up @@ -146,14 +146,14 @@ using metal and glass, it uses glass and reagents (usually sulphuric acid).
return
queue.Cut(index, index + 1)

/obj/machinery/r_n_d/circuit_imprinter/proc/canBuild(var/datum/design/D)
/obj/machinery/r_n_d/circuit_imprinter/proc/canBuild(datum/design/D, amount = 1)
for(var/M in D.materials)
if(materials[M] <= D.materials[M] * mat_efficiency)
return 0
if(materials[M] <= D.materials[M] * mat_efficiency * amount)
return FALSE
for(var/C in D.chemicals)
if(!reagents.has_reagent(C, D.chemicals[C] * mat_efficiency))
return 0
return 1
if(!reagents.has_reagent(C, D.chemicals[C] * mat_efficiency * amount))
return FALSE
return TRUE

/obj/machinery/r_n_d/circuit_imprinter/proc/build(var/datum/design/D)
var/power = active_power_usage
Expand Down
12 changes: 6 additions & 6 deletions code/modules/research/protolathe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@
return
queue.Cut(index, index + 1)

/obj/machinery/r_n_d/protolathe/proc/canBuild(var/datum/design/D)
/obj/machinery/r_n_d/protolathe/proc/canBuild(datum/design/D, amount = 1)
for(var/M in D.materials)
if(materials[M] < D.materials[M])
return 0
if(materials[M] < D.materials[M] * mat_efficiency * amount)
return FALSE
for(var/C in D.chemicals)
if(!reagents.has_reagent(C, D.chemicals[C]))
return 0
return 1
if(!reagents.has_reagent(C, D.chemicals[C] * mat_efficiency * amount))
return FALSE
return TRUE

/obj/machinery/r_n_d/protolathe/proc/build(var/datum/design/D)
var/power = active_power_usage
Expand Down
25 changes: 19 additions & 6 deletions code/modules/research/rdconsole.dm
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,9 @@ won't update every console in existence) but it's more of a hassle to do. Also,
being_built = D
break
if(being_built)
linked_lathe.addToQueue(being_built)
var/amount_to_print = text2num(href_list["build_amount"])
for(var/i = 1 to amount_to_print)
linked_lathe.addToQueue(being_built)
screen = 3.1

else if(href_list["imprint"]) //Causes the Circuit Imprinter to build something.
Expand All @@ -333,7 +335,9 @@ won't update every console in existence) but it's more of a hassle to do. Also,
being_built = D
break
if(being_built)
linked_imprinter.addToQueue(being_built)
var/amount_to_print = text2num(href_list["build_amount"])
for(var/i = 1 to amount_to_print)
linked_imprinter.addToQueue(being_built)
screen = 4.1

else if(href_list["disposeI"]) //Causes the circuit imprinter to dispose of a single reagent (all of it)
Expand Down Expand Up @@ -722,15 +726,20 @@ won't update every console in existence) but it's more of a hassle to do. Also,
continue
var/temp_dat
for(var/M in D.materials)
temp_dat += ", [D.materials[M]] [CallMaterialName(M)]"
temp_dat += ", [D.materials[M]*(linked_imprinter ? linked_imprinter.mat_efficiency : 1)] [CallMaterialName(M)]"
for(var/T in D.chemicals)
temp_dat += ", [D.chemicals[T]*(linked_imprinter ? linked_imprinter.mat_efficiency : 1)] [CallReagentName(T)]"
if(temp_dat)
temp_dat = " \[[copytext(temp_dat, 3)]\]"
if(linked_lathe.canBuild(D))
dat += "<LI><B><A href='?src=\ref[src];build=[D.id]'>[D.name]</A></B>[temp_dat]"
dat += "<LI><B><A href='?src=\ref[src];build=[D.id]&build_amount=1'>[D.name]</A></B>"
if(linked_lathe.canBuild(D, 5))
dat += " <A href='?src=\ref[src];build=[D.id]&build_amount=5'>x5</A>"
if(linked_lathe.canBuild(D, 10))
dat += " <A href='?src=\ref[src];build=[D.id]&build_amount=10'>x10</A>"
else
dat += "<LI><B>[D.name]</B>[temp_dat]"
dat += "<LI><B>[D.name]</B>"
dat += "[temp_dat]"
dat += "</UL>"

if(3.2) //Protolathe Material Storage Sub-menu
Expand Down Expand Up @@ -808,7 +817,11 @@ won't update every console in existence) but it's more of a hassle to do. Also,
if(temp_dat)
temp_dat = " \[[copytext(temp_dat,3)]\]"
if(linked_imprinter.canBuild(D))
dat += "<LI><B><A href='?src=\ref[src];imprint=[D.id]'>[D.name]</A></B>[temp_dat]"
dat += "<LI><B><A href='?src=\ref[src];imprint=[D.id]&build_amount=1'>[D.name]</A></B>[temp_dat]"
if(linked_imprinter.canBuild(D, 5))
dat += " <A href='?src=\ref[src];imprint=[D.id]&build_amount=5'>x5</A>"
if(linked_imprinter.canBuild(D, 10))
dat += " <A href='?src=\ref[src];imprint=[D.id]&build_amount=10'>x10</A>"
else
dat += "<LI><B>[D.name]</B>[temp_dat]"
dat += "</UL>"
Expand Down

0 comments on commit ebbdd6d

Please sign in to comment.