ID:139287
 
Code:
            Move()
var/mob/W = src
usr = src.original
for(var/obj/trail/water/click/WC in world)
if(WC.original == usr)
world<<"NO KURWA1"
var/how = get_dist(W,WC)
world<<"STEP:[how]"
if(get_dist(W,WC) == 0)
world<<"NO KURWA2"
del(W)
..()


Problem description:

Get_dist doesn't work if I set value to 0 if it's greater than 0 it works but not for 0, I want to del (src) when distance between src and WC is equal to 0. How can I do it?
First of all, you're defining get_dist(W,WC) twice which is unnecessary because you have the "how" variable storing the value of get_dist(W,WC).


Second, get_dist() records how many steps it takes to get from A to B. get_dist() will not return 0 unless A and B are in the same location. If what you're trying to detect is if A and B are within touching-range, you'll want to see if the get_dist() between them is 1.
In response to Duelmaster409 (#1)
Get_Dist returns value 0 but when I put 0 it doesn't work, I tried with range(0,WC) any ideas how can I improve it?
In response to Paffci0 (#2)
Have you tried if(WC in range(0,W)) and/or if(!get_dist(W,WC)?
In response to Duelmaster409 (#3)
Yep I tried after you post but It doesn't work ;/
In response to Paffci0 (#4)
Then there must be something else wrong with your code that you didn't provide (please don't copy and paste your entire source) or that I'm not seeing.
In response to Duelmaster409 (#5)
I know that there is something wrong because? It doesn't work with value 0, with any other it does ehh. Thanks after all that you replied. Cheers Paffci0
var/mob/W = src


Don't you mean:

var/mob/W = mob // src is a client if Move() is under client, and it wouldn't make sense typecasting a client to a mob.
In response to Duelmaster409 (#7)
Umm?
This Move() is from obj/trail/water/Move() so src is water.?
In response to Paffci0 (#8)
Ah. I was under the assumption this was client/Move(). This is still entirely wrong, because you are typcasting a /mob from an /obj. Now that I know what src is your entire code doesn't make much sense.
In response to Duelmaster409 (#9)
Why it doesn't make much sense? I'm creating object which with other pr0c is stepping towards (WC) and if range/dist between (WC and src[W]) is 0 it deletes (W) is it still make no sense?

If you know tell me why get_dist/range works with any other value but no with 0?
In response to Paffci0 (#10)
Stop butchering the English language, gah! I'll try to break down your code to point out the problems in a moment.
There is no reason, ever, to be typecasting src. The line var/mob/W = src is somewhere between incorrect and pointless. Get rid of it and use src instead of W.

There is no good reason, ever, to be assigning a value to usr. Remove the line usr = src.original and just use src.original where you use usr later. I'm really not sure what possessed you to roundabout through usr anyway.

Looping through every object in the world is incredibly silly. You are ONLY interested in things where the distance to them is 0, so only look at things in range(src,0). So:

for(var/blah in range(src,0))


The get_dist() stuff is then no longer needed.
In response to Paffci0 (#10)
Nevermind, Garthor beat me to it!
In response to Garthor (#12)
            Move()
for(var/obj/hakus/water/click/WC in range(0,src))
world<<"no? ;/"
del(src)


For 0 nothing
For 1 works perfect.

But if I change it to:
obj
haku
water

Move()
usr = src.original
usr.track()

mob
proc
track()
for(var/obj/haku/water/W in world)
for(var/obj/hakus/water/click/WC in range(0,W))
del(W)

Then it works -,-"
In response to Paffci0 (#14)
There is 100% no reason whatsoever for you to need any for(blah in world) loop. Which object's Move() proc is being called and what is the state of the world?
In response to Garthor (#15)
State of the world? Which object's Move()proc?
Obj/Haku/Water/Move()?

But why it doesn't work for 0? :(
In response to Paffci0 (#16)
State of the world as in how things are configured at the time that the procedure is called. For instance: you wouldn't find anything in range(0,src) if there is nothing in range(0,src). Without context it's hard to diagnose a problem.

For example, it might help to know how and when the things are moving. Do they only move once? Repeatedly? Until something happens?
In response to Garthor (#17)
obj
haku
water
Move()
for(var/obj/hakus/water/click/WC in range(0,src))
del(src)
mob
proc
Hakus_Control()
for(var/obj/haku/water/W in world)
for(var/obj/hakus/water/click/WC in world)
if(W.original == usr)
walk_towards(W,WC)

And WC is created when I click on the turf. But why it finds in range(1,src) but doesn't in range(0,src)?
In response to Paffci0 (#18)
You still haven't given enough information. Odds are, you aren't finding anything in range(0,src) because there is nothing in range(0,src). You are likely confused about the order of events as they occur.
Page: 1 2