Made cables use color var instead of separate icons for each color.

It allows for wires of ANY color (just set cable_coil var)
and most importantly
40 837 958 b - before
39 506 651 b - after
This commit is contained in:
Chinsky
2014-01-19 03:02:58 +04:00
parent 350b8229af
commit 669ae9a1ae
14 changed files with 77 additions and 100 deletions

View File

@@ -257,48 +257,40 @@ We can't just insert in HTML into the nanoUI so we need the raw data to play wit
var/list/container = list( )
/obj/structure/cable
level = 1
anchored =1
var/datum/powernet/powernet
name = "power cable"
desc = "A flexible superconducting cable for heavy-duty power transfer"
icon = 'icons/obj/power_cond_red.dmi'
icon = 'icons/obj/power_cond_white.dmi'
icon_state = "0-1"
var/d1 = 0
var/d2 = 1
layer = 2.44 //Just below unary stuff, which is at 2.45 and above pipes, which are at 2.4
var/cable_color = "red"
var/cable_color = COLOR_RED
var/obj/structure/powerswitch/power_switch
/obj/structure/cable/yellow
cable_color = "yellow"
icon = 'icons/obj/power_cond_yellow.dmi'
cable_color = COLOR_YELLOW
/obj/structure/cable/green
cable_color = "green"
icon = 'icons/obj/power_cond_green.dmi'
cable_color = COLOR_GREEN
/obj/structure/cable/blue
cable_color = "blue"
icon = 'icons/obj/power_cond_blue.dmi'
cable_color = COLOR_BLUE
/obj/structure/cable/pink
cable_color = "pink"
icon = 'icons/obj/power_cond_pink.dmi'
cable_color = COLOR_PINK
/obj/structure/cable/orange
cable_color = "orange"
icon = 'icons/obj/power_cond_orange.dmi'
cable_color = COLOR_ORANGE
/obj/structure/cable/cyan
cable_color = "cyan"
icon = 'icons/obj/power_cond_cyan.dmi'
cable_color = COLOR_CYAN
/obj/structure/cable/white
cable_color = "white"
icon = 'icons/obj/power_cond_white.dmi'
cable_color = COLOR_WHITE
/obj/effect/projection
name = "Projection"

View File

@@ -95,32 +95,32 @@
/obj/item/weapon/handcuffs/cable
name = "cable restraints"
desc = "Looks like some cables tied together. Could be used to tie something up."
icon_state = "cuff_red"
icon_state = "cuff_white"
breakouttime = 300 //Deciseconds = 30s
/obj/item/weapon/handcuffs/cable/red
icon_state = "cuff_red"
color = "#DD0000"
/obj/item/weapon/handcuffs/cable/yellow
icon_state = "cuff_yellow"
color = "#DDDD00"
/obj/item/weapon/handcuffs/cable/blue
icon_state = "cuff_blue"
color = "#0000DD"
/obj/item/weapon/handcuffs/cable/green
icon_state = "cuff_green"
color = "#00DD00"
/obj/item/weapon/handcuffs/cable/pink
icon_state = "cuff_pink"
color = "#DD00DD"
/obj/item/weapon/handcuffs/cable/orange
icon_state = "cuff_orange"
color = "#DD8800"
/obj/item/weapon/handcuffs/cable/cyan
icon_state = "cuff_cyan"
color = "#00DDDD"
/obj/item/weapon/handcuffs/cable/white
icon_state = "cuff_white"
color = "#FFFFFF"
/obj/item/weapon/handcuffs/cyborg
dispenser = 1

View File

@@ -57,10 +57,8 @@
updateicon()
/obj/structure/cable/proc/updateicon()
if(invisibility)
icon_state = "[d1]-[d2]-f"
else
icon_state = "[d1]-[d2]"
icon_state = "[d1]-[d2]"
alpha = invisibility ? 127 : 255
// returns the powernet this cable belongs to
@@ -91,7 +89,7 @@
new/obj/item/weapon/cable_coil(T, 1, cable_color)
for(var/mob/O in viewers(src, null))
O.show_message("\red [user] cuts the cable.", 1)
O.show_message("<span class='warning'>[user] cuts the cable.</span>", 1)
del(src)
@@ -107,10 +105,10 @@
var/datum/powernet/PN = get_powernet() // find the powernet
if(PN && (PN.avail > 0)) // is it powered?
user << "\red [PN.avail]W in power network."
user << "<span class='warning'>[PN.avail]W in power network.</span>"
else
user << "\red The cable is not powered."
user << "<span class='warning'>The cable is not powered.</span>"
shock(user, 5, 0.2)
@@ -154,9 +152,9 @@
/obj/item/weapon/cable_coil
name = "cable coil"
icon = 'icons/obj/power.dmi'
icon_state = "coil_red"
icon_state = "coil"
var/amount = MAXCOIL
item_color = "red"
item_color = COLOR_RED
desc = "A coil of power cable."
throwforce = 10
w_class = 2.0
@@ -166,11 +164,11 @@
g_amt = 20
flags = TABLEPASS | FPRINT | CONDUCT
slot_flags = SLOT_BELT
item_state = "coil_red"
item_state = "coil"
attack_verb = list("whipped", "lashed", "disciplined", "flogged")
suicide_act(mob/user)
viewers(user) << "\red <b>[user] is strangling \himself with the [src.name]! It looks like \he's trying to commit suicide.</b>"
viewers(user) << "<span class='warning'><b>[user] is strangling \himself with the [src.name]! It looks like \he's trying to commit suicide.</b></span>"
return(OXYLOSS)
@@ -185,15 +183,16 @@
/obj/item/weapon/cable_coil/proc/updateicon()
if (!item_color)
item_color = pick("red", "yellow", "blue", "green")
item_color = pick(COLOR_RED, COLOR_BLUE, COLOR_GREEN, COLOR_ORANGE, COLOR_WHITE, COLOR_PINK, COLOR_YELLOW, COLOR_CYAN)
color = item_color
if(amount == 1)
icon_state = "coil_[item_color]1"
icon_state = "coil1"
name = "cable piece"
else if(amount == 2)
icon_state = "coil_[item_color]2"
icon_state = "coil2"
name = "cable piece"
else
icon_state = "coil_[item_color]"
icon_state = "coil"
name = "cable coil"
/obj/item/weapon/cable_coil/examine()
@@ -214,14 +213,14 @@
if(ishuman(M) && !M.restrained() && !M.stat && !M.paralysis && ! M.stunned)
if(!istype(usr.loc,/turf)) return
if(src.amount <= 14)
usr << "\red You need at least 15 lengths to make restraints!"
usr << "<span class='warning'>You need at least 15 lengths to make restraints!</span>"
return
var/obj/item/weapon/handcuffs/cable/B = new /obj/item/weapon/handcuffs/cable(usr.loc)
B.icon_state = "cuff_[item_color]"
usr << "\blue You wind some cable together to make some restraints."
B.color = item_color
usr << "<span class='notice'>You wind some cable together to make some restraints.</span>"
src.use(15)
else
usr << "\blue You cannot do that."
usr << "<span class='notice'>\blue You cannot do that.</span>"
..()
/obj/item/weapon/cable_coil/attackby(obj/item/weapon/W, mob/user)
@@ -229,25 +228,25 @@
if( istype(W, /obj/item/weapon/wirecutters) && src.amount > 1)
src.amount--
new/obj/item/weapon/cable_coil(user.loc, 1,item_color)
user << "You cut a piece off the cable coil."
user << "<span class='notice'>You cut a piece off the cable coil.</span>"
src.updateicon()
return
else if( istype(W, /obj/item/weapon/cable_coil) )
var/obj/item/weapon/cable_coil/C = W
if(C.amount == MAXCOIL)
user << "The coil is too long, you cannot add any more cable to it."
user << "<span class='notice'>The coil is too long, you cannot add any more cable to it.</span>"
return
if( (C.amount + src.amount <= MAXCOIL) )
C.amount += src.amount
user << "You join the cable coils together."
user << "<span class='notice'>You join the cable coils together.</span>"
C.updateicon()
del(src)
return
else
user << "You transfer [MAXCOIL - src.amount ] length\s of cable from one coil to the other."
user << "<span class='notice'>You transfer [MAXCOIL - src.amount ] length\s of cable from one coil to the other.</span>"
src.amount -= (MAXCOIL-C.amount)
src.updateicon()
C.amount = MAXCOIL
@@ -272,11 +271,11 @@
return
if(get_dist(F,user) > 1)
user << "You can't lay cable at a place that far away."
user << "<span class='warning'>You can't lay cable at a place that far away.</span>"
return
if(F.intact) // if floor is intact, complain
user << "You can't lay cable there unless the floor tiles are removed."
user << "<span class='warning'>You can't lay cable there unless the floor tiles are removed.</span>"
return
else
@@ -289,7 +288,7 @@
for(var/obj/structure/cable/LC in F)
if((LC.d1 == dirn && LC.d2 == 0 ) || ( LC.d2 == dirn && LC.d1 == 0))
user << "There's already a cable at that position."
user << "<span class='warning'>There's already a cable at that position.</span>"
return
var/obj/structure/cable/C = new(F)
@@ -332,7 +331,7 @@
return
if(get_dist(C, user) > 1) // make sure it's close enough
user << "You can't lay cable at a place that far away."
user << "<span class='warning'>You can't lay cable at a place that far away.</span>"
return
@@ -343,7 +342,7 @@
if(C.d1 == dirn || C.d2 == dirn) // one end of the clicked cable is pointing towards us
if(U.intact) // can't place a cable if the floor is complete
user << "You can't lay cable there unless the floor tiles are removed."
user << "<span class='warning'>You can't lay cable there unless the floor tiles are removed.</span>"
return
else
// cable is pointing at us, we're standing on an open tile
@@ -353,7 +352,7 @@
for(var/obj/structure/cable/LC in U) // check to make sure there's not a cable there already
if(LC.d1 == fdirn || LC.d2 == fdirn)
user << "There's already a cable at that position."
user << "<span class='warning'>There's already a cable at that position.</span>"
return
var/obj/structure/cable/NC = new(U)
@@ -391,7 +390,7 @@
if(LC == C) // skip the cable we're interacting with
continue
if((LC.d1 == nd1 && LC.d2 == nd2) || (LC.d1 == nd2 && LC.d2 == nd1) ) // make sure no cable matches either direction
user << "There's already a cable at that position."
user << "<span class='warning'>There's already a cable at that position.</span>"
return
@@ -484,30 +483,14 @@
obj/structure/cable/proc/cableColor(var/colorC)
var/color_n = "red"
var/color_n = "#DD0000"
if(colorC)
color_n = colorC
cable_color = color_n
switch(colorC)
if("red")
icon = 'icons/obj/power_cond_red.dmi'
if("yellow")
icon = 'icons/obj/power_cond_yellow.dmi'
if("green")
icon = 'icons/obj/power_cond_green.dmi'
if("blue")
icon = 'icons/obj/power_cond_blue.dmi'
if("pink")
icon = 'icons/obj/power_cond_pink.dmi'
if("orange")
icon = 'icons/obj/power_cond_orange.dmi'
if("cyan")
icon = 'icons/obj/power_cond_cyan.dmi'
if("white")
icon = 'icons/obj/power_cond_white.dmi'
color = color_n
/obj/item/weapon/cable_coil/cut
item_state = "coil_red2"
item_state = "coil2"
/obj/item/weapon/cable_coil/cut/New(loc)
..()
@@ -517,36 +500,28 @@ obj/structure/cable/proc/cableColor(var/colorC)
updateicon()
/obj/item/weapon/cable_coil/yellow
item_color = "yellow"
icon_state = "coil_yellow"
item_color = COLOR_YELLOW
/obj/item/weapon/cable_coil/blue
item_color = "blue"
icon_state = "coil_blue"
item_color = COLOR_BLUE
/obj/item/weapon/cable_coil/green
item_color = "green"
icon_state = "coil_green"
item_color = COLOR_GREEN
/obj/item/weapon/cable_coil/pink
item_color = "pink"
icon_state = "coil_pink"
item_color = COLOR_PINK
/obj/item/weapon/cable_coil/orange
item_color = "orange"
icon_state = "coil_orange"
item_color = COLOR_ORANGE
/obj/item/weapon/cable_coil/cyan
item_color = "cyan"
icon_state = "coil_cyan"
item_color = COLOR_CYAN
/obj/item/weapon/cable_coil/white
item_color = "white"
icon_state = "coil_white"
item_color = COLOR_WHITE
/obj/item/weapon/cable_coil/random/New()
item_color = pick("red","yellow","green","blue","pink")
icon_state = "coil_[item_color]"
item_color = pick(COLOR_RED, COLOR_BLUE, COLOR_GREEN, COLOR_WHITE, COLOR_PINK, COLOR_YELLOW, COLOR_CYAN)
..()
/obj/item/weapon/cable_coil/attack(mob/M as mob, mob/user as mob)
@@ -557,12 +532,12 @@ obj/structure/cable/proc/cableColor(var/colorC)
if(S.burn_dam > 0 && use(1))
S.heal_damage(0,15,0,1)
if(user != M)
user.visible_message("\red \The [user] repairs some burn damage on their [S.display_name] with \the [src]",\
"\red You repair some burn damage on your [S.display_name]",\
user.visible_message("<span class='notice'>\The [user] repairs some burn damage on [M]'s [S.display_name] with \the [src]</span>",\
"<span class='notice'>\The [user] repairs some burn damage on your [S.display_name]</span>",\
"You hear wires being cut.")
else
user.visible_message("\red \The [user] repairs some burn damage on their [S.display_name] with \the [src]",\
"\red You repair some burn damage on your [S.display_name]",\
user.visible_message("<span class='notice'>\The [user] repairs some burn damage on their [S.display_name] with \the [src]</span>",\
"<span class='notice'>You repair some burn damage on your [S.display_name]</span>",\
"You hear wires being cut.")
else
user << "Nothing to fix!"

View File

@@ -747,3 +747,13 @@ var/list/RESTRICTED_CAMERA_NETWORKS = list( //Those networks can only be accesse
//Flags for zone sleeping
#define ZONE_ACTIVE 1
#define ZONE_SLEEPING 0
//some colors
#define COLOR_RED "#FF0000"
#define COLOR_GREEN "#00FF00"
#define COLOR_BLUE "#0000FF"
#define COLOR_CYAN "#00FFFF"
#define COLOR_PINK "#FF00FF"
#define COLOR_YELLOW "#FFFF00"
#define COLOR_ORANGE "#FF9900"
#define COLOR_WHITE "#FFFFFF"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB