move power message generation to a cable proc and calls it from the multitool_act and examine procs (#29037)

This commit is contained in:
Migratingcocofruit
2025-04-20 21:11:52 +00:00
committed by GitHub
parent 570418e152
commit ce8b8d1057
+12 -4
View File
@@ -119,12 +119,20 @@ By design, d1 is the smallest direction and d2 is the highest
return
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
if(powernet && (powernet.available_power > 0)) // is it powered?
to_chat(user, chat_box_examine("<span class='notice'>Total power: [DisplayPower(powernet.available_power)]\nLoad: [DisplayPower(powernet.power_demand)]\nExcess power: [DisplayPower(get_surplus())]</span>"))
else
to_chat(user, "<span class='warning'>The cable is not powered.</span>")
to_chat(user, generate_power_message())
shock(user, 5, 0.2)
/obj/structure/cable/proc/generate_power_message()
if(powernet && (powernet.available_power > 0))
return chat_box_examine("<span class='notice'>Total power: [DisplayPower(powernet.available_power)]\nLoad: [DisplayPower(powernet.power_demand)]\nExcess power: [DisplayPower(get_surplus())]</span>")
else
return "<span class='warning'>The cable is not powered.</span>"
/obj/structure/cable/examine(mob/user)
. = ..()
if(isobserver(user))
. += generate_power_message()
/obj/structure/cable/wirecutter_act(mob/user, obj/item/I)
. = TRUE
var/turf/T = get_turf(src)