<commit_before>
// Light Replacer (LR)
//
// ABOUT THE DEVICE
//
// This is a device supposedly to be used by Janitors and Janitor Cyborgs which will
// allow them to easily replace lights. This was mostly designed for Janitor Cyborgs since
// they don't have hands or a way to replace lightbulbs.
//
// HOW IT WORKS
//
// You attack a light fixture with it, if the light fixture is broken it will replace the
// light fixture with a working light; the broken light is then placed on the floor for the
// user to then pickup with a trash bag. If it's empty then it will just place a light in the fixture.
//
// HOW TO REFILL THE DEVICE
//
// It will need to be manually refilled with lights.
// If it's part of a robot module, it will charge when the Robot is inside a Recharge Station.
//
// EMAGGED FEATURES
//
// NOTICE: The Cyborg cannot use the emagged Light Replacer and the light's explosion was nerfed. It cannot create holes in the station anymore.
//
// I'm not sure everyone will react the emag's features so please say what your opinions are of it.
//
// When emagged it will rig every light it replaces, which will explode when the light is on.
// This is VERY noticable, even the device's name changes when you emag it so if anyone
// examines you when you're holding it in your hand, you will be discovered.
// It will also be very obvious who is setting all these lights off, since only Janitor Borgs and Janitors have easy
// access to them, and only one of them can emag their device.
//
// The explosion cannot insta-kill anyone with 30% or more health.

#define LIGHT_OK 0
#define LIGHT_EMPTY 1
#define LIGHT_BROKEN 2
#define LIGHT_BURNED 3


/obj/item/device/lightreplacer

	name = "light replacer"
	desc = "A device to automatically replace lights. Refill with working lightbulbs."

	icon = 'icons/obj/janitor.dmi'
	icon_state = "lightreplacer0"
	item_state = "electronic"

	flags = CONDUCT
	slot_flags = SLOT_BELT
	origin_tech = "magnets=3;materials=2"

	var/max_uses = 20
	var/uses = 0
	var/emagged = 0
	var/failmsg = ""
	// How much to increase per each glass?
	var/increment = 5
	// How much to take from the glass?
	var/decrement = 1
	var/charge = 1

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

/obj/item/device/lightreplacer/examine(mob/user)
	..()
	user << "It has [uses] light\s remaining."

/obj/item/device/lightreplacer/attackby(obj/item/W, mob/user, params)

	if(istype(W, /obj/item/stack/sheet/glass))
		var/obj/item/stack/sheet/glass/G = W
		if(uses >= max_uses)
			user << "<span class='warning'>[src.name] is full.</span>"
			return
		else if(G.use(decrement))
			AddUses(increment)
			user << "<span class='notice'>You insert a piece of glass into the [src.name]. You have [uses] lights remaining.</span>"
			return
		else
			user << "<span class='warning'>You need one sheet of glass to replace lights!</span>"

	if(istype(W, /obj/item/weapon/light))
		var/obj/item/weapon/light/L = W
		if(L.status == 0) // LIGHT OKAY
			if(uses < max_uses)
				if(!user.unEquip(W))
					return
				AddUses(1)
				user << "<span class='notice'>You insert the [L.name] into the [src.name]. You have [uses] lights remaining.</span>"
				qdel(L)
				return
		else
			user << "<span class='warning'>You need a working light!</span>"
			return

	if(istype(W, /obj/item/weapon/storage/box/lights))
		var/obj/item/weapon/storage/box/lights/B = W
		if(!B.contents.len)
			user << "<span class='warning'>The [B.name] is empty!</span>"
		else if(uses == max_uses)
			user << "<span class='warning'>The [src.name] is full!</span>"
		else
			B.close_all()
			while(src.uses < max_uses && B.contents.len > 0)
				B.contents.Cut(1,2)
				AddUses(1)
			user << "<span class='notice'>You fill the [src.name] with lights from the [B.name]. You have [uses] lights remaining.</span>"
		return

/obj/item/device/lightreplacer/emag_act()
	if(!emagged)
		Emag()
<commit_msg>replacing broken lights with broken lights since 1999<commit_after>
// Light Replacer (LR)
//
// ABOUT THE DEVICE
//
// This is a device supposedly to be used by Janitors and Janitor Cyborgs which will
// allow them to easily replace lights. This was mostly designed for Janitor Cyborgs since
// they don't have hands or a way to replace lightbulbs.
//
// HOW IT WORKS
//
// You attack a light fixture with it, if the light fixture is broken it will replace the
// light fixture with a working light; the broken light is then placed on the floor for the
// user to then pickup with a trash bag. If it's empty then it will just place a light in the fixture.
//
// HOW TO REFILL THE DEVICE
//
// It will need to be manually refilled with lights.
// If it's part of a robot module, it will charge when the Robot is inside a Recharge Station.
//
// EMAGGED FEATURES
//
// NOTICE: The Cyborg cannot use the emagged Light Replacer and the light's explosion was nerfed. It cannot create holes in the station anymore.
//
// I'm not sure everyone will react the emag's features so please say what your opinions are of it.
//
// When emagged it will rig every light it replaces, which will explode when the light is on.
// This is VERY noticable, even the device's name changes when you emag it so if anyone
// examines you when you're holding it in your hand, you will be discovered.
// It will also be very obvious who is setting all these lights off, since only Janitor Borgs and Janitors have easy
// access to them, and only one of them can emag their device.
//
// The explosion cannot insta-kill anyone with 30% or more health.

#define LIGHT_OK 0
#define LIGHT_EMPTY 1
#define LIGHT_BROKEN 2
#define LIGHT_BURNED 3


/obj/item/device/lightreplacer

	name = "light replacer"
	desc = "A device to automatically replace lights. Refill with working lightbulbs."

	icon = 'icons/obj/janitor.dmi'
	icon_state = "lightreplacer0"
	item_state = "electronic"

	flags = CONDUCT
	slot_flags = SLOT_BELT
	origin_tech = "magnets=3;materials=2"

	var/max_uses = 20
	var/uses = 0
	var/emagged = 0
	var/failmsg = ""
	// How much to increase per each glass?
	var/increment = 5
	// How much to take from the glass?
	var/decrement = 1
	var/charge = 1

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

/obj/item/device/lightreplacer/examine(mob/user)
	..()
	user << "It has [uses] light\s remaining."

/obj/item/device/lightreplacer/attackby(obj/item/W, mob/user, params)

	if(istype(W, /obj/item/stack/sheet/glass))
		var/obj/item/stack/sheet/glass/G = W
		if(uses >= max_uses)
			user << "<span class='warning'>[src.name] is full.</span>"
			return
		else if(G.use(decrement))
			AddUses(increment)
			user << "<span class='notice'>You insert a piece of glass into the [src.name]. You have [uses] lights remaining.</span>"
			return
		else
			user << "<span class='warning'>You need one sheet of glass to replace lights!</span>"

	if(istype(W, /obj/item/weapon/light))
		var/obj/item/weapon/light/L = W
		if(L.status == 0) // LIGHT OKAY
			if(uses < max_uses)
				if(!user.unEquip(W))
					return
				AddUses(1)
				user << "<span class='notice'>You insert the [L.name] into the [src.name]. You have [uses] lights remaining.</span>"
				qdel(L)
				return
		else
			user << "<span class='warning'>You need a working light!</span>"
			return

	if(istype(W, /obj/item/weapon/storage/box/lights))
		var/obj/item/weapon/storage/box/lights/B = W
		var/tmp/useable_lights = 0
		for(var/obj/item/weapon/light/L in B.contents)
			if(L.status == 0) // If the light is not broken or burned out
				useable_lights = 1
				break
		if(!useable_lights) // This check necessitates the loop above, as I figure it to be useful to know the box has no useable lights first.
			user << "<span class='warning'>The [B.name] contains no useable lights!</span>"
		else if(uses == max_uses)
			user << "<span class='warning'>The [src.name] is full!</span>"
		else
			B.close_all()
			for(var/obj/item/weapon/light/L in B.contents)
				if(L.status == 0) // Don't want to allow broken or burnt out lights to be useable
					if(src.uses < max_uses)
						qdel(L)
						AddUses(1)
					else
						break
			user << "<span class='notice'>You fill the [src.name] with lights from the [B.name]. You have [uses] lights remaining.</span>"
		return

/obj/item/device/lightreplacer/emag_act()
	if(!emagged)
		Emag()

{'fraction_non_alphanumeric': 0.11572912934432103, 'fraction_numerical': 0.006091006807595844, 'mean_word_length': 3.341109383100052, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1782661', 'n_tokens_mistral': 3006, 'n_tokens_neox': 2728, 'n_words': 1043}