machine ingredient adding more intuitive

This commit is contained in:
Tastyfish
2012-01-02 11:46:19 -05:00
parent 2d91693a3b
commit 87a14c0674
2 changed files with 53 additions and 6 deletions
@@ -63,7 +63,16 @@
req_components = circuit.req_components.Copy()
for(var/A in circuit.req_components)
req_components[A] = circuit.req_components[A]
if(circuit.frame_desc) desc = circuit.frame_desc
req_component_names = circuit.req_components.Copy()
for(var/A in req_components)
var/cp = text2path(A)
var/obj/ct = new cp() // have to quickly instantiate it get name
req_component_names[A] = ct.name
if(circuit.frame_desc)
desc = circuit.frame_desc
else
update_desc()
user << desc
else
user << "\red This frame does not accept circuit boards of this type!"
if(istype(P, /obj/item/weapon/wirecutters))
@@ -126,19 +135,26 @@
if(istype(P, /obj/item/weapon))
for(var/I in req_components)
if(istype(P, text2path(I)) && (req_components[I] > 0))
playsound(src.loc, 'Deconstruct.ogg', 50, 1)
if(istype(P, /obj/item/weapon/cable_coil))
var/obj/item/weapon/cable_coil/CP = P
if(CP.amount > 1)
var/camt = min(CP.amount, req_components[I]) // amount of cable to take, idealy amount required, but limited by amount provided
var/obj/item/weapon/cable_coil/CC = new /obj/item/weapon/cable_coil(src)
CC.amount = 1
CC.amount = camt
CC.update_icon()
CP.use(camt)
components += CC
req_components[I]--
req_components[I] -= camt
update_desc()
break
user.drop_item()
P.loc = src
components += P
req_components[I]--
update_desc()
break
user << desc
if(P.loc != src && !istype(P, /obj/item/weapon/cable_coil))
user << "\red You cannot add that component to the machine!"
+34 -3
View File
@@ -9,8 +9,23 @@
obj/item/weapon/circuitboard/circuit = null
list/components = null
list/req_components = null
list/req_component_names = null
state = 1
proc/update_desc()
var/D
if(req_components)
D = "Requires "
var/first = 1
for(var/I in req_components)
if(req_components[I] > 0)
D += "[first?"":", "][num2text(req_components[I])] [req_component_names[I]]"
first = 0
if(first) // nothing needs to be added, then
D += "nothing"
D += "."
desc = D
/obj/machinery/constructable_frame/machine_frame
attackby(obj/item/P as obj, mob/user as mob)
if(P.crit_fail)
@@ -48,7 +63,16 @@
req_components = circuit.req_components.Copy()
for(var/A in circuit.req_components)
req_components[A] = circuit.req_components[A]
if(circuit.frame_desc) desc = circuit.frame_desc
req_component_names = circuit.req_components.Copy()
for(var/A in req_components)
var/cp = text2path(A)
var/obj/ct = new cp() // have to quickly instantiate it get name
req_component_names[A] = ct.name
if(circuit.frame_desc)
desc = circuit.frame_desc
else
update_desc()
user << desc
else
user << "\red This frame does not accept circuit boards of this type!"
if(istype(P, /obj/item/weapon/wirecutters))
@@ -104,19 +128,26 @@
if(istype(P, /obj/item/weapon))
for(var/I in req_components)
if(istype(P, text2path(I)) && (req_components[I] > 0))
playsound(src.loc, 'Deconstruct.ogg', 50, 1)
if(istype(P, /obj/item/weapon/cable_coil))
var/obj/item/weapon/cable_coil/CP = P
if(CP.amount > 1)
var/camt = min(CP.amount, req_components[I]) // amount of cable to take, idealy amount required, but limited by amount provided
var/obj/item/weapon/cable_coil/CC = new /obj/item/weapon/cable_coil(src)
CC.amount = 1
CC.amount = camt
CC.update_icon()
CP.use(camt)
components += CC
req_components[I]--
req_components[I] -= camt
update_desc()
break
user.drop_item()
P.loc = src
components += P
req_components[I]--
update_desc()
break
user << desc
if(P.loc != src && !istype(P, /obj/item/weapon/cable_coil))
user << "\red You cannot add that component to the machine!"