Make stack amount var private

This commit is contained in:
Aronai Sieyes
2021-08-19 21:06:46 -04:00
parent ab7b3fcad9
commit e52031d6aa
72 changed files with 241 additions and 297 deletions
@@ -238,9 +238,7 @@
if(amount <= 0)
amount = S.max_amount
var/ejected = min(round(stored_material[material_name] / S.perunit), amount)
S.amount = min(ejected, amount)
if(S.amount <= 0)
qdel(S)
if(!S.set_amount(min(ejected, amount)))
return
stored_material[material_name] -= ejected * S.perunit
if(recursive && stored_material[material_name] >= S.perunit)
@@ -256,7 +254,7 @@
var/max_res_amount = storage_capacity[S.material.name]
if(stored_material[S.material.name] + S.perunit <= max_res_amount)
var/count = 0
while(stored_material[S.material.name] + S.perunit <= max_res_amount && S.amount >= 1)
while(stored_material[S.material.name] + S.perunit <= max_res_amount && S.get_amount() >= 1)
stored_material[S.material.name] += S.perunit
S.use(1)
count++
+7 -7
View File
@@ -135,7 +135,7 @@
LAZYADDASSOCLIST(.["instances"], item.type, item)
if(istype(item, /obj/item/stack))
var/obj/item/stack/stack = item
.["other"][item.type] += stack.amount
.["other"][item.type] += stack.get_amount()
else if(item.tool_qualities)
.["tool_qualities"] |= item.tool_qualities
.["other"][item.type] += 1
@@ -297,20 +297,20 @@
var/obj/item/stack/SD
while(amt > 0)
S = locate(path_key) in surroundings
if(S.amount >= amt)
if(S.get_amount() >= amt)
if(!locate(S.type) in Deletion)
SD = new S.type()
Deletion += SD
S.use(amt)
SD = locate(S.type) in Deletion
SD.amount += amt
SD.add(amt)
continue main_loop
else
amt -= S.amount
amt -= S.get_amount()
if(!locate(S.type) in Deletion)
Deletion += S
else
data = S.amount
data = S.get_amount()
S = locate(S.type) in Deletion
S.add(data)
surroundings -= S
@@ -334,8 +334,8 @@
continue
else if(istype(part, /obj/item/stack))
var/obj/item/stack/ST = locate(part) in Deletion
if(ST.amount > partlist[part])
ST.amount = partlist[part]
if(ST.get_amount() > partlist[part])
ST.set_amount(partlist[part])
. += ST
Deletion -= ST
continue
+1 -1
View File
@@ -70,7 +70,7 @@
if(.)
var/obj/item/stack/S = product
if(istype(S))
amount += S.amount
amount += S.get_amount()
/datum/stored_item/stack/get_product(var/product_location, var/count)
if(!LAZYLEN(instances))
+13 -14
View File
@@ -9,8 +9,7 @@
var/on = 0
/obj/machinery/cablelayer/New()
cable = new(src)
cable.amount = 100
cable = new(src, 100)
..()
/obj/machinery/cablelayer/Moved(atom/old_loc, direction, forced = FALSE)
@@ -36,32 +35,32 @@
return
if(O.is_wirecutter())
if(cable && cable.amount)
var/m = round(input(usr,"Please specify the length of cable to cut","Cut cable",min(cable.amount,30)) as num, 1)
m = min(m, cable.amount)
if(cable && cable.get_amount())
var/m = round(input(usr, "Please specify the length of cable to cut", "Cut cable", min(cable.get_amount(), 30)) as num, 1)
m = min(m, cable.get_amount())
m = min(m, 30)
if(m)
playsound(src, O.usesound, 50, 1)
use_cable(m)
var/obj/item/stack/cable_coil/CC = new (get_turf(src))
CC.amount = m
CC.set_amount(m)
else
to_chat(usr, "<span class='warning'>There's no more cable on the reel.</span>")
/obj/machinery/cablelayer/examine(mob/user)
. = ..()
. += "[src]'s cable reel has [cable.amount] length\s left."
. += "[src]'s cable reel has [cable.get_amount()] length\s left."
/obj/machinery/cablelayer/proc/load_cable(var/obj/item/stack/cable_coil/CC)
if(istype(CC) && CC.amount)
var/cur_amount = cable? cable.amount : 0
if(istype(CC) && CC.get_amount())
var/cur_amount = cable ? cable.get_amount() : 0
var/to_load = max(max_cable - cur_amount,0)
if(to_load)
to_load = min(CC.amount, to_load)
to_load = min(CC.get_amount(), to_load)
if(!cable)
cable = new(src)
cable.amount = 0
cable.amount += to_load
cable = new(src, to_load)
else
cable.add(to_load)
CC.use(to_load)
return to_load
else
@@ -69,7 +68,7 @@
return
/obj/machinery/cablelayer/proc/use_cable(amount)
if(!cable || cable.amount<1)
if(!cable || cable.get_amount() < 1)
visible_message("A red light flashes on \the [src].")
return
cable.use(amount)
+1 -1
View File
@@ -223,7 +223,7 @@
if(multiplier > 1)
if(istype(I, /obj/item/stack))
var/obj/item/stack/S = I
S.amount = multiplier
S.set_amount(multiplier)
else
for(multiplier; multiplier > 1; --multiplier) // Create multiple items if it's not a stack.
I = new making.path(src.loc)
+1 -2
View File
@@ -183,8 +183,7 @@
points -= cost
if(ispath(bi.equipment_path, /obj/item/stack))
var/obj/item/stack/S = new bi.equipment_path(loc)
S.amount = bi.equipment_amt
new bi.equipment_path(loc, bi.equipment_amt)
playsound(src, 'sound/machines/vending/vending_drop.ogg', 100, 1)
return TRUE
+1 -2
View File
@@ -86,8 +86,7 @@
to_chat(user, "<span class='notice'>You remove the cables.</span>")
state = 2
icon_state = "2"
var/obj/item/stack/cable_coil/A = new /obj/item/stack/cable_coil( loc )
A.amount = 5
new /obj/item/stack/cable_coil(loc, 5)
if(istype(P, /obj/item/stack/material) && P.get_material_name() == "rglass")
var/obj/item/stack/RG = P
+1 -1
View File
@@ -189,7 +189,7 @@
to_chat(user, "<span class='notice'>\The [src] is already fully repaired.</span>")
return
var/obj/item/stack/P = C
if(P.amount < amt)
if(P.get_amount() < amt)
to_chat(user, "<span class='warning'>You don't have enough sheets to repair this! You need at least [amt] sheets.</span>")
return
to_chat(user, "<span class='notice'>You begin repairing [src]...</span>")
+1 -2
View File
@@ -277,8 +277,7 @@
if(repairing && I.is_crowbar())
var/datum/material/mat = get_material()
var/obj/item/stack/material/repairing_sheet = mat.place_sheet(loc)
repairing_sheet.amount += repairing-1
var/obj/item/stack/material/repairing_sheet = mat.place_sheet(loc, repairing)
repairing = 0
to_chat(user, "<span class='notice'>You remove \the [repairing_sheet].</span>")
playsound(src, I.usesound, 100, 1)
+1 -2
View File
@@ -90,8 +90,7 @@
return TRUE
if(reinforcing && I.is_crowbar())
var/obj/item/stack/material/plasteel/reinforcing_sheet = new /obj/item/stack/material/plasteel(src.loc)
reinforcing_sheet.amount = reinforcing
var/obj/item/stack/material/plasteel/reinforcing_sheet = new /obj/item/stack/material/plasteel(src.loc, reinforcing)
reinforcing = 0
to_chat(user, "<span class='notice'>You remove \the [reinforcing_sheet].</span>")
playsound(src, I.usesound, 100, 1)
+4 -6
View File
@@ -514,9 +514,8 @@
if(istype(P, /obj/item/stack/cable_coil))
var/obj/item/stack/cable_coil/CP = P
if(CP.get_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/stack/cable_coil/CC = new /obj/item/stack/cable_coil(src)
CC.amount = camt
var/camt = min(CP.get_amount(), req_components[I]) // amount of cable to take, idealy amount required, but limited by amount provided
var/obj/item/stack/cable_coil/CC = new /obj/item/stack/cable_coil(src, camt)
CC.update_icon()
CP.use(camt)
components += CC
@@ -587,9 +586,8 @@
if(istype(P, /obj/item/stack))
var/obj/item/stack/ST = P
if(ST.get_amount() > 1)
var/camt = min(ST.amount, req_components[I]) // amount of stack to take, idealy amount required, but limited by amount provided
var/obj/item/stack/NS = new ST.stacktype(src)
NS.amount = camt
var/camt = min(ST.get_amount(), req_components[I]) // amount of stack to take, idealy amount required, but limited by amount provided
var/obj/item/stack/NS = new ST.stacktype(src, camt)
NS.update_icon()
ST.use(camt)
components += NS
+1 -2
View File
@@ -71,8 +71,7 @@
to_chat(user, "<span class='notice'>You start to dismantle the IV drip.</span>")
if(do_after(user, 15))
to_chat(user, "<span class='notice'>You dismantle the IV drip.</span>")
var/obj/item/stack/rods/A = new /obj/item/stack/rods(src.loc)
A.amount = 6
new /obj/item/stack/rods(src.loc, 6)
if(beaker)
beaker.loc = get_turf(src)
beaker = null
+4 -6
View File
@@ -125,12 +125,12 @@
if(!(S.material.name in materials))
to_chat(user, "<span class='warning'>The [src] doesn't accept [S.material]!</span>")
return 1
if(S.amount < 1)
if(S.get_amount() < 1)
return 1 // Does this even happen? Sanity check I guess.
var/max_res_amount = storage_capacity[S.material.name]
if(materials[S.material.name] + S.perunit <= max_res_amount)
var/count = 0
while(materials[S.material.name] + S.perunit <= max_res_amount && S.amount >= 1)
while(materials[S.material.name] + S.perunit <= max_res_amount && S.get_amount() >= 1)
materials[S.material.name] += S.perunit
S.use(1)
count++
@@ -205,7 +205,7 @@
// 0 amount = 0 means ejecting a full stack; -1 means eject everything
/obj/machinery/partslathe/proc/eject_materials(var/material, var/amount)
var/recursive = amount == -1 ? 1 : 0
var/recursive = amount == -1 ? TRUE : FALSE
material = lowertext(material)
var/mattype
switch(material)
@@ -219,9 +219,7 @@
if(amount <= 0)
amount = S.max_amount
var/ejected = min(round(materials[material] / S.perunit), amount)
S.amount = min(ejected, amount)
if(S.amount <= 0)
qdel(S)
if(!S.set_amount(min(ejected, amount)))
return
materials[material] -= ejected * S.perunit
if(recursive && materials[material] >= S.perunit)
+3 -4
View File
@@ -146,10 +146,9 @@
var/amount_ejected = 0
while (metal >= 1)
var/datum/material/M = get_material_by_name(MAT_STEEL)
var/obj/item/stack/material/S = new M.stack_type(get_turf(src))
S.amount = min(metal, S.max_amount)
metal -= S.amount
amount_ejected += S.amount
var/obj/item/stack/material/S = new M.stack_type(get_turf(src), metal)
metal -= S.get_amount()
amount_ejected += S.get_amount()
return amount_ejected
/obj/machinery/pipelayer/proc/dismantleFloor(var/turf/new_turf)
+1 -1
View File
@@ -21,7 +21,7 @@
if(M)
if(!M.get_amount())
return
while(metal_amount < 150000 && M.amount)
while(metal_amount < 150000 && M.get_amount())
metal_amount += O.matter[MAT_STEEL] /*O:height * O:width * O:length * 100000.0*/
M.use(1)
count++
+2 -3
View File
@@ -67,11 +67,10 @@
//Tanning!
for(var/obj/item/stack/hairlesshide/HH in washing)
var/obj/item/stack/wetleather/WL = new(src)
WL.amount = HH.amount
var/obj/item/stack/wetleather/WL = new(src, HH.get_amount())
washing -= HH
HH.forceMove(get_turf(src))
HH.use(HH.amount)
HH.use(HH.get_amount())
washing += WL
+14 -16
View File
@@ -8,8 +8,7 @@
required_type = list(/obj/mecha/working)
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/New()
cable = new(src)
cable.amount = 0
cable = new(src, 0)
..()
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/MoveAction()
@@ -38,13 +37,12 @@
log_message("[equip_ready?"Dea":"A"]ctivated.")
return
if(href_list["cut"])
if(cable && cable.amount)
var/m = round(input(chassis.occupant,"Please specify the length of cable to cut","Cut cable",min(cable.amount,30)) as num, 1)
m = min(m, cable.amount)
if(cable && cable.get_amount())
var/m = round(input(chassis.occupant, "Please specify the length of cable to cut", "Cut cable", min(cable.get_amount(), 30)) as num, 1)
m = min(m, cable.get_amount())
if(m)
use_cable(m)
var/obj/item/stack/cable_coil/CC = new (get_turf(chassis))
CC.amount = m
new /obj/item/stack/cable_coil(get_turf(chassis), m)
else
occupant_message("There's no more cable on the reel.")
return
@@ -52,19 +50,19 @@
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/get_equip_info()
var/output = ..()
if(output)
return "[output] \[Cable: [cable ? cable.amount : 0] m\][(cable && cable.amount) ? "- <a href='?src=\ref[src];toggle=1'>[!equip_ready?"Dea":"A"]ctivate</a>|<a href='?src=\ref[src];cut=1'>Cut</a>" : null]"
return "[output] \[Cable: [cable ? cable.get_amount() : 0] m\][(cable && cable.get_amount()) ? "- <a href='?src=\ref[src];toggle=1'>[!equip_ready?"Dea":"A"]ctivate</a>|<a href='?src=\ref[src];cut=1'>Cut</a>" : null]"
return
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/proc/load_cable(var/obj/item/stack/cable_coil/CC)
if(istype(CC) && CC.amount)
var/cur_amount = cable? cable.amount : 0
if(istype(CC) && CC.get_amount())
var/cur_amount = cable? cable.get_amount() : 0
var/to_load = max(max_cable - cur_amount,0)
if(to_load)
to_load = min(CC.amount, to_load)
to_load = min(CC.get_amount(), to_load)
if(!cable)
cable = new(src)
cable.amount = 0
cable.amount += to_load
cable = new(src, to_load)
else
cable.add(to_load)
CC.use(to_load)
return to_load
else
@@ -72,12 +70,12 @@
return
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/proc/use_cable(amount)
if(!cable || cable.amount<1)
if(!cable || cable.get_amount() < 1)
set_ready_state(TRUE)
occupant_message("Cable depleted, [src] deactivated.")
log_message("Cable depleted, [src] deactivated.")
return
if(cable.amount < amount)
if(cable.get_amount() < amount)
occupant_message("No enough cable to finish the task.")
return
cable.use(amount)
+8 -9
View File
@@ -18,8 +18,7 @@
/obj/item/mecha_parts/mecha_equipment/generator/Initialize()
. = ..()
fuel = new fuel_type(src)
fuel.amount = 0
fuel = new fuel_type(src, 0)
/obj/item/mecha_parts/mecha_equipment/generator/Destroy()
qdel(fuel)
@@ -29,7 +28,7 @@
if(!chassis)
set_ready_state(TRUE)
return PROCESS_KILL
if(fuel.amount<=0)
if(fuel.get_amount() <= 0)
log_message("Deactivated - no fuel.")
set_ready_state(TRUE)
return PROCESS_KILL
@@ -43,7 +42,7 @@
if(cur_charge<chassis.cell.maxcharge)
use_fuel = fuel_per_cycle_active
chassis.give_power(power_per_cycle)
fuel.amount -= min(use_fuel/fuel.perunit,fuel.amount)
fuel.set_amount(min(use_fuel/fuel.perunit, fuel.get_amount()), TRUE) // allows fuel to get to 0
update_equip_info()
/obj/item/mecha_parts/mecha_equipment/generator/detach()
@@ -68,7 +67,7 @@
/obj/item/mecha_parts/mecha_equipment/generator/get_equip_info()
var/output = ..()
if(output)
return "[output] \[[fuel]: [round(fuel.amount*fuel.perunit,0.1)] cm<sup>3</sup>\] - <a href='?src=\ref[src];toggle=1'>[(datum_flags & DF_ISPROCESSING)?"Dea":"A"]ctivate</a>"
return "[output] \[[fuel]: [round(fuel.get_amount()*fuel.perunit,0.1)] cm<sup>3</sup>\] - <a href='?src=\ref[src];toggle=1'>[(datum_flags & DF_ISPROCESSING)?"Dea":"A"]ctivate</a>"
return
/obj/item/mecha_parts/mecha_equipment/generator/action(target)
@@ -86,12 +85,12 @@
return
/obj/item/mecha_parts/mecha_equipment/generator/proc/load_fuel(var/obj/item/stack/material/P)
if(P.type == fuel.type && P.amount)
var/to_load = max(max_fuel - fuel.amount*fuel.perunit,0)
if(P.type == fuel.type && P.get_amount())
var/to_load = max(max_fuel - fuel.get_amount()*fuel.perunit,0)
if(to_load)
var/units = min(max(round(to_load / P.perunit),1),P.amount)
var/units = min(max(round(to_load / P.perunit),1),P.get_amount())
if(units)
fuel.amount += units
fuel.add(units)
P.use(units)
return units
else
+2 -4
View File
@@ -665,7 +665,7 @@
visible_message("[bicon(src)] <b>[src]</b> beeps: \"No records in User DB\"")
/obj/machinery/mecha_part_fabricator/proc/eject_materials(var/material, var/amount) // 0 amount = 0 means ejecting a full stack; -1 means eject everything
var/recursive = amount == -1 ? 1 : 0
var/recursive = amount == -1 ? TRUE : FALSE
var/matstring = lowertext(material)
var/datum/material/M = get_material_by_name(matstring)
@@ -673,9 +673,7 @@
if(amount <= 0)
amount = S.max_amount
var/ejected = min(round(materials[matstring] / S.perunit), amount)
S.amount = min(ejected, amount)
if(S.amount <= 0)
qdel(S)
if(!S.set_amount(ejected, amount))
return
materials[matstring] -= ejected * S.perunit
if(recursive && materials[matstring] >= S.perunit)
+24 -47
View File
@@ -190,8 +190,7 @@
holder.icon_state = "ripley4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "ripley2"
if(10)
if(diff==FORWARD)
@@ -238,8 +237,7 @@
holder.icon_state = "ripley10"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/steel(get_turf(holder), 5)
holder.icon_state = "ripley8"
if(4)
if(diff==FORWARD)
@@ -261,8 +259,7 @@
holder.icon_state = "ripley13"
else
user.visible_message("[user] pries external armor layer from [holder].", "You prie external armor layer from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/plasteel(get_turf(holder), 5)
holder.icon_state = "ripley11"
if(1)
if(diff==FORWARD)
@@ -425,8 +422,7 @@
holder.icon_state = "gygax4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "gygax2"
if(16)
if(diff==FORWARD)
@@ -521,8 +517,7 @@
holder.icon_state = "gygax16"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/steel(get_turf(holder), 5)
holder.icon_state = "gygax14"
if(4)
if(diff==FORWARD)
@@ -709,8 +704,7 @@
holder.icon_state = "gygax4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "gygax2"
if(16)
if(diff==FORWARD)
@@ -805,8 +799,7 @@
holder.icon_state = "gygax16"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You pry the internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/steel(get_turf(holder), 5)
holder.icon_state = "gygax14"
if(4)
if(diff==FORWARD)
@@ -828,8 +821,7 @@
holder.icon_state = "gygax19-s"
else
user.visible_message("[user] pries the external armor layer from [holder].", "You pry the external armor layer from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder)) // Fixes serenity giving Gygax Armor Plates for the reverse action...
MS.amount = 5
new /obj/item/stack/material/plasteel(get_turf(holder), 5) // Fixes serenity giving Gygax Armor Plates for the reverse action...
holder.icon_state = "gygax17"
if(1)
if(diff==FORWARD)
@@ -975,8 +967,7 @@
holder.icon_state = "fireripley4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "fireripley2"
if(11)
if(diff==FORWARD)
@@ -1023,8 +1014,7 @@
holder.icon_state = "fireripley10"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/plasteel(get_turf(holder), 5)
holder.icon_state = "fireripley8"
if(5)
if(diff==FORWARD)
@@ -1046,8 +1036,7 @@
holder.icon_state = "fireripley13"
else
user.visible_message("[user] removes the external armor from [holder].", "You remove the external armor from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/plasteel(get_turf(holder), 5)
holder.icon_state = "fireripley11"
if(2)
if(diff==FORWARD)
@@ -1055,8 +1044,7 @@
holder.icon_state = "fireripley14"
else
user.visible_message("[user] pries external armor layer from [holder].", "You prie external armor layer from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/plasteel(get_turf(holder), 5)
holder.icon_state = "fireripley12"
if(1)
if(diff==FORWARD)
@@ -1220,8 +1208,7 @@
holder.icon_state = "durand4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "durand2"
if(16)
if(diff==FORWARD)
@@ -1316,8 +1303,7 @@
holder.icon_state = "durand16"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/steel(get_turf(holder), 5)
holder.icon_state = "durand14"
if(4)
if(diff==FORWARD)
@@ -1479,8 +1465,7 @@
holder.icon_state = "odysseus4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "odysseus2"
if(10)
if(diff==FORWARD)
@@ -1527,8 +1512,7 @@
holder.icon_state = "odysseus10"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/steel(get_turf(holder), 5)
holder.icon_state = "odysseus8"
if(4)
if(diff==FORWARD)
@@ -1549,9 +1533,8 @@
user.visible_message("[user] secures external armor layer.", "You secure external reinforced armor layer.")
holder.icon_state = "odysseus13"
else
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 5
user.visible_message("[user] pries [MS] from [holder].", "You prie [MS] from [holder].")
new /obj/item/stack/material/plasteel(get_turf(holder), 5)
user.visible_message("[user] pries the plasteel from [holder].", "You prie the plasteel from [holder].")
holder.icon_state = "odysseus11"
if(1)
if(diff==FORWARD)
@@ -1714,8 +1697,7 @@
holder.icon_state = "phazon4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "phazon2"
if(16)
if(diff==FORWARD)
@@ -1810,8 +1792,7 @@
holder.icon_state = "phazon20"
else
user.visible_message("[user] pries the internal armor layer from [holder].", "You pry the internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/steel(get_turf(holder), 5)
holder.icon_state = "phazon14"
if(4)
if(diff==FORWARD)
@@ -1833,8 +1814,7 @@
holder.icon_state = "phazon23"
else
user.visible_message("[user] pries the external armor layer from [holder].", "You pry external armor layer from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/plasteel(get_turf(holder), 5)
holder.icon_state = "phazon21"
if(1)
if(diff==FORWARD)
@@ -2004,8 +1984,7 @@
holder.icon_state = "janus4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "janus2"
if(18)
if(diff==FORWARD)
@@ -2116,8 +2095,7 @@
holder.icon_state = "janus18"
else
user.visible_message("[user] pries the internal armor layer from [holder].", "You pry the internal armor layer from [holder].")
var/obj/item/stack/material/durasteel/MS = new /obj/item/stack/material/durasteel(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/durasteel(get_turf(holder), 5)
holder.icon_state = "janus16"
if(4)
if(diff==FORWARD)
@@ -2139,8 +2117,7 @@
holder.icon_state = "janus21"
else
user.visible_message("[user] pries the external armor layer from [holder].", "You pry external armor layer from [holder].")
var/obj/item/stack/material/morphium/MS = new /obj/item/stack/material/morphium(get_turf(holder))
MS.amount = 5
new /obj/item/stack/material/morphium(get_turf(holder), 5)
holder.icon_state = "janus19"
if(1)
if(diff==FORWARD)
@@ -145,8 +145,7 @@
holder.icon_state = "polecat4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "polecat2"
if(16)
if(diff==FORWARD)
@@ -241,8 +240,7 @@
holder.icon_state = "polecat16"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 3
new /obj/item/stack/material/steel(get_turf(holder), 3)
holder.icon_state = "polecat14"
if(4)
if(diff==FORWARD)
@@ -402,8 +400,7 @@
holder.icon_state = "gopher4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "gopher2"
if(10)
if(diff==FORWARD)
@@ -450,8 +447,7 @@
holder.icon_state = "gopher10"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 3
new /obj/item/stack/material/steel(get_turf(holder), 3)
holder.icon_state = "gopher8"
if(4)
if(diff==FORWARD)
@@ -473,8 +469,7 @@
holder.icon_state = "gopher13"
else
user.visible_message("[user] pries external armor layer from [holder].", "You prie external armor layer from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 2
new /obj/item/stack/material/plasteel(get_turf(holder), 2)
holder.icon_state = "gopher11"
if(1)
if(diff==FORWARD)
@@ -635,8 +630,7 @@
holder.icon_state = "weasel4"
else
user.visible_message("[user] removes the wiring from [holder].", "You remove the wiring from [holder].")
var/obj/item/stack/cable_coil/coil = new /obj/item/stack/cable_coil(get_turf(holder))
coil.amount = 4
new /obj/item/stack/cable_coil(get_turf(holder), 4)
holder.icon_state = "weasel2"
if(16)
if(diff==FORWARD)
@@ -731,8 +725,7 @@
holder.icon_state = "weasel16"
else
user.visible_message("[user] pries internal armor layer from [holder].", "You prie internal armor layer from [holder].")
var/obj/item/stack/material/steel/MS = new /obj/item/stack/material/steel(get_turf(holder))
MS.amount = 3
new /obj/item/stack/material/steel(get_turf(holder), 3)
holder.icon_state = "weasel14"
if(4)
if(diff==FORWARD)
@@ -754,8 +747,7 @@
holder.icon_state = "weasel19"
else
user.visible_message("[user] pries external armor layer from [holder].", "You prie external armor layer from [holder].")
var/obj/item/stack/material/plasteel/MS = new /obj/item/stack/material/plasteel(get_turf(holder))
MS.amount = 3
new /obj/item/stack/material/plasteel(get_turf(holder), 3)
holder.icon_state = "weasel17"
if(1)
if(diff==FORWARD)
+1 -2
View File
@@ -29,8 +29,7 @@
to_chat(user, "<span class='warning'>There is another network terminal here.</span>")
return
else
var/obj/item/stack/cable_coil/C = new /obj/item/stack/cable_coil(loc)
C.amount = 10
new /obj/item/stack/cable_coil(loc, 10)
to_chat(user, "You cut the cables and disassemble the unused power terminal.")
qdel(T)
new /obj/machinery/power/apc(loc, ndir, 1)
@@ -127,7 +127,7 @@ var/list/marker_beacon_colors = list(
if(istype(I, /obj/item/stack/marker_beacon))
var/obj/item/stack/marker_beacon/M = I
to_chat(user, "<span class='notice'>You start picking [src] up...</span>")
if(do_after(user, remove_speed, target = src) && M.amount + 1 <= M.max_amount)
if(do_after(user, remove_speed, target = src) && M.get_amount() + 1 <= M.max_amount)
M.add(1)
playsound(src, 'sound/items/deconstruct.ogg', 50, 1)
qdel(src)
+42 -6
View File
@@ -17,7 +17,7 @@
center_of_mass = null
var/list/datum/stack_recipe/recipes
var/singular_name
var/amount = 1
VAR_PROTECTED/amount = 1
var/max_amount //also see stack recipes initialisation, param "max_res_amount" must be equal to this max_amount
var/stacktype //determines whether different stack types can merge
var/build_type = null //used when directly applied to a turf
@@ -33,8 +33,10 @@
. = ..()
if(!stacktype)
stacktype = type
if(amount)
src.amount = amount
if(!isnull(amount)) // Could be 0
if(amount < 0)
amount = max_amount
set_amount(amount, TRUE)
update_icon()
/obj/item/stack/Destroy()
@@ -229,12 +231,15 @@
//Return 1 if an immediate subsequent call to use() would succeed.
//Ensures that code dealing with stacks uses the same logic
/obj/item/stack/proc/can_use(var/used)
if (get_amount() < used)
if(used < 0 || used % 1)
stack_trace("Tried to use a bad stack amount: [used]")
return 0
if(get_amount() < used)
return 0
return 1
/obj/item/stack/proc/use(var/used)
if (!can_use(used))
if(!can_use(used))
return 0
if(!uses_charge)
amount -= used
@@ -251,6 +256,9 @@
return 1
/obj/item/stack/proc/add(var/extra)
if(extra < 0 || extra % 1)
stack_trace("Tried to add a bad stack amount: [extra]")
return 0
if(!uses_charge)
if(amount + extra > get_max_amount())
return 0
@@ -265,6 +273,27 @@
var/datum/matter_synth/S = synths[i]
S.add_charge(charge_costs[i] * extra)
/obj/item/stack/proc/set_amount(var/new_amount, var/no_limits = FALSE)
if(new_amount < 0 || new_amount % 1)
stack_trace("Tried to set a bad stack amount: [new_amount]")
return 0
// Clean up the new amount
new_amount = max(round(new_amount), 0)
// Can exceed max if you really want
if(new_amount > max_amount && !no_limits)
new_amount = max_amount
amount = new_amount
// Can set it to 0 without qdel if you really want
if(amount == 0 && !no_limits)
qdel(src)
return FALSE
return TRUE
/*
The transfer and split procs work differently than use() and add().
Whereas those procs take no action if the desired amount cannot be added or removed these procs will try to transfer whatever they can.
@@ -282,6 +311,10 @@
if (isnull(tamount))
tamount = src.get_amount()
if(tamount < 0 || tamount % 1)
stack_trace("Tried to transfer a bad stack amount: [tamount]")
return 0
var/transfer = max(min(tamount, src.get_amount(), (S.get_max_amount() - S.get_amount())), 0)
@@ -302,7 +335,10 @@
if(uses_charge)
return null
tamount = round(tamount)
if(tamount < 0 || tamount % 1)
stack_trace("Tried to split a bad stack amount: [tamount]")
return null
var/transfer = max(min(tamount, src.amount, initial(max_amount)), 0)
var/orig_amount = src.amount
@@ -130,10 +130,10 @@
/obj/item/weapon/card/emag/attackby(obj/item/O as obj, mob/user as mob)
if(istype(O, /obj/item/stack/telecrystal))
var/obj/item/stack/telecrystal/T = O
if(T.amount < 1)
if(T.get_amount() < 1)
to_chat(usr, "<span class='notice'>You are not adding enough telecrystals to fuel \the [src].</span>")
return
uses += T.amount/2 //Gives 5 uses per 10 TC
uses += T.get_amount()*0.5 //Gives 5 uses per 10 TC
uses = CEILING(uses, 1) //Ensures no decimal uses nonsense, rounds up to be nice
to_chat(usr, "<span class='notice'>You add \the [O] to \the [src]. Increasing the uses of \the [src] to [uses].</span>")
qdel(O)
@@ -13,7 +13,7 @@
/obj/item/weapon/whetstone/attackby(obj/item/I, mob/user)
if(istype(I, /obj/item/stack/material))
var/obj/item/stack/material/M = I
if(M.amount >= 5)
if(M.get_amount() >= 5)
to_chat(user, "You begin to refine the [src] with [M]...")
if(do_after(user, 70))
M.use(5)
+23 -25
View File
@@ -245,7 +245,7 @@
return 0
var/current = 0
for(var/obj/item/stack/material/S in contents)
current += S.amount
current += S.get_amount()
if(capacity == current)//If it's full, you're done
if(!stop_messages)
to_chat(usr, "<span class='warning'>The snatcher is full.</span>")
@@ -262,29 +262,27 @@
var/inserted = 0
var/current = 0
for(var/obj/item/stack/material/S2 in contents)
current += S2.amount
if(capacity < current + S.amount)//If the stack will fill it up
current += S2.get_amount()
if(capacity < current + S.get_amount())//If the stack will fill it up
amount = capacity - current
else
amount = S.amount
amount = S.get_amount()
for(var/obj/item/stack/material/sheet in contents)
if(S.type == sheet.type) // we are violating the amount limitation because these are not sane objects
sheet.amount += amount // they should only be removed through procs in this file, which split them up.
S.amount -= amount
if(S.type == sheet.type)
// we are violating the amount limitation because these are not sane objects
sheet.set_amount(sheet.get_amount() + amount, TRUE)
S.use(amount) // will qdel() if we use it all
inserted = 1
break
if(!inserted || !S.amount)
if(!inserted)
usr.remove_from_mob(S)
usr.update_icons() //update our overlays
if (usr.client && usr.s_active != src)
usr.client.screen -= S
S.dropped(usr)
if(!S.amount)
qdel(S)
else
S.loc = src
S.loc = src
orient2hud(usr)
if(usr.s_active)
@@ -305,7 +303,7 @@
for(var/obj/item/stack/material/I in contents)
adjusted_contents++
var/datum/numbered_display/D = new/datum/numbered_display(I)
D.number = I.amount
D.number = I.get_amount()
numbered_contents.Add( D )
var/row_num = 0
@@ -319,14 +317,14 @@
/obj/item/weapon/storage/bag/sheetsnatcher/quick_empty()
var/location = get_turf(src)
for(var/obj/item/stack/material/S in contents)
while(S.amount)
var/obj/item/stack/material/N = new S.type(location)
var/stacksize = min(S.amount,N.max_amount)
N.amount = stacksize
S.amount -= stacksize
N.update_icon()
if(!S.amount)
qdel(S) // todo: there's probably something missing here
var/cur_amount = S.get_amount()
var/full_stacks = round(cur_amount / S.max_amount) // Floor of current/max is amount of full stacks we make
var/remainder = cur_amount % S.max_amount // Current mod max is remainder after full sheets removed
for(var/i = 1 to full_stacks)
new S.type(location, S.max_amount)
if(remainder)
new S.type(location, remainder)
S.set_amount(0)
orient2hud(usr)
if(usr.s_active)
usr.s_active.show_to(usr)
@@ -342,10 +340,10 @@
//Therefore, make a new stack internally that has the remainder.
// -Sayu
if(S.amount > S.max_amount)
var/obj/item/stack/material/temp = new S.type(src)
temp.amount = S.amount - S.max_amount
S.amount = S.max_amount
if(S.get_amount() > S.max_amount)
var/newstack_amt = S.get_amount() - S.max_amount
new S.type(src, newstack_amt) // The one we'll keep to replace the one we give
S.set_amount(S.max_amount) // The one we hand to the clicker
return ..(S,new_location)
@@ -116,7 +116,6 @@
for(var/i = 0, i<2, i++)
for(var/res in resources)
var/obj/item/stack/R = new res(src)
R.amount = R.max_amount
new res(src, -1)
return ..()
+1 -2
View File
@@ -43,8 +43,7 @@
to_chat(user, "<span class='notice'>You start to cut the shower curtains.</span>")
if(do_after(user, 10))
to_chat(user, "<span class='notice'>You cut the shower curtains.</span>")
var/obj/item/stack/material/plastic/A = new /obj/item/stack/material/plastic( src.loc )
A.amount = 3
new /obj/item/stack/material/plastic(src.loc, 3)
qdel(src)
return
else
+1 -2
View File
@@ -113,8 +113,7 @@
if(finished)
to_chat(user, "<span class='notice'>You start breaking down \the [src].</span>")
if(do_after(user, 10 SECONDS, src, exclusive = TASK_ALL_EXCLUSIVE))
var/obj/item/stack/S = new /obj/item/stack/material/plasteel(loc)
S.amount = 10
new /obj/item/stack/material/plasteel(loc, 10)
playsound(user, O.usesound, 50, 1)
qdel(src)
else
+1 -2
View File
@@ -101,8 +101,7 @@
return
if(product && product_amount) // Make wooden logs.
var/obj/item/stack/material/M = new product(get_turf(src))
M.amount = product_amount
var/obj/item/stack/material/M = new product(get_turf(src), product_amount)
M.update_icon()
visible_message("<span class='danger'>\The [src] is felled!</span>")
stump()
+1 -2
View File
@@ -22,8 +22,7 @@
to_chat(user, "<span class='notice'>You start to cut the plastic flaps.</span>")
if(do_after(user, 10 * P.toolspeed))
to_chat(user, "<span class='notice'>You cut the plastic flaps.</span>")
var/obj/item/stack/material/plastic/A = new /obj/item/stack/material/plastic( src.loc )
A.amount = 4
new /obj/item/stack/material/plastic(src.loc, 4)
qdel(src)
return
else
+1 -1
View File
@@ -297,7 +297,7 @@
visible_message("<span class='notice'>[user] dismantles \the [src].</span>")
var/obj/item/stack/material/mats = new glasstype(loc)
if(is_fulltile())
mats.amount = 4
mats.set_amount(4)
qdel(src)
else if(istype(W, /obj/item/stack/cable_coil) && reinf && state == 0 && !istype(src, /obj/structure/window/reinforced/polarized))
var/obj/item/stack/cable_coil/C = W
+1 -1
View File
@@ -96,7 +96,7 @@
if(!use_flooring)
return
// Do we have enough?
if(use_flooring.build_cost && S.amount < use_flooring.build_cost)
if(use_flooring.build_cost && S.get_amount() < use_flooring.build_cost)
to_chat(user, "<span class='warning'>You require at least [use_flooring.build_cost] [S.name] to complete the [use_flooring.descriptor].</span>")
return
// Stay still and focus...
+1 -2
View File
@@ -31,8 +31,7 @@
to_chat(user, "<span class='notice'>You begin to remove \the [src] with your [W].</span>")
if(do_after(user, 4 SECONDS * W.toolspeed))
to_chat(user, "<span class='notice'>\The [src] has been dug up, and now lies in a pile nearby.</span>")
var/obj/item/stack/material/snow/S = new(src)
S.amount = 10
new /obj/item/stack/material/snow(src, 10)
demote()
else
to_chat(user, "<span class='notice'>You decide to not finish removing \the [src].</span>")
@@ -7,8 +7,7 @@
if(icon_state in has_rocks)
user.visible_message("[user] loosens rocks from \the [src]...", "You loosen rocks from \the [src]...")
if(do_after(user, 5 SECONDS, exclusive = TASK_USER_EXCLUSIVE))
var/obj/item/stack/material/flint/R = new(get_turf(src))
R.amount = rand(1,4)
var/obj/item/stack/material/flint/R = new(get_turf(src), rand(1,4))
R.pixel_x = rand(-6,6)
R.pixel_y = rand(-6,6)
icon_state = "dirt0"
@@ -34,9 +33,8 @@
user.visible_message("[user] starts digging around in \the [src]...", "You start digging around in \the [src]...")
if(do_after(user, 5 SECONDS, exclusive = TASK_USER_EXCLUSIVE))
if(prob(rock_chance))
var/obj/item/stack/material/flint/R = new(get_turf(src))
var/obj/item/stack/material/flint/R = new(get_turf(src), rand(1,4))
to_chat(user, "<span class='notice'>You found some [R]</span>")
R.amount = rand(1,4)
R.pixel_x = rand(-6,6)
R.pixel_y = rand(-6,6)
else
@@ -73,8 +71,7 @@
if(sticks)
user.visible_message("[user] searches \the [src] for loose sticks...", "You search \the [src] for loose sticks...")
if(do_after(user, 5 SECONDS, exclusive = TASK_USER_EXCLUSIVE))
var/obj/item/stack/material/stick/S = new(get_turf(user))
S.amount = rand(1,3)
var/obj/item/stack/material/stick/S = new(get_turf(user), rand(1,3))
S.pixel_x = rand(-6,6)
S.pixel_y = rand(-6,6)
sticks = FALSE
+1 -2
View File
@@ -57,8 +57,7 @@
var/bar_type = pick(possible_spawns)
for(var/i=0,i<amount,i++)
var/obj/item/stack/material/M = new bar_type(C)
M.amount = quantity
new bar_type(C, quantity)
else
//credits
var/amount = rand(2,6)
+1 -2
View File
@@ -270,8 +270,7 @@
SStgui.update_uis(src)
if(ispath(bi.equipment_path, /obj/item/stack))
var/obj/item/stack/S = new bi.equipment_path(loc)
S.amount = bi.equipment_amt
new bi.equipment_path(loc, bi.equipment_amt)
playsound(src, 'sound/machines/vending/vending_drop.ogg', 100, 1)
return TRUE
@@ -95,7 +95,7 @@
return
var/obj/item/stack/cable_coil/cable = W
if(!cable.amount >= 5)
if(!cable.get_amount() >= 5)
to_chat(user, "You need five units of cable to repair \the [src].")
return
+1 -2
View File
@@ -76,8 +76,7 @@
..()
return
var/obj/item/stack/cable_coil/CC = new/obj/item/stack/cable_coil(user.loc)
CC.amount = 1
var/obj/item/stack/cable_coil/CC = new (user.loc)
CC.update_icon()
cut_overlays()
string_attached = null
+1 -1
View File
@@ -58,7 +58,7 @@
return
else if(istype(I, /obj/item/stack/cable_coil) && !strung)
var/obj/item/stack/cable_coil/C = I
if(C.amount < 5)
if(C.get_amount() < 5)
to_chat(user, "<span class='warning'>You do not have enough length in \the [C] to string this!</span>")
return
if(do_after(user, rand(10 SECONDS, 20 SECONDS)))
@@ -60,7 +60,7 @@
for(var/obj/item/stack/wetleather/WL in I.instances)
if(!WL.wetness)
if(WL.amount)
if(WL.get_amount())
WL.forceMove(get_turf(src))
WL.dry()
I.instances -= WL
@@ -20,7 +20,7 @@
while(count > 0)
var/obj/item/stack/S = I.get_product(get_turf(src), min(count, amount))
count -= S.amount
count -= S.get_amount()
SStgui.update_uis(src)
/obj/machinery/smartfridge/sheets/find_record(var/obj/item/O)
+6 -6
View File
@@ -201,12 +201,12 @@
var/obj/item/stack/material/wood/NG = new (user.loc)
if(flesh_colour) NG.color = flesh_colour
for (var/obj/item/stack/material/wood/G in user.loc)
if(G==NG)
if(G == NG)
continue
if(G.amount>=G.max_amount)
if(G.get_amount() >= G.max_amount)
continue
G.attackby(NG, user)
to_chat(user, "You add the newly-formed wood to the stack. It now contains [NG.amount] planks.")
to_chat(user, "You add the newly-formed wood to the stack. It now contains [NG.get_amount()] planks.")
qdel(src)
return
else if(!isnull(seed.chems["potato"]))
@@ -280,12 +280,12 @@
var/obj/item/stack/tile/grass/G = new (user.loc)
if(flesh_colour) G.color = flesh_colour
for (var/obj/item/stack/tile/grass/NG in user.loc)
if(G==NG)
if(G == NG)
continue
if(NG.amount>=NG.max_amount)
if(NG.get_amount() >= NG.max_amount)
continue
NG.attackby(G, user)
to_chat(user, "You add the newly-formed grass to the stack. It now contains [G.amount] tiles.")
to_chat(user, "You add the newly-formed grass to the stack. It now contains [G.get_amount()] tiles.")
qdel(src)
return
@@ -40,7 +40,7 @@
if(debug)
to_chat(user, span("warning", "\The [src] does not need any material."))
return
var/num = min((max_metal - metal) / metal_per_sheet, stack.amount)
var/num = min((max_metal - metal) / metal_per_sheet, stack.get_amount())
if(num < 1)
to_chat(user, span("warning", "\The [src] is too full to add more metal."))
return
+1 -2
View File
@@ -10,8 +10,7 @@
..()
var/turf/T = get_turf(src)
var/obj/structure/closet/C = locate() in T
var/obj/item/stack/M = new type_to_spawn(C || T)
M.amount = M.max_amount //some stuff spawns with 60, we're still calling it fifty
var/obj/item/stack/M = new type_to_spawn(C || T, -1)
M.update_icon() // Some stacks have different sprites depending on how full they are.
return INITIALIZE_HINT_QDEL //Bye!
@@ -312,9 +312,9 @@ var/list/name_to_material
place_sheet(target)
// Debris product. Used ALL THE TIME.
/datum/material/proc/place_sheet(var/turf/target)
/datum/material/proc/place_sheet(var/turf/target, amount)
if(stack_type)
return new stack_type(target)
return new stack_type(target, amount)
// As above.
/datum/material/proc/place_shard(var/turf/target)
@@ -24,14 +24,14 @@
//Try locating an exisitng stack on the tile and add to there if possible
var/obj/item/stack/hairlesshide/H = null
for(var/obj/item/stack/hairlesshide/HS in user.loc) // Could be scraping something inside a locker, hence the .loc, not get_turf
if(HS.amount < HS.max_amount)
if(HS.get_amount() < HS.max_amount)
H = HS
break
// Either we found a valid stack, in which case increment amount,
// Or we need to make a new stack
if(istype(H))
H.amount++
H.add(1)
else
H = new /obj/item/stack/hairlesshide(user.loc)
@@ -21,14 +21,14 @@
for(var/i in 1 to wateramount)
var/obj/item/stack/wetleather/H = null
for(var/obj/item/stack/wetleather/HS in get_turf(src)) // Doesn't have a user, can't just use their loc
if(HS.amount < HS.max_amount)
if(HS.get_amount() < HS.max_amount)
H = HS
break
// Either we found a valid stack, in which case increment amount,
// Or we need to make a new stack
if(istype(H))
H.amount++
H.add(1)
else
H = new /obj/item/stack/wetleather(get_turf(src))
@@ -38,9 +38,8 @@
dry()
/obj/item/stack/wetleather/proc/dry()
var/obj/item/stack/material/leather/L = new(src.loc)
L.amount = amount
use(amount)
var/obj/item/stack/material/leather/L = new(src.loc, get_amount())
use(get_amount())
return L
/obj/item/stack/wetleather/transfer_to(obj/item/stack/S, var/tamount=null, var/type_verified)
@@ -41,7 +41,7 @@
drying = A
else // Drying something, add if possible
var/obj/item/stack/wetleather/W = A
W.transfer_to(drying, W.amount, TRUE)
W.transfer_to(drying, W.get_amount(), TRUE)
update_icon()
return TRUE
return ..()
@@ -50,9 +50,8 @@
if(drying)
var/obj/item/stack/S = drying
if(!drying.wetness) // If it's dry, make a stack of dry leather and prepare to put that in their hands
var/obj/item/stack/material/leather/L = new(src)
L.amount = drying.amount
drying.use(drying.amount)
var/obj/item/stack/material/leather/L = new(src, drying.get_amount())
drying.set_amount(0)
S = L
if(ishuman(user))
@@ -47,10 +47,9 @@
existing_wood = M
break
var/obj/item/stack/material/wood/new_wood = new plank_type(user.loc)
new_wood.amount = 2
var/obj/item/stack/material/wood/new_wood = new plank_type(user.loc, 2)
if(existing_wood && new_wood.transfer_to(existing_wood))
to_chat(user, "<span class='notice'>You add the newly-formed wood to the stack. It now contains [existing_wood.amount] planks.</span>")
to_chat(user, "<span class='notice'>You add the newly-formed wood to the stack. It now contains [existing_wood.get_amount()] planks.</span>")
else
return ..()
@@ -62,10 +62,8 @@
var/stack = params["stack"]
if(machine.stack_storage[stack] > 0)
var/stacktype = machine.stack_paths[stack]
var/obj/item/stack/material/S = new stacktype(get_turf(machine.output))
S.amount = machine.stack_storage[stack]
new stacktype(get_turf(machine.output), machine.stack_storage[stack])
machine.stack_storage[stack] = 0
S.update_icon()
. = TRUE
add_fingerprint(usr)
@@ -125,7 +123,7 @@
var/obj/item/stack/material/S = O
var/matname = S.material.name
if(!isnull(stack_storage[matname]))
stack_storage[matname] += S.amount
stack_storage[matname] += S.get_amount()
qdel(S)
else
O.loc = output.loc
@@ -136,10 +134,8 @@
for(var/sheet in stack_storage)
if(stack_storage[sheet] >= stack_amt)
var/stacktype = stack_paths[sheet]
var/obj/item/stack/material/S = new stacktype (get_turf(output))
S.amount = stack_amt
new stacktype (get_turf(output), stack_amt)
stack_storage[sheet] -= stack_amt
S.update_icon()
if(console)
console.updateUsrDialog()
+1 -2
View File
@@ -298,8 +298,7 @@
new /obj/item/device/assembly/prox_sensor(Tsec)
if(prob(50))
new /obj/item/robot_parts/l_arm(Tsec)
var/obj/item/stack/tile/floor/T = new /obj/item/stack/tile/floor(Tsec)
T.amount = amount
new /obj/item/stack/tile/floor(Tsec, amount)
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(3, 1, src)
s.start()
@@ -215,8 +215,8 @@
to_chat(src,"<span class='warning'>You can't process [substance]!</span>")
return //Only a few things matter, the rest are best not cluttering the lists.
var/howmuch = input(src,"How much do you want to store? (0-[matstack.amount])","Select amount") as null|num
if(!howmuch || matstack != get_active_hand() || howmuch > matstack.amount)
var/howmuch = input(src,"How much do you want to store? (0-[matstack.get_amount()])","Select amount") as null|num
if(!howmuch || matstack != get_active_hand() || howmuch > matstack.get_amount())
return //Quietly fail
var/actually_added = refactory.add_stored_material(substance,howmuch*matstack.perunit)
@@ -131,8 +131,7 @@
H.synth_color = TRUE
/datum/species/protean/equip_survival_gear(var/mob/living/carbon/human/H)
var/obj/item/stack/material/steel/metal_stack = new()
metal_stack.amount = 3
var/obj/item/stack/material/steel/metal_stack = new(null, 3)
var/obj/item/clothing/accessory/permit/nanotech/permit = new()
permit.set_name(H.real_name)
@@ -59,11 +59,8 @@
// This could be done better.
var/obj/item/stack/medical/MED = O
if(health < getMaxHealth())
if(MED.amount >= 1)
if(MED.use(1))
adjustBruteLoss(-MED.heal_brute)
MED.amount -= 1
if(MED.amount <= 0)
qdel(MED)
visible_message("<b>\The [user]</b> applies the [MED] on [src].")
else
var/datum/gender/T = gender_datums[src.get_visible_gender()]
@@ -757,8 +757,7 @@ GLOBAL_VAR_INIT(teppi_count, 0) // How mant teppi DO we have?
if(do_after(user, sheartime, exclusive = TASK_USER_EXCLUSIVE, target = src))
user.visible_message("<span class='notice'>\The [user] shears \the [src] with \the [tool].</span>","<span class='notice'>You shear \the [src] with \the [tool].</span>")
amount_grown = rand(0,250)
var/obj/item/stack/material/fur/F = new(get_turf(user))
F.amount = rand(10,15)
var/obj/item/stack/material/fur/F = new(get_turf(user), rand(10,15))
F.color = marking_color
teppi_wool = FALSE
update_icon()
@@ -57,8 +57,7 @@
continue
while(count > 0)
inst = new real_path
inst.amount = min(count, max_amount)
inst = new real_path(null, min(count, max_amount))
count -= inst.get_amount()
. += inst
+1 -1
View File
@@ -559,7 +559,7 @@ GLOBAL_LIST_EMPTY(apcs)
"You start adding cables to the APC frame...")
playsound(src, 'sound/items/Deconstruct.ogg', 50, 1)
if(do_after(user, 20))
if(C.amount >= 10 && !terminal && opened && has_electronics != APC_HAS_ELECTRONICS_SECURED)
if(C.get_amount() >= 10 && !terminal && opened && has_electronics != APC_HAS_ELECTRONICS_SECURED)
var/obj/structure/cable/N = T.get_cable_node()
if(prob(50) && electrocute_mob(usr, N, N))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
+3 -5
View File
@@ -163,10 +163,8 @@
//Removes one stack's worth of material from the generator.
/obj/machinery/power/port_gen/pacman/DropFuel()
if(sheets)
var/obj/item/stack/material/S = new sheet_path(loc)
var/amount = min(sheets, S.max_amount)
S.amount = amount
sheets -= amount
var/obj/item/stack/material/S = new sheet_path(loc, sheets)
sheets -= S.get_amount()
/obj/machinery/power/port_gen/pacman/UseFuel()
@@ -265,7 +263,7 @@
/obj/machinery/power/port_gen/pacman/attackby(var/obj/item/O as obj, var/mob/user as mob)
if(istype(O, sheet_path))
var/obj/item/stack/addstack = O
var/amount = min((max_sheets - sheets), addstack.amount)
var/amount = min((max_sheets - sheets), addstack.get_amount())
if(amount < 1)
to_chat(user, "<span class='warning'>The [src.name] is full!</span>")
return
+1 -1
View File
@@ -216,7 +216,7 @@
to_chat(user, "<span class='notice'>\The [src] is already fully repaired.</span>")
return
var/obj/item/stack/P = W
if(P.amount < amt)
if(!P.can_use(amt))
to_chat(user, "<span class='warning'>You don't have enough sheets to repair this! You need at least [amt] sheets.</span>")
return
to_chat(user, "<span class='notice'>You begin repairing \the [src]...</span>")
+1 -2
View File
@@ -63,8 +63,7 @@ GLOBAL_LIST_EMPTY(solars_list)
if(do_after(user, 50))
var/obj/item/solar_assembly/S = new(loc)
S.anchored = TRUE
var/obj/item/stack/glass = new glass_type(loc)
glass.amount = 2
new glass_type(loc, 2)
playsound(src, 'sound/items/Deconstruct.ogg', 50, 1)
user.visible_message("<span class='notice'>[user] takes the glass off the solar panel.</span>")
qdel(src)
+1 -2
View File
@@ -58,8 +58,7 @@
var/obj/item/solar_assembly/S = new(loc)
S.tracker = TRUE
S.anchored = TRUE
var/obj/item/stack/glass = new glass_type(loc)
glass.amount = 2
new glass_type(loc, 2)
playsound(src, 'sound/items/Deconstruct.ogg', 50, 1)
user.visible_message("<span class='notice'>[user] takes the glass off the tracker.</span>")
qdel(src)
+1 -1
View File
@@ -232,7 +232,7 @@
var/obj/item/stack/stack = O
if(istype(stack))
var/list/sheet_components = sheet_reagents[stack.type]
var/amount_to_take = max(0,min(stack.amount,round(remaining_volume/REAGENTS_PER_SHEET)))
var/amount_to_take = max(0,min(stack.get_amount(),round(remaining_volume/REAGENTS_PER_SHEET)))
if(amount_to_take)
stack.use(amount_to_take)
if(QDELETED(stack))
@@ -270,9 +270,7 @@
var/chosen = pick(material)
if(chosen in rare_types)
spawn_amount = rand(1,15)
var/obj/item/stack/material/C = new chosen
C.amount = spawn_amount
C.loc = get_turf(holder.my_atom)
new chosen(get_turf(holder.my_atom), spawn_amount)
/decl/chemical_reaction/instant/slimelight
name = "Slime Glow"
@@ -296,9 +294,7 @@
result_amount = 1
/decl/chemical_reaction/instant/slimephoron/on_reaction(var/datum/reagents/holder)
var/obj/item/stack/material/phoron/P = new /obj/item/stack/material/phoron
P.amount = 10
P.loc = get_turf(holder.my_atom)
new /obj/item/stack/material/phoron(get_turf(holder.my_atom), 10)
/decl/chemical_reaction/instant/slimefreeze
name = "Slime Freeze"
+4 -4
View File
@@ -342,11 +342,11 @@
if(istype(O, /obj/item/stack/medical/bruise_pack) && round(volume) >= 5)
var/obj/item/stack/medical/bruise_pack/C = O
var/packname = C.name
var/to_produce = min(C.amount, round(volume / 5))
var/to_produce = min(C.get_amount(), round(volume / 5))
var/obj/item/stack/medical/M = C.upgrade_stack(to_produce)
if(M && M.amount)
if(M && M.get_amount())
holder.my_atom.visible_message("<b>\The [packname]</b> bubbles.")
remove_self(to_produce * 5)
@@ -1251,11 +1251,11 @@
if(istype(O, /obj/item/stack/medical/crude_pack) && round(volume) >= 1)
var/obj/item/stack/medical/crude_pack/C = O
var/packname = C.name
var/to_produce = min(C.amount, round(volume))
var/to_produce = min(C.get_amount(), round(volume))
var/obj/item/stack/medical/M = C.upgrade_stack(to_produce)
if(M && M.amount)
if(M && M.get_amount())
holder.my_atom.visible_message("<b>\The [packname]</b> bubbles.")
remove_self(to_produce)
+2 -2
View File
@@ -188,8 +188,8 @@
var/stacktype = M.stack_type
var/turf/T = get_step(src, dir)
var/obj/item/stack/S = locate(stacktype) in T
if(S)
S.amount++
if(S && S.get_amount() < S.max_amount)
S.add(1)
else
new stacktype(T)
+1 -2
View File
@@ -100,8 +100,7 @@ using metal and glass, it uses glass and reagents (usually sulphuric acid).
if(materials[f] >= SHEET_MATERIAL_AMOUNT)
var/path = getMaterialType(f)
if(path)
var/obj/item/stack/S = new path(loc)
S.amount = round(materials[f] / SHEET_MATERIAL_AMOUNT)
new path(loc, round(materials[f] / SHEET_MATERIAL_AMOUNT))
..()
/obj/machinery/r_n_d/circuit_imprinter/attackby(var/obj/item/O as obj, var/mob/user as mob)
+2 -4
View File
@@ -233,7 +233,7 @@
new_item.matter[i] = new_item.matter[i] * mat_efficiency
/obj/machinery/r_n_d/protolathe/proc/eject_materials(var/material, var/amount) // 0 amount = 0 means ejecting a full stack; -1 means eject everything
var/recursive = amount == -1 ? 1 : 0
var/recursive = amount == -1 ? TRUE : FALSE
material = lowertext(material)
var/obj/item/stack/material/mattype
var/datum/material/MAT = get_material_by_name(material)
@@ -250,9 +250,7 @@
if(amount <= 0)
amount = S.max_amount
var/ejected = min(round(materials[material] / S.perunit), amount)
S.amount = min(ejected, amount)
if(S.amount <= 0)
qdel(S)
if(!S.set_amount(ejected, amount))
return
materials[material] -= ejected * S.perunit
if(recursive && materials[material] >= S.perunit)
+1 -2
View File
@@ -38,6 +38,5 @@
eject = amount == -1 ? eject : min(eject, amount)
if(eject < 1)
return
var/obj/item/stack/material/S = new sheetType(loc)
S.amount = eject
new sheetType(loc, eject)
materials[material] -= eject * perUnit
+2 -2
View File
@@ -388,9 +388,9 @@
var/amnt = S.perunit
if(stored_material[S.material.name] + amnt <= max_res_amount)
if(S && S.amount >= 1)
if(S && S.get_amount() >= 1)
var/count = 0
while(stored_material[S.material.name] + amnt <= max_res_amount && S.amount >= 1)
while(stored_material[S.material.name] + amnt <= max_res_amount && S.get_amount() >= 1)
stored_material[S.material.name] += amnt
S.use(1)
count++