ID:268506
 
Enter(usr.contents.Find(/obj/Fishing_Boat))
usr.Ride()

Wouldn't that make it so that noone unless they have a boat enter the area?
Considering you're actual code is right...

Enter()
if(usr.contents.Find(/obj/boat)
usr.Ride()
else
usr.loc=locate(usr.x,usr.y,usr.z)
In response to DeathAwaitsU
Thanks for your help, but yet it doesn't seem to work. The fact that I am using this Enter() proc in an OBJ type wouldn't affect it would it?
In response to DeathAwaitsU
No, no, no. Do not use usr in Enter. I repeat, do not use usr in Enter. Do not use it in any procs, in fact, unless you can be completely sure it is called for (which it usually is not).
turf/Enter(atom/movable/A)
if(ismob(A))
var/mob/M=A
var/obj/boat/O=locate()in M
if(O)
M.Ride()
return 1

That would be more like what you are looking for, but even that is not the greatest way to do it. You want to call M.Ride in Entered.
turf
Enter(atom/movable/A)
if(ismob(A))
var/mob/M=A
var/obj/boat/O=locate()in M
if(O)
return 1
return 0
Entered(atom/movable/A)
M.Ride()

That way would be better. You might not think so at the moment, seeing as it is simply a single line moved over; but it is good habit to always keep things that happen when entering seperate from the things that determine whether or not you can enter, the former going into Entered and the latter going into Enter. Many bugs occur when people try to cram it all into Enter.

And about that usr.loc=locate(usr.x,usr.y,usr.z) line... that is beyond redundant. The object is allready there, so if you don't allow it to enter it will stay there.
In response to Loduwijk
I know not to use usr in procs but i tend to always forget stuff like enter since i dont really think of them as processes in my head.

Thanks a lot for correcting me though.
In response to DeathAwaitsU
It would help you out a lot if you try to refrain from using usr at all times. Use src all the time, even in your verbs (unless, of course, they belong to other objects in which case src is not the player's mob); and pass arguments around when you can't use src. Start trying to use usr only when absolutely nessessary. Your programs might not require you to go quite that far; but where avoiding usr is concerned, going too far is better than not going far enough.
In response to Loduwijk
Would this for for the Enter() proc in OBJs? Because it doesnt seem to work!!!
This is what I have.
obj/water
name = ""
icon = 'AnimatedWater.dmi'
Enter(atom/movable/A)
if(ismob(A))
var/mob/M=A
var/obj/Fishing_Boat/O=locate()in M
if(O)
return 1
return 0
Entered(atom/movable/A)
var/mob/M=A
M.Ride()
In response to Loduwijk
Loduwijk wrote:
Entered(atom/movable/A)
M.Ride()

*cough*.. Ahem? *points up*
In response to Ryne Rekab
Yes, it will work for obj/Enter; but I suspect you aren't actually entering the object. You don't call obj/Enter by stepping on the object. Also, as Unknown Person pointed out (thanks) I typoed. The Entered function should have looked like the following.
Entered(atom/movable/A)
if(ismob(A))
var/mob/M=A
M.Ride()

If you want to treat this water as though it were turf for the sake of laying it down as terrain and calling its Enter/Entered functions when stepped on, you will need to alter turf/Enter and have it search for water in it and call that water's Enter and Entered and pass the variable into them as well.
turf/Enter(atom/movable/A)
var/obj/water/water=locate()in contents
if(water)
if(!water.Enter(A))
return 0
.=..()
turf/Entered(atom/movable/A)
var/obj/water/water/=locate()in contents
if(water)water.Entered(A)
In response to Loduwijk
Thank You, this final bit fixed it.