ID:158327
 
-How do you make it to where a certain user clicks his/her object then clicks a spot on the turf and makes it go there.
-If possible could you also tell me how to select multiple objects at once.
Kokomo0020 wrote:
-How do you make it to where a certain user clicks his/her object then clicks a spot on the turf and makes it go there.
-If possible could you also tell me how to select multiple objects at once.

Well there is a procedure to handle clicking, guess what it's called?

Click()

There are actually two methods of doing this, here are both:

Method 1:
turf
Click()
walk_to(usr, src)


In this method, Click() is called when the turf has been clicked.

Method 2:
client
Click(turf/T)
walk_to(usr, T)
..()


In this method, Click() is called when a client clicks a /turf (T), I am also calling the default action which calls the objects Click() procedure along with the arguments (location, control and params) - You can look up more on this in the Click() reference.
Kokomo0020 wrote:
-How do you make it to where a certain user clicks his/her object then clicks a spot on the turf and makes it go there.
-If possible could you also tell me how to select multiple objects at once.

For the 2nd one..... List? Or do you want something visual? If thats, it, then i guess try writing the values in your handy little list to stat panel...? Or did you want a hud? If so, forget about, because the few people who know about won't tell you.
In response to Haywire
So would I do this:
obj/Click()
to turf/Click()
walk_to(usr,src)

Because you still didn't explain how to click the
object(not mob) then the turf to make the object move there.



In response to Kokomo0020
Try adding the object clicked to a list, or give it a variable to decide if anything should move to the turf you clicked...

mob/var/list/selected=new           
obj
clickable
Click()
usr<<"Omg you clicked me, I'm honoured :)"
usr.selected += src
turf
Click()
for(var/obj/a in usr.selected)
walk(a,src)


But don't take it from me, I have no idea what I'm talking about! :)
In response to Kokomo0020
Kokomo0020 wrote:
So would I do this:
obj/Click()
> to turf/Click()
> walk_to(usr,src)

Because you still didn't explain how to click the
object(not mob) then the turf to make the object move there.




What, I don't understand what you mean, where did /obj come from? I thought you wanted /turf/Click().
In response to Neos300
Neos300 wrote:
Or did you want a hud? If so, forget about, because the few people who know about won't tell you.

You seem awfully bitter about this for some reason. All you really need to know about a HUD is in the reference.
In response to Haywire
Nope. What I'm looking for is where a user, and that user only, can select an object by clicking it then send it to where they want it to go to by then clicking the area on the turf.
In response to Speedro
Oh jeez dude, thanks. Exactly what I was looking for. I can't ever understand the guide so your amazing.

In response to Kokomo0020
Kokomo0020 wrote:
Nope. What I'm looking for is where a user, and that user only, can select an object by clicking it then send it to where they want it to go to by then clicking the area on the turf.

atom
icon = 'Icons.dmi'
//Set all atoms the icon 'Icons.dmi'

turf
Grass
icon_state = "Grass"



mob
icon_state = "Mob"
var
list
selected_objs = null
//Initiliase to null since there might be many mobs in the world and most of them may not need this list so better null than empty!


obj
density = 1

obj1
icon_state = "Obj1"
obj2
icon_state = "Obj2"


client
Click(atom/o)
if(istype(o, /obj))


if(!usr.selected_objs || !usr.selected_objs.len)
usr.selected_objs = list()
//If the list is null then we might as well initliase it to list() since we need to use it

var/x = FALSE
if(o in usr.selected_objs) //If obj 'o' exists in selected_objs
usr.selected_objs -= o //Remove obj 'o' from the list
else
usr.selected_objs += o //Add obj 'o' into the list
x = TRUE //Set x to true since it is sleected

world << "[o.name] [(x) ? "Selected" : "Deselected"]!"
//Output to the world if obj 'o' is selected or not depending on the 'x' variable

//Clean up
if(!usr.selected_objs || !usr.selected_objs.len)
usr.selected_objs = null
//If the list is empty we might as well set it to null, better null than empty

else if(istype(o, /turf/Grass))

for(var/obj/object in usr.selected_objs) //For all /obj 's in the selected_objs list
walk_to(object, o) //walk the object to the location of o
..()


Small documentated example.
In response to Garthor
Garthor wrote:
Neos300 wrote:
Or did you want a hud? If so, forget about, because the few people who know about won't tell you.

You seem awfully bitter about this for some reason. All you really need to know about a HUD is in the reference.

Really? I honestly did not know that. Thank you for helping me find this out.
You should make use of the click() part of DM. Put it in with the rest of your code, I'm not sure how you're programming this thing for yourself.