Format:
Enter(atom/movable/O)
Returns:
1 to permit; 0 to deny.
When:
Called when an object attempts to enter the contents list.
Args:
O: the object attempting to enter.
Default action:
Permit the object to enter (returning 1) if this would result in 1 or fewer dense objects at the location.
In other words, you must end your Enter() proc with return 1 or else you won't be able to enter it.
area Test1 name = "Testing Area" Enter(O) O << "You triggered the enter proc!" return 1
Of course, you can't have two dense objects in the same location, so I'm not too sure if you'll be do anything if the turf you have the proc on is dense.
area Test1 name = "Testing Area" Enter() usr << "You triggered the enter proc!" return 1
Of course, you can't have two dense objects in the same location, so I'm not too sure if you'll be do anything if the turf you have the proc on is dense.
Oh gads. How many times do I have to repeat myself on this?
NEVER use usr inside Enter() or Entered(). Enter() has an argument; use that instead. usr may or may not be the thing that's trying to enter, so it's not safe to use it.
As for the rest, you don't have to worry about the turf being dense; Enter() will override that, because the density check is done in the default Enter() proc. What probably makes more sense, though, is to use the default Enter() via ..() for boats, while returning 0 for non-boats.
Incorrect. Because he wants to selectively block things from entering, Enter() is the correct choice; Entered() should be used for things you want to happen after the atom has already entered, not while they're still checking.
I beleive it is rather of rude for you to shout at me for that. I typed it up as an example, geeze.
I've been shouting at everyone for that, for the simple reason that it's bad code and it keeps propagating among the newbies, leading to more problems. I've said the same thing in any number of posts now.
Anyway, in my case I at least know what usr is.
But the problem is, that would only work in your case, and the reason why wouldn't be immediately obvious to anyone who used it as an example. The big reason why usr is so bad to have in Entered() is that even if it always works in one particular single-player game, it will instantly break if it goes multiplayer or if other atoms (mobs or objs) start moving around.
I am wondering y every1 is so busy correcting eachother's mistakes in these posts. Y hasn't any1 just plain answered the question with the code for it?
turf/Ocean
icon = 'turf.dmi'
icon_state ="water"
density = 0 //density = 0 for this example
Enter(M)//i dunno how u want to figger if some1 can enter
if(M:hasboat) //however u figger it
return ..() //do the rest of the movement stuff to c
//if there is enything blockin or other things stopin them
else
return 0
Entered(mob/M)
M.icon = 'objects.dmi'
M.icon_state ="rowboat"
Exited(mob/M) //don't forget to bring em back to normal
M.icon = 'people.dmi'
M.icon_state = "player" //whatever ur normal icon stuff
mob/var/hasboat = 1 //just here for this example
I think i got everything...O well i know some1 will correct me if im wrong...
I am wondering y every1 is so busy correcting eachother's mistakes in these posts. Y hasn't any1 just plain answered the question with the code for it?
Actually the answer is among the posts here; it's just not posted outright in a neat section of code.
I think i got everything...O well i know some1 will correct me if im wrong...
Indeed I will!
turf/Ocean ... Enter(M)//i dunno how u want to figger if some1 can enter if(M:hasboat) //however u figger it return ..() else return 0
Whee! Instant crash! Anything that doesn't have the hasboat var will cause a major flood of debug messages and won't move out onto the water. This is why it's best to avoid using : whenever you can help it.
The correct solution is to specify the type for M:
Entered(mob/M) M.icon = 'objects.dmi' M.icon_state ="rowboat" Exited(mob/M) //don't forget to bring em back to normal M.icon = 'people.dmi' M.icon_state = "player"
Since objs can move too, you can't safely assume M will be a mob; you should use a form of code similar to what I put above. However, I do like the way you automatically assigned a boat icon on entering the water; that's clever.
set the density to 0