Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes the Light Replacer more easily attainable + Allows broken light recycling #7381

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions code/game/machinery/autolathe_datums.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
path = /obj/item/tool/wrench
category = AUTOLATHE_CATEGORY_TOOLS

/datum/autolathe/recipe/lightreplacer
name = "light replacer"
path = /obj/item/device/lightreplacer/empty
category = AUTOLATHE_CATEGORY_TOOLS

/datum/autolathe/recipe/mop
name = "mop"
path = /obj/item/tool/mop
Expand Down
4 changes: 3 additions & 1 deletion code/game/machinery/vending/vendor_types/engineering.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
list("ME3 Hand Welder", floor(scale * 2), /obj/item/tool/weldingtool/simple, VENDOR_ITEM_REGULAR),
list("Screwdriver", floor(scale * 4), /obj/item/tool/screwdriver, VENDOR_ITEM_REGULAR),
list("Wirecutters", floor(scale * 4), /obj/item/tool/wirecutters, VENDOR_ITEM_REGULAR),
list("Wrench", floor(scale * 4), /obj/item/tool/wrench, VENDOR_ITEM_REGULAR)
list("Wrench", floor(scale * 4), /obj/item/tool/wrench, VENDOR_ITEM_REGULAR),
list("Light Replacer", floor(scale * 4), /obj/item/device/lightreplacer, VENDOR_ITEM_REGULAR)
)

/obj/structure/machinery/cm_vending/sorted/tech/comtech_tools
Expand All @@ -65,6 +66,7 @@
list("Wrench", floor(scale * 4), /obj/item/tool/wrench, VENDOR_ITEM_REGULAR),
list("Multitool", floor(scale * 4), /obj/item/device/multitool, VENDOR_ITEM_REGULAR),
list("ME3 Hand Welder", floor(scale * 2), /obj/item/tool/weldingtool/simple, VENDOR_ITEM_REGULAR),
list("Light Replacer", floor(scale * 4), /obj/item/device/lightreplacer, VENDOR_ITEM_REGULAR),

list("UTILITY", -1, null, null),
list("Sentry Gun Network Laptop", 4, /obj/item/device/sentry_computer, VENDOR_ITEM_REGULAR),
Expand Down
53 changes: 35 additions & 18 deletions code/game/objects/items/devices/lightreplacer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
/obj/item/device/lightreplacer

name = "light replacer"
desc = "A device to automatically replace lights. Refill with working lightbulbs."
desc = "A device to automatically replace lights. Can be refill with working lightbulbs and sheets of glass, and can recycle broken lightbulbs."

icon = 'icons/obj/janitor.dmi'
icon_state = "lightreplacer0"
Expand All @@ -50,20 +50,28 @@
flags_atom = FPRINT|CONDUCT
flags_equip_slot = SLOT_WAIST

matter = list("metal" = 20,"glass" = 50)

var/max_uses = 50
var/uses = 0
var/failmsg = ""
var/charge = 1
var/recycle = 0
var/max_recycle = 3

/obj/item/device/lightreplacer/Initialize()
. = ..()
uses = max_uses
failmsg = "The [name]'s refill light blinks red."

/obj/item/device/lightreplacer/empty/Initialize()
. = ..()
uses = 0
failmsg = "The [name]'s refill light blinks red."

/obj/item/device/lightreplacer/get_examine_text(mob/user)
. = ..()
. += "It has [uses] lights remaining."
. += "It has [uses] lights remaining, and [recycle] broken lights stored."

/obj/item/device/lightreplacer/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/stack/sheet/glass))
Expand All @@ -83,31 +91,34 @@
if(L.status == 0) // LIGHT OKAY
if(uses < max_uses)
AddUses(1)
to_chat(user, "You insert the [L.name] into the [src.name]. You have [uses] lights remaining.")
to_chat(user, SPAN_NOTICE("You insert the [L.name] into the [src.name]. You have [uses] lights remaining."))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
to_chat(user, SPAN_NOTICE("You insert the [L.name] into the [src.name]. You have [uses] lights remaining."))
to_chat(user, SPAN_NOTICE("You insert [L] into [src]. You have [uses] lights remaining."))

user.drop_held_item()
qdel(L)
return
else
to_chat(user, "You need a working light.")
Recycle()
to_chat(user, SPAN_NOTICE("You insert the [L.name] into the [src.name] for recycling."))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
to_chat(user, SPAN_NOTICE("You insert the [L.name] into the [src.name] for recycling."))
to_chat(user, SPAN_NOTICE("You insert [L] into [src] for recycling."))

user.drop_held_item()
qdel(L)
return


/obj/item/device/lightreplacer/attack_self(mob/user)
..()
to_chat(usr, "It has [uses] lights remaining.")
to_chat(usr, "It has [uses] lights remaining, and has [recycle] broken lights stored.")

/obj/item/device/lightreplacer/update_icon()
icon_state = "lightreplacer0"


/obj/item/device/lightreplacer/proc/Use(mob/user)

playsound(src.loc, 'sound/machines/click.ogg', 25, 1)
AddUses(-1)
return 1

// Negative numbers will subtract
/obj/item/device/lightreplacer/proc/AddUses(amount = 1)
playsound(src.loc, 'sound/machines/click.ogg', 25, 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
playsound(src.loc, 'sound/machines/click.ogg', 25, 1)
playsound(src, 'sound/machines/click.ogg', 25, 1)

uses = min(max(uses + amount, 0), max_uses)

/obj/item/device/lightreplacer/proc/Charge(mob/user)
Expand All @@ -116,6 +127,17 @@
AddUses(1)
charge = 1

/obj/item/device/lightreplacer/proc/Recycle(mob/living/U)
if(recycle == max_recycle)
recycle = 0
AddUses(1)
playsound(src.loc, 'sound/machines/ding.ogg', 5, 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
playsound(src.loc, 'sound/machines/ding.ogg', 5, 1)
playsound(src, 'sound/machines/ding.ogg', 5, 1)

return
else
playsound(src.loc, 'sound/machines/click.ogg', 25, 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
playsound(src.loc, 'sound/machines/click.ogg', 25, 1)
playsound(src, 'sound/machines/click.ogg', 25, 1)

recycle += 1
return
Comment on lines +136 to +139
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
else
playsound(src.loc, 'sound/machines/click.ogg', 25, 1)
recycle += 1
return
playsound(src.loc, 'sound/machines/click.ogg', 25, 1)
recycle += 1

the else clause is redundant as the previous condition returns


/obj/item/device/lightreplacer/proc/ReplaceLight(obj/structure/machinery/light/target, mob/living/U)

if(target.status != LIGHT_OK)
Expand All @@ -125,26 +147,21 @@

if(target.status != LIGHT_EMPTY)

var/obj/item/light_bulb/L1 = new target.light_type(target.loc)
L1.status = target.status
L1.rigged = target.rigged
L1.brightness = target.brightness
L1.switchcount = target.switchcount
target.switchcount = 0
L1.update()

target.status = LIGHT_EMPTY
target.update()

var/obj/item/light_bulb/L2 = new target.light_type()
Recycle()

var/obj/item/light_bulb/bulb = new target.light_type()

target.status = L2.status
target.switchcount = L2.switchcount
target.status = bulb.status
target.switchcount = bulb.switchcount
target.rigged = FALSE
target.brightness = L2.brightness
target.brightness = bulb.brightness
target.on = target.has_power()
target.update()
qdel(L2)
qdel(bulb)

if(target.on && target.rigged)
target.explode()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/power/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@

/obj/item/light_bulb/proc/shatter()
if(status == LIGHT_OK || status == LIGHT_BURNED)
src.visible_message(SPAN_DANGER("[name] shatters."),SPAN_DANGER("You hear a small glass object shatter."))
src.visible_message(SPAN_DANGER("The [name] shatters."),SPAN_DANGER("You hear a small glass object shatter."))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
src.visible_message(SPAN_DANGER("The [name] shatters."),SPAN_DANGER("You hear a small glass object shatter."))
visible_message(SPAN_DANGER("[src] shatters."), SPAN_DANGER("You hear a small glass object shatter."))

status = LIGHT_BROKEN
force = 5
sharp = IS_SHARP_ITEM_SIMPLE
Expand Down
Loading