From 3a8136e80730610587936184ff874e2bf381c988 Mon Sep 17 00:00:00 2001 From: Ren Erthilo Date: Sun, 22 Apr 2012 02:58:42 +0100 Subject: [PATCH] TG: Added the caution code, sprited by magicbones, not present anywhere on the map http://nanotrasen.com/phpBB3/viewtopic.php?f=10&t=4548&start=50#p37266 Added a power switch (/obj/structure/powerswitch), which is used to split or connect two cables. The way it works is simple. It connects the powernets by adding cable on the floor it's on and removing it when it's turned off. In-file description: //This is a power switch. When turned on it looks at the cables around the tile that it's on and notes which cables are trying to connect to it. //After it knows this it creates the number of cables from the center to each of the cables attempting to conenct. These cables cannot be removed //with wirecutters. When the switch is turned off it removes all the cables on the tile it's on. //The switch uses a 5s delay to prevent powernet change spamming. Screenshot: http://www.kamletos.si/power%20switch.PNG Revision: r3072 Author: baloh.matevz --- code/modules/power/cable.dm | 4 ++ code/modules/power/switch.dm | 84 +++++++++++++++++++++++++++++++++++ icons/obj/janitor.dmi | Bin 2728 -> 826 bytes 3 files changed, 88 insertions(+) create mode 100644 code/modules/power/switch.dm diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm index e5365fe3408..bc5e765cab7 100644 --- a/code/modules/power/cable.dm +++ b/code/modules/power/cable.dm @@ -126,6 +126,10 @@ if(istype(W, /obj/item/weapon/wirecutters)) + if(power_switch) + user << "\red This piece of cable is tied to a power switch. Flip the switch to remove it." + return + if (shock(user, 50)) return diff --git a/code/modules/power/switch.dm b/code/modules/power/switch.dm new file mode 100644 index 00000000000..9b94838dbe8 --- /dev/null +++ b/code/modules/power/switch.dm @@ -0,0 +1,84 @@ +//This is a power switch. When turned on it looks at the cables around the tile that it's on and notes which cables are trying to connect to it. +//After it knows this it creates the number of cables from the center to each of the cables attempting to conenct. These cables cannot be removed +//with wirecutters. When the switch is turned off it removes all the cables on the tile it's on. +//The switch uses a 5s delay to prevent powernet change spamming. + +/obj/structure/powerswitch + name = "power switch" + desc = "A switch that controls power." + icon = 'power.dmi' + icon_state = "switch-dbl-up" + var/icon_state_on = "switch-dbl-down" + var/icon_state_off = "switch-dbl-up" + flags = FPRINT + density = 0 + anchored = 1 + var/on = 0 //up is off, down is on + var/busy = 0 //set to 1 when you start pulling + + simple + icon_state = "switch-up" + icon_state_on = "switch-down" + icon_state_off = "switch-up" + + + examine() + ..() + if(on) + usr << "The switch is in the on position" + else + usr << "The switch is in the off position" + + attack_ai(mob/user) + user << "\red You're an AI. This is a manual switch. It's not going to work." + return + + attack_hand(mob/user) + + if(busy) + user << "\red This switch is already being toggled." + return + + ..() + + busy = 1 + for(var/mob/O in viewers(user)) + O.show_message(text("\red [user] started pulling the [src]."), 1) + + if(do_after(user, 50)) + set_state(!on) + for(var/mob/O in viewers(user)) + O.show_message(text("\red [user] flipped the [src] into the [on ? "on": "off"] position."), 1) + busy = 0 + + proc/set_state(var/state) + on = state + if(on) + icon_state = icon_state_on + var/list/connection_dirs = list() + for(var/direction in list(1,2,4,8,5,6,9,10)) + for(var/obj/structure/cable/C in get_step(src,direction)) + if(C.d1 == turn(direction, 180) || C.d2 == turn(direction, 180)) + connection_dirs += direction + break + + for(var/direction in connection_dirs) + var/obj/structure/cable/C = new/obj/structure/cable(src.loc) + C.d1 = 0 + C.d2 = direction + C.icon_state = "[C.d1]-[C.d2]" + C.power_switch = src + + var/datum/powernet/PN = new() + PN.number = powernets.len + 1 + powernets += PN + C.netnum = PN.number + PN.cables += C + + C.mergeConnectedNetworks(C.d2) + C.mergeConnectedNetworksOnTurf() + + else + icon_state = icon_state_off + for(var/obj/structure/cable/C in src.loc) + del(C) \ No newline at end of file diff --git a/icons/obj/janitor.dmi b/icons/obj/janitor.dmi index c05f6f7b73e58c113f11438a6cb29f77a8c0eea2..ef050d19e50fc8eb72f7762fb12a1f415ad727dd 100644 GIT binary patch delta 814 zcmV+}1JV4b6}kqH8Gi!+007eJf;<2K0Blf9R7JqRz<*5wvu+0enE=ed0APTC{Qm$} zb$6Nn|5Q{|h3x+T000y}a2QjTEG#Sl%>QO+X()HnJ(BcQs{bHy&j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