ID:1926232
 
(See the best response by Lummox JR.)
Code:
player/verb/East()
if(src.Move(locate(usr.x,usr.y,usr.z),NORTH,src.step_x+6,src.step_y)==1)
world<<"1"
else
world<<"0"


Problem description: From what I understand the move proc returns 1 when success and 0 when fail. Now I assumed fail would be respresented by not being able to move from a dense object. However when i do the code from above what I get is nothing. Nothing even prints out to the screen. My objective is too have alternative moving behaviour if it touches something dense

I looked into it, and found a "possible" solution. Luckily, in my little test project, I had the same issue and didn't even know it.


If your problem is what I ran into, it's because you've changed the default Move() script. This isn't a big deal at all, but you will need to pass the value off.

For instance, if your script is like this:
mob/Move()
..()


It will not return a value, but if it's like this:
mob/Move()
.=..()


It will return the values as if you haven't changed it. What the period variable represents, is the default return value of the procedure. By changing it, you tell the script to return a value. By having .=..(), that means to run parent procedures, and return the values (it's hard to explain, so I'm sorry if I'm being too confusing).


Furthermore, you can actually do what you're trying to, by using step() instead:

player/verb/East()
src << step(src,EAST) //Displays if successful


I also found that using what you have, will return the number of pixels the mob has taken. So, your script would need to be something like this.

player/verb/East()
if(src.Move(locate(usr.x,usr.y,usr.z),NORTH,src.step_x+6,src.step_y))//If it's not zero
world<<"success"
else
world<<"0"
I haven't touched move however. And I did that and it still prints neither of them.

But I'll test more when I get home
Something should be printing. The only way nothing would print, is either there's a runtime error, or you don't have a default output selected (which would mean nothing ever prints unless specified to a certain output). I misunderstood when you said nothing, thought you were saying it always passes 0/null.


If you aren't getting runtime errors, try something like this:

player/verb/East()
if(src.Move(locate(usr.x,usr.y,usr.z),NORTH,src.step_x+6,src.step_y))//If it's not zero
alert(src, "successful")
else
alert(src, "0")
Print works fine before the if statement but after it'll stop working. Or not that it'll stop working but go in neither the if or the else which is strange

I'll try that
Best response
DanteVFenris wrote:
From what I understand the move proc returns 1 when success and 0 when fail. Now I assumed fail would be respresented by not being able to move from a dense object. However when i do the code from above what I get is nothing. Nothing even prints out to the screen. My objective is too have alternative moving behaviour if it touches something dense

This is incorrect.

The Move() proc used to return 0 or 1, but since the advent of pixel movement it does not; on success it returns the number of pixels moved (in sliding movement) or 1 (in jumping movement). This is documented in the reference.

In your example case, if you want to test if something dense was touched to prevent the full movement, you would want to see if Move() returned anything less than 6. If you want to see if movement was successful at all, then you would want to simply check if the return value was true. (Two other problems: Why is the dir argument NORTH if you're moving east, and why are you mixing src and usr?)

As a more general rule, using ==1 and ==0 to test if something was true or false is bad form. You should simply use if(something) to see if it's true, and if(!something) when you want to see if it's false.
In response to Lummox JR
those problems are caused from a copy and paste from old code, im editing it.
In response to Lummox JR
player/verb/North()
    src<<"b"
if(Move(locate(x,y,z),NORTH,step_x,step_y+6)<6)
src<<"1"

src<<"a"

okay here is an example, the a and the 1 do not print, even if it hits a dense object
What are you trying to test for? I said < 6 is what you'd check to see if anything stopped the movement prematurely. If you want to see if you moved at all, any true value would tell you that.
In response to Lummox JR
woah nope found an even weirder problem....

I thought I've been doing it right. What i've noticed is it will start printing properly but only after a minute or so after the world is run
butt....

your still able to print messages before that. It also is still able to walk. It just completely ignore ifs or else until 20 seconds. Now this is a demo ive just started to test things so there really is nothing in it. No sleep statements in the entire thing so far.

Damn this is so weird maybe i have a bugged file
Nevermind found the problem, it was entirely unrelated to this. Completley and yet it somehow managed to pull off this very strange behaviour
mob
Login()//Starts here.
var/player/p = new(locate(1,1,1))
p.client=src.client
src.loc=null


true problem, easiest way to make a player of type mob transfer to a player of type player on login
In response to DanteVFenris
world
mob = /player
In response to Kaiochao
thats what it was, okay thank you!