ID:147356
 
MY RTS has a day and night system. I have an object you can build called Light Tower. When you build It i want it to make a light on its loc, then 1 above it, below and on both sides...but I dont know how to, here is what got so far.



var/o = new/obj/Light(usr.loc)
new/area/inside(usr.loc)
var/d = new/area/inside(usr.loc)
var/dd = new/area/inside(usr.loc)
dd:x += 1
d:x -= 1
but when I build it in the game i get lots of errors..
Konamix wrote:
MY RTS has a day and night system. I have an object you can build called Light Tower. When you build It i want it to make a light on its loc, then 1 above it, below and on both sides...but I dont know how to, here is what got so far.

In the verb that creates the light tower, just use this

var/o = new/obj/Light(usr.loc)

or if you don't access o, just use

new/obj/Light/(usr.loc)

If you use a proc, you'll need to do away with usr and feed the loc to the proc as an argument.

In any event, you want to override the Light/New() proc.
obj/Light/New(new_loc)
..() // do all the default creation stuff
if(!isturf(new_loc)) return // prevent invalid locs

// find if an inside area already exists
var/area/inside/I = locate()
if(!I) // if not...
I = new() // create one
I.contents += new_loc

// step through the 4 cardinal directions
var/new_dir = 1
for(var/X = 1 to 4)
var/turf/T = getstep(new_turf, dew_dir)
if(T) I.contents += T