ID:144301
 
Code:
mob
verb
Colloportus(obj/door/D in view())
set category = "Spells"
view()<< "[usr] says, \"Colloportus!\""
view()<<"The door's lock with a wave of [usr]'s hand."
D.lock=1
Alohomora(obj/door/D in view())
set category = "Spells"
usr << "[usr] says, \"Alohomora!\""
view()<<"The door's unlock with a wave of [usr]'s hand."
D.lock=0


Problem description:these are spells that work fairly well, except that when they are called it checks alllllll the obj's in view not only the obj/door/D i dont get it please help

~Volks (The Jokers Card)

oview(1) or get_step(usr,usr.dir)
In response to Xx Dark Wizard xX
well you dont have to be close to it, just it in your view
In response to VolksBlade
Different parts of a verb tell different parts of BYOND what to do. Consider this verb:
mob/verb/attack(mob/enemy/target as mob in view())

The "mob/enemy/target" part tells Dream Maker that the variable "target" is of type "/mob/enemy". The "as mob in view()" part, on the other hand, tells Dream Seeker that the user has to select any mob in view(). So, even though it doesn't make much sense, this verb is considered perfectly valid by both DS and DM:
mob/verb/nonsense(obj/an_object as turf in view())

That will tell DM that an_object is of type /obj, and DS will force the user to select a turf.

It seems, to me, that the best thing for you to do is something like the following:
mob/verb/unlock_spell()
var/turf/door/next_step = get_step(src, dir)
if(istype(next_step, /turf/door))
next_step.open()

That proc will first define a variable which is of type /turf/door, and will set it equal to whatever the next turf in front of the player is. Then it will check if that turf really is a door. If it is, it'll open it.



Edit: I just read what you said about the door only having to be "in view()". Well, there's another approach you could take. It's not as clean, but it will work in this situation.

First, tell DM what sort of variable you're defining, and then tell DS what sort of object the user can select:
mob/verb/unlock( /obj/door/the_door as obj in view())

That will allow the user to select any obj in view, but we want to make sure that she actually chooses a door:
if(!istype(the_door, /obj/door)) return

That'll bail out if the user chose anything besides a door.