diff --git a/code/_onclick/hud/robot.dm b/code/_onclick/hud/robot.dm
index fc0b407550d..51dc22df59e 100644
--- a/code/_onclick/hud/robot.dm
+++ b/code/_onclick/hud/robot.dm
@@ -60,7 +60,6 @@
/obj/screen/robot/lamp/Click()
var/mob/living/silicon/robot/R = usr
R.control_headlamp()
- icon_state = "lamp[R.lamp_intensity]"
/datum/hud/proc/robot_hud()
@@ -115,6 +114,7 @@
using = new /obj/screen/robot/lamp()
using.screen_loc = ui_borg_lamp
adding += using
+ mymobR.lamp_button = using
//Intent
using = new /obj/screen/act_intent()
diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm
index 957d2668b6d..0fca94e2b05 100644
--- a/code/modules/mob/living/silicon/robot/robot.dm
+++ b/code/modules/mob/living/silicon/robot/robot.dm
@@ -15,6 +15,7 @@
var/obj/screen/inv1 = null
var/obj/screen/inv2 = null
var/obj/screen/inv3 = null
+ var/obj/screen/lamp_button = null
var/shown_robot_modules = 0 //Used to determine whether they have the module menu shown or not
var/obj/screen/robot_modules_background
@@ -992,13 +993,9 @@
src << "This function is currently offline."
return
- if(lamp_intensity < lamp_max) //Lamp is set lower than the max.
- lamp_intensity += 2
- src << "Headlamp power set to Level [lamp_intensity/2]."
- else //Greater than or equal to the max, so turn it off instead.
- lamp_intensity = 0
- src << "Headlamp disabled."
-
+//Some sort of magical "modulo" thing which somehow increments lamp power by 2, until it hits the max and resets to 0.
+ lamp_intensity = (lamp_intensity+2) % (lamp_max+2)
+ src << "[lamp_intensity ? "Headlamp power set to Level [lamp_intensity/2]" : "Headlamp disabled."]"
update_headlamp()
/mob/living/silicon/robot/proc/update_headlamp(var/turn_off = 0)
@@ -1007,12 +1004,12 @@
if(lamp_intensity && (turn_off || stat))
src << "Your headlamp has been deactivated."
lamp_intensity = 0
- if(client)
- var/obj/screen/robot/lamp/button = locate(/obj/screen/robot/lamp) in client.screen
- if(button)
- button.icon_state = "lamp0"
else
AddLuminosity(lamp_intensity)
+
+ if(lamp_button)
+ lamp_button.icon_state = "lamp[lamp_intensity]"
+
update_icons()