/obj/item/stack/power_conduit
name = "power cable"
gender = NEUTER //That's a cable coil sounds better than that's some cable coils
icon = 'icons/obj/conduits/power.dmi'
icon_state = "coil_3"
amount = 50
item_color = rgb(240, 0, 0)
desc = "A coil of light power cables."
throwforce = 1
w_class = 2.0
throw_speed = 3
throw_range = 5
var/obj/conduit/power/conduit = /obj/conduit/power
var/channelsize = 1
var/channel = 3
var/list/materials = list("copper" = 2, "rubber" = 1)
flags = CONDUCT
slot_flags = SLOT_BELT
attack_verb = list("whipped", "lashed", "disciplined", "flogged")
singular_name = "cable piece"
/obj/item/stack/power_conduit/suicide_act(mob/user)
if(locate(/obj/structure/stool) in user.loc)
user.visible_message("<span class='suicide'>[user] is making a noose with the [src.name]! It looks like \he's trying to commit suicide.</span>")
else
user.visible_message("<span class='suicide'>[user] is strangling \himself with the [src.name]! It looks like \he's trying to commit suicide.</span>")
return(OXYLOSS)
/obj/item/stack/power_conduit/New(loc, amount = 50, var/param_color = null)
..()
src.amount = amount
if(param_color)
item_color = param_color
else
item_color = rgb(240, 0, 0)
pixel_x = rand(-4,4)
pixel_y = rand(-4,4)
update_icon()
/obj/item/stack/power_conduit/update_icon()
if(amount == 1)
icon_state = "coil_1"
name = "cable piece"
else if(amount == 2)
icon_state = "coil_2"
name = "cable piece"
else
icon_state = "coil_3"
name = "power cable"
color = item_color
/obj/item/stack/power_conduit/verb/next_channel()
set name = "Next Conduit Channel"
set category = "Object"
var/mob/M = usr
if(ishuman(M) && !M.restrained() && !M.stat && M.canmove)
if(!istype(usr.loc,/turf))
return
if(channel < 6)
channel += 1
else
channel = 0
usr << "<span class='notice'>You will now lay cables on channel [channel].</span>"
else
usr << "<span class='notice'>You cannot do that.</span>"
..()
// Items usable on a cable coil :
// - Wirecutters : cut them duh !
// - Cable coil : merge cables
/obj/item/stack/power_conduit/attackby(obj/item/weapon/W, mob/user)
..()
if( istype(W, /obj/item/weapon/wirecutters) && src.amount > 1)
src.amount--
new /obj/item/stack/power_conduit(user.loc, 1,item_color)
user << "You cut a piece off the [src.name]."
src.update_icon()
return
else if(istype(W, /obj/item/stack/power_conduit))
var/obj/item/stack/power_conduit/C = W
if(C.amount >= 50)
user << "The coil is too long, you cannot add any more cable to it."
return
if( (C.amount + src.amount <= 50) )
user << "You join the cable cables together."
C.give(src.amount) // give it cable
src.use(src.amount) // make sure this one cleans up right
return
else
var/amt = 50 - C.amount
user << "You transfer [amt] length\s of cable from one coil to the other."
C.give(amt)
src.use(amt)
return
/obj/item/stack/power_conduit/use(var/used)
. = ..()
update_icon()
return
//add cables to the stack
/obj/item/stack/power_conduit/proc/give(var/extra)
if(amount + extra > 50)
amount = 50
else
amount += extra
update_icon()
/obj/item/stack/power_conduit/attackturf(var/turf/T, var/mob/user)
if(T.cancable)
var/obj/conduit/power/found
for(var/obj/conduit/power/LC in T)
if(LC.channel == channel)
if (istype(LC, conduit))
found = LC
else
user << "There is another type of conduit at that position."
if ((T.x == loc.x) && (T.y == loc.y+1)) //North
if (found)
if (found.connects & 2)
user << "There is already a conduit at that position."
else
found.connects += 2
found.build()
found.update_icon()
else
use(1)
user << "[user] lays a [src] on the tile."
new conduit(T, 2, channel)
if ((T.x == loc.x) && (T.y == loc.y-1)) //South
if (found)
if (found.connects & 1)
user << "There is already a conduit at that position."
else
found.connects += 1
found.build()
found.update_icon()
else
use(1)
user << "[user] lays [src] on the tile."
new conduit(T, 1, channel)
if ((T.x == loc.x+1) && (T.y == loc.y)) //East
if (found)
if (found.connects & 8)
user << "There is already a conduit at that position."
else
found.connects += 8
found.build()
found.update_icon()
else
use(1)
user << "[user] lays a [src] on the tile."
new conduit(T, 8, channel)
if ((T.x == loc.x-1) && (T.y == loc.y)) //West
if (found)
if (found.connects & 4)
user << "There is already a conduit at that position."
else
found.connects += 4
found.build()
found.update_icon()
else
use(1)
user << "[user] lays a [src] on the tile."
new conduit(T, 4, channel)
return 1
return 0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////// Structure Cable //////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/obj/conduit/power
icon = 'icons/obj/conduits/power.dmi'
name = "power conduit"
desc = "A cheap, low power conduit for transporting electricity to machines."
anchored = 1
gender = NEUTER
var/channelsize = 1
var/mangled = 0 // It gets a new icon, It will occasionally "spark" causing a small area flash effect to mobs, and draining a percentage of power.
var/item_color = rgb(240,0,0) //Color of the wires insulation.
var/channel = 3 // Channel the wire is connected to, between 0 and 3.
var/connects = 0 // Directions the wire connects to, Bitflag. 1 is NORTH, 2 is SOUTH, 4 is WEST, 8 is EAST, or something.
var/insheat = 200 // How much heat does it take to destroy the insulation? Higher heat means less chance to melt, but more damage when it does.
var/resistance = 50 // How much energy is lost when passing through conduit. Affects the heat of the cable.
var/datum/conduit/powernet/parent = null // The powernet parent of the cable.
var/drop = /obj/item/stack/power_conduit // The object dropped when this cable is removed.
var/list/siblings // Pipes of the same channel, in the cardinals of this pipe, that are also connected to it. Cleans up building and stuff.
/obj/conduit/power/New(var/turf/T, var/C = 0, var/CH = 3, var/COL = rgb(240,0,0))
loc = T
item_color = COL
connects = C
channel = CH
build()
update_icon()
/*/obj/conduit/power/initialize() // Called at round start. Its really just a more intensive build process.
if (!rand(0,500))
mangle() // Really low chance for wire to start mangled.
build()*/
/obj/conduit/power/proc/build() // Called whenever a new cable is placed.
var/turf/M = get_turf(src)
for (var/obj/conduit/power/C in orange(1)) // Generate Siblings.
if (C.channel == channel)
var/turf/V = get_turf(C)
if (((connects&1) && (C.connects&2) && (V.y == M.y-1) && (V.x == M.x)) || \
((connects&2) && (C.connects&1) && (V.y == M.y+1) && (V.x == M.x)) || \
((connects&4) && (C.connects&8) && (V.y == M.y) && (V.x == M.x-1)) || \
((connects&8) && (C.connects&4) && (V.y == M.y) && (V.x == M.x+1)))
siblings += C
C.siblings += src
for (var/obj/conduit/power/C in siblings) // Merge sibling pipenets, adopt yourself a parent.
if (C.parent)
if (parent)
parent.merge(C.parent)
else
parent = C.parent
parent.children += src
parent.eff += resistance
else
world.log << "[get_timestamp()] - [src] found orphan pipe [C] at [get_turf(C)]."
if (!parent) // Create your own pipenetwork if you dont have one already.
parent = new /datum/conduit/powernet()
parent.children += src
parent.eff += resistance
/obj/conduit/power/proc/rebuild() // Called by powernet whenever a cable is removed or modified.
parent.rebuild() // This is really innefficient, Workin' on it.
/obj/conduit/power/proc/remove() // Called when this cable is removed.
for (var/obj/conduit/power/P in siblings)
P.siblings -= src
parent.eff -= resistance
parent.rebuild() // Calls rebuild() proc on all of its children to ensure they are rebuilt once, and only once.
/obj/conduit/power/proc/mangle() // Mangle the wire.
mangled = 1
update_icon()
/obj/conduit/power/update_icon() // Make sure the wire looks like it should.
icon_state = ("power_[channel]_[connects]")
color = item_color
/datum/conduit/powernet
var/list/children
var/power = 0
var/eff = 0 // Cable efficiency? Its the sum of all cable resistances in the powernet.
var/lastprocess = 0
/datum/conduit/powernet/proc/process()
for (var/obj/conduit/power/P in children)
if (power && eff)
if (power > (eff*10))
power -= (eff*10) // You lose a bunch of power every process to resistance.
else
power = 0
if ((power*(eff/500)) > P.insheat) // Cables will start to melt (dangerously) if the cable is too long, or too much power is going through it. Deal with this by using hubs and transformers or just better wires.
//P.melt()
//P.process()
//if (children.len < 2) // If there are no longer any members in the powernet, there is no powernet, duh.
// del src
lastprocess = world.time
/datum/conduit/powernet/Del()
if (children.len > 0) // This is really bad, somehow the powernet was deleted with children still attached to it. Oh well.
for (var/obj/conduit/power/P in children)
P.parent = null
//world.conduitmaster.orphans += P
/datum/conduit/powernet/proc/merge(var/datum/conduit/powernet/P)
for (var/obj/conduit/power/C in P.children)
C.parent = src
power += P.power
eff += P.eff
children += P.children
del P
/datum/conduit/powernet/proc/rebuild()
for (var/obj/conduit/power/P in children)
P.parent = null
for (var/obj/conduit/power/P in children)
P.build()
var/dpower = power/children.len
for (var/obj/conduit/power/P in children)
P.parent.power += dpower
del src
Problem description:
Does not compile, Throws an error saying there is a bad expression or something. Currently its "code\modules\conduits\powernet.dm:25:error: : invalid expression"
Secondly, double click your error. It will take you to the line that has the problem.
Thirdly, copy and include 5 lines above and 5 lines below where the error occurred (or just the whole entire proc/verb or whatever it is). Paste that as your new code snippet.
Finally, receive help. Good luck.