ID:1737910
 
(See the best response by Nadrew.)
Code:
obj/props/laserbutton
icon='props.dmi'
icon_state="laserbutton"
density=1
name= "Laser Control Panel"
verb/Use()
set src in oview(1)
set hidden = 1
view(6)<<"<font color=purple><b><small>[usr] has activated the laser system."
LaserSpawn()


Problem description: Basically, I'm trying to make it so when players activate a switch, lasers will spawn in the nearby area, so when a hostile player crosses it they're vaporized instantly.

obj/proc/LaserSpawn()
switch(type)
if(/area/laser)
spawn(5) new/obj/props/lasers


I just can't figure out how to get the lasers to spawn in the areas within view in front the lazer button. The area has been placed infront of said switch.

You can check the area that a turf is in by getting its loc.
in laserspawn() you need to use get_step() or view()/oview()(or range()/orange()) to check for the /area/laser/ type and spawn the obj at that location.

Best response
You can use locate().

obj/proc/LaserSpawn()
var/area/laser/found_area = locate() in view(src)
if(found_area)
for(var/turf/T in found_area)
if(prob(50)) new/obj/props/lasers(T)


That will randomly place lasers within the area, you'd probably be using an area bigger than one tile so I added a little 50% chance of the laser spawn, you can of course change this to do it how you want it done.
In response to Nadrew
I had assumed that he was trying to essentially have the laser spawn inside a set area in a line infront of a switch/button obj.

You did just give me an interesting idea for a 'laser show' obj, lol.
In response to NNAAAAHH
Yes, this is what I'm trying to do.

Edit: Either way, the laser stuff works now. Thanks Nadrew!