ID:144398
 
Code:
        Enter()
if(istype(usr,/mob/player)||istype(usr,/mob/MizuBunshin))
return 1
if(istype(usr,/mob/Pet))
usr.icon_state="swim"
return 1
if(istype(usr,/obj/))
world<<"Success"
return 1


Problem description:
It lets everything that is defined in, except objs...
NEVER USE USR IN PROCS, ESPECIALLY MOVEMENT PROCS!!!

And do return..() instead of return 1... return..() will check all other info to see if the person can walk in (eg: dense object will deny walk into) while return 1 will force pass them through.. I think

- GhostAnime
In response to GhostAnime (#1)
Ah! Ok ta

(I originally used src, but was just fiddling with things to see if I could get the result I wanted...)
You have an extra slash after obj. Use this:

Enter()
if(istype(usr,/mob/player)||istype(usr,/mob/MizuBunshin))
return 1
if(istype(usr,/mob/Pet))
usr.icon_state="swim"
return 1
if(istype(usr,/obj)) //slash was here
world<<"Success"
return 1


Edit: Still, fix up the usr abuse. You can do that yourself.
In response to CuriousNeptune (#2)
src = source.. there's a reason why there's an argument in the Enter() definiation:
turf/apple/Enter(mob/M)
world<<"[src.name] = Apple"
if(ismob(M)) world<<"[M] = Mob"
else world<<"[M] = Not a mob"
It is very important to know that movement procs (like bump, enter, etc) do not look for what you entered in the arguments [the parenthesis].. so "M" can be an object.. so always safety check

- GhostAnime
In response to Top player (#3)
Please do not show faulty examples, usr abuse and forced location :/

- GhostAnime
In response to Top player (#3)
o_o The slash, there or not, made no difference.
In response to GhostAnime (#4)
area
Water
Entered(mob/M)
if(istype(M,/mob/))
usr.disabledwater=1
usr.canfindrocks=0
usr.WaterWalk()
Enter(mob/M)
if(istype(M,/mob/player)||istype(M,/mob/MizuBunshin))
return..()
if(istype(M,/mob/Pet))
src.icon_state="swim"
return..()
Enter(obj/O)
if(istype(O,/obj/))
world<<"Success"
return..()
Exited(mob/M)
if(istype(M,/mob/))
M.disabledwater=0
M.canfindrocks=1
M.WaterWalk()
Exit(mob/M)
if(istype(M,/mob/Pet))
src.icon_state=""
return..()
else
return..()


Now nothing gets in :| (which is bad, I want free flow of objs. And limited flow of predefined mobs)
In response to CuriousNeptune (#7)
area
Water
Enter(obj/O)
if(istype(O,/obj/))
world<<"Success"
Enter(mob/M)
if(istype(M,/mob/player)||istype(M,/mob/MizuBunshin))
return 1
if(istype(M,/mob/Pet))
src.icon_state="swim"
return 1
else
return

The exit() was relatively simple to solve, as I want any and all things to be able to leave the water...
But I don't want certain mobs to be able to enter it.

I've just included the enter procs here for easier reading.
The problem I'm having is that players, mizu bunshin and pet mobs can enter the water, but nothing else can.
If I put the obj's "enter()" proc on the bottom, objects may enter, but nothing else may... :(

EDIT
        Enter()
if(istype(usr,/mob/player)||istype(usr,/mob/MizuBunshin)||istype(usr,/obj/))
return 1
if(istype(src,/mob/Pet))
src.icon_state="swim"
return 1
else
return

The above code works superbly, except for objects.
using src must be incorrect, as only usr will work...
But neither src or usr will work for my obj :(
In response to CuriousNeptune (#8)
Really, people, before using procs, look them up in the DM Reference.
After your movement proc overridation, in the end, do 'return ..()' to do the default behaviour (remove it from the istype() trees, to shorten the code) will be ran.
No need to use 'else' if in the 'if' statement, you used 'return'.
Combine your 2 same-object-path Enter() overrides...no reason to separate them. Typecast the argument as /atom/movable, if needed.


Yea, top player, dont post bad code. That also means don't post if you don't know about the subject at hand. ....Also, an extra trailing slash isn't even an error...
In response to Kaioken (#9)
Can't use atom/movable, or the unwanted mobs will be able to pass through.
I had had the obj bit combined since the post, but all that's done for me is have the obj part ignored...

the reason i use else is to say "if its not one of the above defined things, don't let it through" hence 'return 1'

Im pretty sure I could fix it all by specifying which mobs i wish to keep out... I was just trying to do it the other way round...
In response to CuriousNeptune (#10)
CuriousNeptune wrote:
Can't use atom/movable, or the unwanted mobs will be able to pass through.

Typecasting doesn't limit anything to types, it just tells the compiler what type the var should be. The things that limit to types are your istype() checks.

I had had the obj bit combined since the post, but all that's done for me is have the obj part ignored...

...Because you must of did something wrong.

the reason i use else is to say "if its not one of the above defined things..."

ORLY? Thanks, but I know the use of the 'else' statement. :P I'm saying it's useless in this case and shouldn't be used, because if the code does meet the "above defined things", it would of returned - which stops the proc. Therefore, the else is useless.

Im pretty sure I could fix it all by specifying which mobs i wish to keep out... I was just trying to do it the other way round...

You can do it either approach...but you need to do it the right way.

Well, um, if you want any help, post your code (and problems).
In response to Kaioken (#11)
I figured you could... And since I haven't made any mobs that fit into the blocked category, i was reluctant to code as such :| Pretty OCD really ^_^

I just made it if(mob/NPC) return (not EXACTLY like that, of course. :P

Works.
In response to CuriousNeptune (#12)
yet you are still having the wrong type being in your code from what you showed in [link] .. which is src.icon_state... don't you want M.icon_state? Remember src=source of that proc/verb [which is the area/Water]
area
Water
Enter(mob/M) /*
REMEMBER, AS I STATED EARLIER (in [link]):
Movement procs like Enter() does NOT
KEYWORD: NOT!!
look for the type you put in the argument (which here is mob/M)..
which means that M CAN be an object or a turf or an area... so SAFETY CHECK!*/

if(isobj(M)) //Read the above note why I am checking if it's an object... also, why should I type the whole istype(M,/obj)? I use the bui;t-in procs for the samething for lazy people :O!
world<<"Success"
else if(istype(M,/mob/Pet))
M.icon_state = "swim" //earlier, you refered this to src.icon_state... which was changing the icon_state of the source, which is area/Water..an d not of the pet (I assume it's the pet you want to change the state of only :/)
else if(!(istype(M,/mob/player)||istype(M,/mob/MizuBunshin))
return 0
/*
There's a reason why I did not returned anything except for this yet.. look a bit below ;)
When you have 'return', it's saying 'return null' which is, I believe, the samething as having no return statement in a procedure....
which means return FALSE which means return 0 which means that the object wanting to enter the turf will be DENIED (according to the DM Reference) which is why your objects were not entering before :/
*/


return..() //As I stated earlier, return 1 would basically force move it..\
this makes sure that it checks if the item is able to enter that turf\
(meaning it checks for dense objects and such)


Read the comments very carefully as I believe you still have problems :/ Ask if you do not understand something

- GhostAnime