Fix PDA flashlights not working or installing (#14336)

This commit is contained in:
Wildkins
2022-06-18 22:11:33 +02:00
committed by GitHub
parent 7104cd6229
commit c040f9dc6f
3 changed files with 17 additions and 14 deletions
@@ -72,6 +72,12 @@
to_chat(personal_ai.pai, SPAN_NOTICE("You gain access to \the [src]'s computronics."))
user.drop_from_inventory(H, src)
update_icon()
else if(istype(H, /obj/item/computer_hardware/flashlight))
if(flashlight)
to_chat(user, SPAN_WARNING("\The [src]'s flashlight slot is already occupied by \the [flashlight]."))
return
found = TRUE
flashlight = H
if(found)
to_chat(user, SPAN_NOTICE("You install \the [H] into \the [src]."))
H.parent_computer = src
@@ -186,4 +192,4 @@
all_components.Add(tesla_link)
if(flashlight)
all_components.Add(flashlight)
return all_components
return all_components
@@ -13,23 +13,14 @@
/obj/item/computer_hardware/flashlight/enable()
. = ..()
if(parent_computer)
parent_computer.light_range = range
parent_computer.light_power = power
tweak_light(parent_computer)
parent_computer.set_light(range, power, flashlight_color)
/obj/item/computer_hardware/flashlight/disable()
. = ..()
if(parent_computer)
parent_computer.light_range = initial(parent_computer.light_range)
parent_computer.light_power = initial(parent_computer.light_power)
tweak_light(parent_computer)
parent_computer.set_light(initial(parent_computer.light_range), initial(parent_computer.light_power), flashlight_color)
/obj/item/computer_hardware/flashlight/proc/tweak_brightness(var/new_power)
. = power = Clamp(0, new_power, 1)
parent_computer.light_power = power
tweak_light(parent_computer)
/obj/item/computer_hardware/flashlight/proc/tweak_light(var/obj/item/modular_computer/C)
if(!istype(C))
return
C.set_light(C.light_range, C.light_power, l_color = flashlight_color)
if(parent_computer && enabled)
parent_computer.set_light(range, power, flashlight_color)