ID:176900
 
like when I click my mob a box surrounds it to show it is selected. Then when i click for the mob to move, it deletes the box, which is what i want it to do, but i want it to disappear only when it reaches its target and stops.
Delita12345 wrote:
like when I click my mob a box surrounds it to show it is selected. Then when i click for the mob to move, it deletes the box, which is what i want it to do, but i want it to disappear only when it reaches its target and stops.

I'm not really sure of what you're getting at here; I can kind of picture it, but there are a few too many pronouns to make the whole thing out.

One of the things I notice here is that you're speaking of a click interface for movement. I can see that selecting items is important to this, but you also mentioned a target, and that you want "it" (not sure whether you're referring to the selection box or the target) to disappear when the target is reached. I'm not sure what kind of game the interface is used for, which might make a difference in how you'd implement this.

If you can elaborate a little bit more I think it would help.

Lummox JR
In response to Lummox JR
i want the selection box to disappear only when the mob has reached the turf i click on.
In response to Delita12345
Okay, one step at a time...

The best way to make a box appear around something is to use overlays. You would most likely want to make a new .dmi file (for the sake of this example, we'll call it box.dmi).

To detect when a usr clicks on something, override Click() for whatever you want the usr to click on. For example, if you have a unit which you want the usr to be able to click on, override Click() for the unit.

Finally, you'll need a var that is set to whichever mob the usr has selected.

<code>mob/var mob/unit/selected //Which unit src has selected mob/unit Click() src.overlays+='box.dmi' //Put a box around the unit usr << "You have selected [src]" //Tell the usr usr.selected=src //Set the selected variable to the unit</code>

Now we just need to make the unit move somewhere, and remove the selection overlay when it stops.

To determine where the unit is going to move, we can check for clicks on turfs:

<code>turf/Click() if (usr.selected) //If the usr has selected a unit var/mob/unit/moveunit=usr.selected //Save which unit it is, just in case the value of usr.selected changes spawn() //Everything indented under this will go on in the background (while other things are going on) while (!usr.selected.loc=src) //Loop until it reaches the turf if (!moveunit) return //If the unit has been deleted for some reason, exit the proc step_to(moveunit,src) //Move the unit to the turf //The unit has now reached the turf moveunit.overlays-='box.dmi' //Delete the box</code>

That might not be exactly what you wanted, and it's not the best way of doing things (ideally the mob would handle its own movement, rather than the turf it's moving to), but it's the best I can be bothered to do right now. Hope it helps.