ID:176894
 
Im trying to make a code where when a person clicks on a tile of grass it puts a click image there for a few secons and moves your character there but im having problems with it only working on grass. Can somone help me please.
This is my code:

mob
var/c=0

client.Click(O)
usr.c=1
Here I need something like if(src = turf/grass) which doesn't work<<<<<<<<<<<<<< <<
walk_to(usr,O)
var/o=image('cursor.dmi',O,"click")
src << o
sleep(2)
usr.c=0
while(get_dist(usr,O) >0)
sleep(2)
if(usr.c==1)
del(o)
del(o)

client.Move()
usr << "Click to move."</<<<<<></<<></< ;<<<<<<<<<<<<></< <<<<<<></<<<<<<< <></<<<<<<<<<<<< <<></<<<<<<<<<<< <></<<<></<<<<<<< ;<<<<></<<<<></<<< ;<<<></<<<<<<<<<< ></<<<<<<<<<></<> ;</<></<<<<<<<<<<< ;<<<<>
Ahem, [link]

There are two ways you could do this. You could either set the Click function to be for turf/grass, like this:

<code>turf/grass/Click() // do stuff</code>

or you could check to see if the Click action is used on turf/grass type like this

<code>client/Click(atom/target) if(target.type == turf/grass) / do stuff</code>
ShadowBlade6300 wrote:
Im trying to make a code where when a person clicks on a tile of grass it puts a click image there for a few secons and moves your character there but im having problems with it only working on grass. Can somone help me please.
This is my code:

mob
var/c=0

client.Click(O)
usr.c=1
Here I need something like if(src = turf/grass) which doesn't work<<<<<<<<<<<<<< <<
walk_to(usr,O)
var/o=image('cursor.dmi',O,"click")
src << o
sleep(2)
usr.c=0
while(get_dist(usr,O) >0)
sleep(2)
if(usr.c==1)
del(o)
del(o)

client.Move()
usr << "Click to move."
That's an interestingb approach but there is a much, MUCH cleaner approach.
Use the atoms Click() procedure.
turf/grass
Click()
//now use your code. I believe you can use usr.
In response to Foomer
Thanks