ID:149406
 
Ok im making a game in witch you have pets that you control by clicking a spot on the screen to tell it were to go. Im having one drowl back. My code tells it to go to the object at the click spot. I want it to go to the loc of the clicked spot, here my move code:

client.Click(O)
var/mob/Pets/P
for(P in world)
if(P:owner==usr.key)
usr.c=1
walk_to(P,O,1,0)
var/t=image('target.dmi',O,"[usr.select]")
usr << t
sleep(2)
usr.c=0
while(get_dist(P,O) >1)
sleep(2)
if(usr.c==1)
del(t)
del(t)
See, in that code its making O be the object. I just want it to be the place. How would i do that? See the whole reson im doing this is to make it so when you click it doesnt follow that object forever.</<>
Scoobert wrote:
Ok im making a game in witch you have pets that you control by clicking a spot on the screen to tell it were to go. Im having one drowl back. My code tells it to go to the object at the click spot. I want it to go to the loc of the clicked spot, here my move code:

client.Click(O)
var/mob/Pets/P
for(P in world)
if(P:owner==usr.key)
usr.c=1
walk_to(P,O,1,0)
var/t=image('target.dmi',O,"[usr.select]")
usr << t
sleep(2)
usr.c=0
while(get_dist(P,O) >1)
sleep(2)
if(usr.c==1)
del(t)
del(t)
See, in that code its making O be the object. I just want it to be the place. How would i do that? See the whole reson im doing this is to make it so when you click it doesnt follow that object forever.

Replace

<code> client.Click() </code>

With

<code> turf/Click() </code>

Now, it knows that O is a turf, not an object.

You'll probably have to muddle around with a few minor alterations, but that's your main problem.

In response to Malver
That would work but it would also mean that if you click on an object at a specific loc it won't go to it, you'd have to click on the turf itself.

Another way to do it would be to check what was clicked on sort of like this:

client/Click(atom/O)
if(isturf(O)) walk_to(P,O,1,0)
else walk_to(P,O.loc,1,0)