mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-16 09:34:52 +01:00
Absolute paths
This commit is contained in:
@@ -10,81 +10,81 @@
|
||||
// Large, but inaccurate. Use a chem dispenser or beaker for accuracy.
|
||||
possible_transfer_amounts = list(50, 100)
|
||||
|
||||
New()
|
||||
..()
|
||||
if(spawn_reagent)
|
||||
reagents.add_reagent(spawn_reagent, volume)
|
||||
var/datum/reagent/R = chemical_reagents_list[spawn_reagent]
|
||||
setLabel(R.name)
|
||||
|
||||
var/spawn_reagent = null
|
||||
var/label = ""
|
||||
|
||||
examine(mob/user)
|
||||
..()
|
||||
user << "It has a capacity of [volume] units."
|
||||
if(reagents.total_volume <= 0)
|
||||
user << "It is empty."
|
||||
else
|
||||
user << "It contains [reagents.total_volume] units of liquid."
|
||||
if(!is_open_container())
|
||||
user << "The cap is sealed."
|
||||
/obj/item/weapon/reagent_containers/chem_disp_cartridge/New()
|
||||
..()
|
||||
if(spawn_reagent)
|
||||
reagents.add_reagent(spawn_reagent, volume)
|
||||
var/datum/reagent/R = chemical_reagents_list[spawn_reagent]
|
||||
setLabel(R.name)
|
||||
|
||||
verb/setLabel(L as text)
|
||||
set name = "Set Cartridge Label"
|
||||
set category = "Object"
|
||||
set src in view(usr, 1)
|
||||
if(L)
|
||||
if(usr)
|
||||
usr << "<span class='notice'>You set the label on \the [src] to '[L]'.</span>"
|
||||
/obj/item/weapon/reagent_containers/chem_disp_cartridge/examine(mob/user)
|
||||
..()
|
||||
user << "It has a capacity of [volume] units."
|
||||
if(reagents.total_volume <= 0)
|
||||
user << "It is empty."
|
||||
else
|
||||
user << "It contains [reagents.total_volume] units of liquid."
|
||||
if(!is_open_container())
|
||||
user << "The cap is sealed."
|
||||
|
||||
label = L
|
||||
name = "[initial(name)] - '[L]'"
|
||||
else
|
||||
if(usr)
|
||||
usr << "<span class='notice'>You clear the label on \the [src].</span>"
|
||||
label = ""
|
||||
name = initial(name)
|
||||
/obj/item/weapon/reagent_containers/chem_disp_cartridge/verb/setLabel(L as text)
|
||||
set name = "Set Cartridge Label"
|
||||
set category = "Object"
|
||||
set src in view(usr, 1)
|
||||
if(L)
|
||||
if(usr)
|
||||
usr << "<span class='notice'>You set the label on \the [src] to '[L]'.</span>"
|
||||
|
||||
attack_self()
|
||||
..()
|
||||
if (is_open_container())
|
||||
usr << "<span class = 'notice'>You put the cap on \the [src].</span>"
|
||||
flags ^= OPENCONTAINER
|
||||
else
|
||||
usr << "<span class = 'notice'>You take the cap off \the [src].</span>"
|
||||
flags |= OPENCONTAINER
|
||||
label = L
|
||||
name = "[initial(name)] - '[L]'"
|
||||
else
|
||||
if(usr)
|
||||
usr << "<span class='notice'>You clear the label on \the [src].</span>"
|
||||
label = ""
|
||||
name = initial(name)
|
||||
|
||||
afterattack(obj/target, mob/user , flag)
|
||||
if (!is_open_container() || !flag)
|
||||
/obj/item/weapon/reagent_containers/chem_disp_cartridge/attack_self()
|
||||
..()
|
||||
if (is_open_container())
|
||||
usr << "<span class = 'notice'>You put the cap on \the [src].</span>"
|
||||
flags ^= OPENCONTAINER
|
||||
else
|
||||
usr << "<span class = 'notice'>You take the cap off \the [src].</span>"
|
||||
flags |= OPENCONTAINER
|
||||
|
||||
/obj/item/weapon/reagent_containers/chem_disp_cartridge/afterattack(obj/target, mob/user , flag)
|
||||
if (!is_open_container() || !flag)
|
||||
return
|
||||
|
||||
else if(istype(target, /obj/structure/reagent_dispensers)) //A dispenser. Transfer FROM it TO us.
|
||||
target.add_fingerprint(user)
|
||||
|
||||
if(!target.reagents.total_volume && target.reagents)
|
||||
user << "<span class='warning'>\The [target] is empty.</span>"
|
||||
return
|
||||
|
||||
else if(istype(target, /obj/structure/reagent_dispensers)) //A dispenser. Transfer FROM it TO us.
|
||||
target.add_fingerprint(user)
|
||||
if(reagents.total_volume >= reagents.maximum_volume)
|
||||
user << "<span class='warning'>\The [src] is full.</span>"
|
||||
return
|
||||
|
||||
if(!target.reagents.total_volume && target.reagents)
|
||||
user << "<span class='warning'>\The [target] is empty.</span>"
|
||||
return
|
||||
var/trans = target.reagents.trans_to(src, target:amount_per_transfer_from_this)
|
||||
user << "<span class='notice'>You fill \the [src] with [trans] units of the contents of \the [target].</span>"
|
||||
|
||||
if(reagents.total_volume >= reagents.maximum_volume)
|
||||
user << "<span class='warning'>\The [src] is full.</span>"
|
||||
return
|
||||
else if(target.is_open_container() && target.reagents) //Something like a glass. Player probably wants to transfer TO it.
|
||||
|
||||
var/trans = target.reagents.trans_to(src, target:amount_per_transfer_from_this)
|
||||
user << "<span class='notice'>You fill \the [src] with [trans] units of the contents of \the [target].</span>"
|
||||
if(!reagents.total_volume)
|
||||
user << "<span class='warning'>\The [src] is empty.</span>"
|
||||
return
|
||||
|
||||
else if(target.is_open_container() && target.reagents) //Something like a glass. Player probably wants to transfer TO it.
|
||||
if(target.reagents.total_volume >= target.reagents.maximum_volume)
|
||||
user << "<span class='warning'>\The [target] is full.</span>"
|
||||
return
|
||||
|
||||
if(!reagents.total_volume)
|
||||
user << "<span class='warning'>\The [src] is empty.</span>"
|
||||
return
|
||||
var/trans = src.reagents.trans_to(target, amount_per_transfer_from_this)
|
||||
user << "<span class='notice'>You transfer [trans] units of the solution to \the [target].</span>"
|
||||
|
||||
if(target.reagents.total_volume >= target.reagents.maximum_volume)
|
||||
user << "<span class='warning'>\The [target] is full.</span>"
|
||||
return
|
||||
|
||||
var/trans = src.reagents.trans_to(target, amount_per_transfer_from_this)
|
||||
user << "<span class='notice'>You transfer [trans] units of the solution to \the [target].</span>"
|
||||
|
||||
else
|
||||
return ..()
|
||||
else
|
||||
return ..()
|
||||
@@ -18,158 +18,158 @@
|
||||
density = 1
|
||||
anchored = 1
|
||||
|
||||
New()
|
||||
..()
|
||||
/obj/machinery/chemical_dispenser/New()
|
||||
..()
|
||||
|
||||
if(spawn_cartridges)
|
||||
for(var/type in spawn_cartridges)
|
||||
add_cartridge(new type(src))
|
||||
if(spawn_cartridges)
|
||||
for(var/type in spawn_cartridges)
|
||||
add_cartridge(new type(src))
|
||||
|
||||
examine(mob/user)
|
||||
..()
|
||||
user << "It has [cartridges.len] cartridges installed, and has space for [DISPENSER_MAX_CARTRIDGES - cartridges.len] more."
|
||||
|
||||
proc/add_cartridge(obj/item/weapon/reagent_containers/chem_disp_cartridge/C, mob/user)
|
||||
if(!istype(C))
|
||||
if(user)
|
||||
user << "<span class='warning'>\The [C] will not fit in \the [src]!</span>"
|
||||
return
|
||||
|
||||
if(cartridges.len >= DISPENSER_MAX_CARTRIDGES)
|
||||
if(user)
|
||||
user << "<span class='warning'>\The [src] does not have any slots open for \the [C] to fit into!</span>"
|
||||
return
|
||||
|
||||
if(!C.label)
|
||||
if(user)
|
||||
user << "<span class='warning'>\The [C] does not have a label!</span>"
|
||||
return
|
||||
|
||||
if(cartridges[C.label])
|
||||
if(user)
|
||||
user << "<span class='warning'>\The [src] already contains a cartridge with that label!</span>"
|
||||
return
|
||||
/obj/machinery/chemical_dispenser/examine(mob/user)
|
||||
..()
|
||||
user << "It has [cartridges.len] cartridges installed, and has space for [DISPENSER_MAX_CARTRIDGES - cartridges.len] more."
|
||||
|
||||
/obj/machinery/chemical_dispenser/proc/add_cartridge(obj/item/weapon/reagent_containers/chem_disp_cartridge/C, mob/user)
|
||||
if(!istype(C))
|
||||
if(user)
|
||||
user.drop_from_inventory(C)
|
||||
user << "<span class='notice'>You add \the [C] to \the [src].</span>"
|
||||
user << "<span class='warning'>\The [C] will not fit in \the [src]!</span>"
|
||||
return
|
||||
|
||||
C.loc = src
|
||||
cartridges[C.label] = C
|
||||
cartridges = sortAssoc(cartridges)
|
||||
nanomanager.update_uis(src)
|
||||
if(cartridges.len >= DISPENSER_MAX_CARTRIDGES)
|
||||
if(user)
|
||||
user << "<span class='warning'>\The [src] does not have any slots open for \the [C] to fit into!</span>"
|
||||
return
|
||||
|
||||
proc/remove_cartridge(label)
|
||||
. = cartridges[label]
|
||||
cartridges -= label
|
||||
nanomanager.update_uis(src)
|
||||
if(!C.label)
|
||||
if(user)
|
||||
user << "<span class='warning'>\The [C] does not have a label!</span>"
|
||||
return
|
||||
|
||||
attackby(obj/item/weapon/W, mob/user)
|
||||
if(istype(W, /obj/item/weapon/wrench))
|
||||
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
|
||||
user << "<span class='notice'>You begin to [anchored ? "un" : ""]fasten \the [src].</span>"
|
||||
if (do_after(user, 20))
|
||||
user.visible_message(
|
||||
"<span class='notice'>\The [user] [anchored ? "un" : ""]fastens \the [src].</span>",
|
||||
"<span class='notice'>You have [anchored ? "un" : ""]fastened \the [src].</span>",
|
||||
"You hear a ratchet.")
|
||||
anchored = !anchored
|
||||
else
|
||||
user << "<span class='notice'>You decide not to [anchored ? "un" : ""]fasten \the [src].</span>"
|
||||
if(cartridges[C.label])
|
||||
if(user)
|
||||
user << "<span class='warning'>\The [src] already contains a cartridge with that label!</span>"
|
||||
return
|
||||
|
||||
else if(istype(W, /obj/item/weapon/reagent_containers/chem_disp_cartridge))
|
||||
add_cartridge(W, user)
|
||||
if(user)
|
||||
user.drop_from_inventory(C)
|
||||
user << "<span class='notice'>You add \the [C] to \the [src].</span>"
|
||||
|
||||
else if(istype(W, /obj/item/weapon/screwdriver))
|
||||
var/label = input(user, "Which cartridge would you like to remove?", "Chemical Dispenser") as null|anything in cartridges
|
||||
if(!label) return
|
||||
var/obj/item/weapon/reagent_containers/chem_disp_cartridge/C = remove_cartridge(label)
|
||||
if(C)
|
||||
user << "<span class='notice'>You remove \the [C] from \the [src].</span>"
|
||||
C.loc = loc
|
||||
C.loc = src
|
||||
cartridges[C.label] = C
|
||||
cartridges = sortAssoc(cartridges)
|
||||
nanomanager.update_uis(src)
|
||||
|
||||
else if(istype(W, /obj/item/weapon/reagent_containers/glass) || istype(W, /obj/item/weapon/reagent_containers/food))
|
||||
var/obj/item/weapon/reagent_containers/RC = W
|
||||
|
||||
if(!accept_drinking && istype(RC,/obj/item/weapon/reagent_containers/food))
|
||||
user << "<span class='warning'>This machine only accepts beakers!</span>"
|
||||
return
|
||||
|
||||
if(!RC.is_open_container())
|
||||
user << "<span class='warning'>You don't see how \the [src] could dispense reagents into \the [RC].</span>"
|
||||
return
|
||||
|
||||
container = RC
|
||||
user.drop_from_inventory(RC)
|
||||
RC.loc = src
|
||||
user << "<span class='notice'>You set \the [RC] on \the [src].</span>"
|
||||
nanomanager.update_uis(src) // update all UIs attached to src
|
||||
/obj/machinery/chemical_dispenser/proc/remove_cartridge(label)
|
||||
. = cartridges[label]
|
||||
cartridges -= label
|
||||
nanomanager.update_uis(src)
|
||||
|
||||
/obj/machinery/chemical_dispenser/attackby(obj/item/weapon/W, mob/user)
|
||||
if(istype(W, /obj/item/weapon/wrench))
|
||||
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
|
||||
user << "<span class='notice'>You begin to [anchored ? "un" : ""]fasten \the [src].</span>"
|
||||
if (do_after(user, 20))
|
||||
user.visible_message(
|
||||
"<span class='notice'>\The [user] [anchored ? "un" : ""]fastens \the [src].</span>",
|
||||
"<span class='notice'>You have [anchored ? "un" : ""]fastened \the [src].</span>",
|
||||
"You hear a ratchet.")
|
||||
anchored = !anchored
|
||||
else
|
||||
return ..()
|
||||
user << "<span class='notice'>You decide not to [anchored ? "un" : ""]fasten \the [src].</span>"
|
||||
|
||||
ui_interact(mob/user, ui_key = "main",var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if(stat & (BROKEN|NOPOWER)) return
|
||||
if(user.stat || user.restrained()) return
|
||||
else if(istype(W, /obj/item/weapon/reagent_containers/chem_disp_cartridge))
|
||||
add_cartridge(W, user)
|
||||
|
||||
// this is the data which will be sent to the ui
|
||||
var/data[0]
|
||||
data["amount"] = amount
|
||||
data["isBeakerLoaded"] = container ? 1 : 0
|
||||
data["glass"] = accept_drinking
|
||||
var beakerD[0]
|
||||
if(container && container.reagents && container.reagents.reagent_list.len)
|
||||
for(var/datum/reagent/R in container.reagents.reagent_list)
|
||||
beakerD[++beakerD.len] = list("name" = R.name, "volume" = R.volume)
|
||||
data["beakerContents"] = beakerD
|
||||
else if(istype(W, /obj/item/weapon/screwdriver))
|
||||
var/label = input(user, "Which cartridge would you like to remove?", "Chemical Dispenser") as null|anything in cartridges
|
||||
if(!label) return
|
||||
var/obj/item/weapon/reagent_containers/chem_disp_cartridge/C = remove_cartridge(label)
|
||||
if(C)
|
||||
user << "<span class='notice'>You remove \the [C] from \the [src].</span>"
|
||||
C.loc = loc
|
||||
|
||||
if(container)
|
||||
data["beakerCurrentVolume"] = container.reagents.total_volume
|
||||
data["beakerMaxVolume"] = container.reagents.maximum_volume
|
||||
else
|
||||
data["beakerCurrentVolume"] = null
|
||||
data["beakerMaxVolume"] = null
|
||||
else if(istype(W, /obj/item/weapon/reagent_containers/glass) || istype(W, /obj/item/weapon/reagent_containers/food))
|
||||
var/obj/item/weapon/reagent_containers/RC = W
|
||||
|
||||
var chemicals[0]
|
||||
for(var/label in cartridges)
|
||||
var/obj/item/weapon/reagent_containers/chem_disp_cartridge/C = cartridges[label]
|
||||
chemicals[++chemicals.len] = list("label" = label, "amount" = C.reagents.total_volume)
|
||||
data["chemicals"] = chemicals
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "chem_disp.tmpl", ui_title, 390, 680)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
|
||||
Topic(href, href_list)
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return 0 // don't update UIs attached to this object
|
||||
|
||||
if(href_list["amount"])
|
||||
amount = round(text2num(href_list["amount"]), 1) // round to nearest 1
|
||||
amount = max(0, min(120, amount)) // Since the user can actually type the commands himself, some sanity checking
|
||||
|
||||
else if(href_list["dispense"])
|
||||
var/label = href_list["dispense"]
|
||||
if(cartridges[label] && container && container.is_open_container())
|
||||
var/obj/item/weapon/reagent_containers/chem_disp_cartridge/C = cartridges[label]
|
||||
C.reagents.trans_to(container, amount)
|
||||
|
||||
else if(href_list["ejectBeaker"])
|
||||
if(container)
|
||||
var/obj/item/weapon/reagent_containers/B = container
|
||||
B.loc = loc
|
||||
container = null
|
||||
|
||||
add_fingerprint(usr)
|
||||
return 1 // update UIs attached to this object
|
||||
|
||||
attack_ai(mob/user as mob)
|
||||
src.attack_hand(user)
|
||||
|
||||
attack_hand(mob/user as mob)
|
||||
if(stat & BROKEN)
|
||||
if(!accept_drinking && istype(RC,/obj/item/weapon/reagent_containers/food))
|
||||
user << "<span class='warning'>This machine only accepts beakers!</span>"
|
||||
return
|
||||
ui_interact(user)
|
||||
|
||||
if(!RC.is_open_container())
|
||||
user << "<span class='warning'>You don't see how \the [src] could dispense reagents into \the [RC].</span>"
|
||||
return
|
||||
|
||||
container = RC
|
||||
user.drop_from_inventory(RC)
|
||||
RC.loc = src
|
||||
user << "<span class='notice'>You set \the [RC] on \the [src].</span>"
|
||||
nanomanager.update_uis(src) // update all UIs attached to src
|
||||
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/machinery/chemical_dispenser/ui_interact(mob/user, ui_key = "main",var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if(stat & (BROKEN|NOPOWER)) return
|
||||
if(user.stat || user.restrained()) return
|
||||
|
||||
// this is the data which will be sent to the ui
|
||||
var/data[0]
|
||||
data["amount"] = amount
|
||||
data["isBeakerLoaded"] = container ? 1 : 0
|
||||
data["glass"] = accept_drinking
|
||||
var beakerD[0]
|
||||
if(container && container.reagents && container.reagents.reagent_list.len)
|
||||
for(var/datum/reagent/R in container.reagents.reagent_list)
|
||||
beakerD[++beakerD.len] = list("name" = R.name, "volume" = R.volume)
|
||||
data["beakerContents"] = beakerD
|
||||
|
||||
if(container)
|
||||
data["beakerCurrentVolume"] = container.reagents.total_volume
|
||||
data["beakerMaxVolume"] = container.reagents.maximum_volume
|
||||
else
|
||||
data["beakerCurrentVolume"] = null
|
||||
data["beakerMaxVolume"] = null
|
||||
|
||||
var chemicals[0]
|
||||
for(var/label in cartridges)
|
||||
var/obj/item/weapon/reagent_containers/chem_disp_cartridge/C = cartridges[label]
|
||||
chemicals[++chemicals.len] = list("label" = label, "amount" = C.reagents.total_volume)
|
||||
data["chemicals"] = chemicals
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "chem_disp.tmpl", ui_title, 390, 680)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/chemical_dispenser/Topic(href, href_list)
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return 0 // don't update UIs attached to this object
|
||||
|
||||
if(href_list["amount"])
|
||||
amount = round(text2num(href_list["amount"]), 1) // round to nearest 1
|
||||
amount = max(0, min(120, amount)) // Since the user can actually type the commands himself, some sanity checking
|
||||
|
||||
else if(href_list["dispense"])
|
||||
var/label = href_list["dispense"]
|
||||
if(cartridges[label] && container && container.is_open_container())
|
||||
var/obj/item/weapon/reagent_containers/chem_disp_cartridge/C = cartridges[label]
|
||||
C.reagents.trans_to(container, amount)
|
||||
|
||||
else if(href_list["ejectBeaker"])
|
||||
if(container)
|
||||
var/obj/item/weapon/reagent_containers/B = container
|
||||
B.loc = loc
|
||||
container = null
|
||||
|
||||
add_fingerprint(usr)
|
||||
return 1 // update UIs attached to this object
|
||||
|
||||
/obj/machinery/chemical_dispenser/attack_ai(mob/user as mob)
|
||||
src.attack_hand(user)
|
||||
|
||||
/obj/machinery/chemical_dispenser/attack_hand(mob/user as mob)
|
||||
if(stat & BROKEN)
|
||||
return
|
||||
ui_interact(user)
|
||||
Reference in New Issue
Block a user