ID:270277
 
My code is as follows

mob
icon = 'p1.dmi'
icon_state = "stand_S"

client
North()
return 0
South()
return 0
East()
return 0
West()
return 0
MouseDown(O, L, x1,y1)
step_on_click(L)
return

proc
step_on_click(x1)
usr << L.x
return


Now I've read archives and archives about this and none of them will work on my system. The only variable that seemsto be passed when calling this function is the name of the object and none of the other variables or objects associated. L.loc, l.x, l.y, l.icon_x and the whole lot of any imaginable var that would be associated with an object or location give me errors and say variable does not exist when trying to compile.

I've read tutorial after tutorial and this SHOULD work but it does not. In fact passing O and L give me the same exact results, the name of the object on the location I clicked. The x1 and y1 give me the x and y coordinates as related to where the start of the icon is. So it's a repeating patern of 32 in every direction. None of the mentioned var's work with the x1 or x2 either.

The real purpose of this code is to, as you can see I've disable almost all regular movement, determine where the mouse is in relation to the player and change the direction that the player is facing according to where the mouse is clicked.

Ive tried using Click() and MouseDown(). I've not yet tried mouse up, however this will also eventually include movement only if you keep holding down the button. MouseUp is an unnacceptable substitute from the get go.

Can anyone else suggest a way to determine the x,y of the mouse pointer? I wish it was a var, or a proc that returns a value 1 at a time, that was part of the client. Like client.getx() or client.gety(). In all reality, and I'm not trying to be rude, I think it's bad programming practice that this is not currently the case because I challenge you to find a .NET, API or MFC object that do not have this feature
client
Click(O)
mob.dir=get_dir(mob,O)
In response to Jp
The problem with that is I'm adding directions so that a player can face NW, NE, SW, SE.. getting the direction doesn't help me. I need the x and y so that I can compare it to the x and y of the player. This will also allow me to cause the mouse pointer to change icons depending on the location relative to the player so that you know which way that you'll be facing when you click. Now I understand it's not incredibly possible in BYOND to get the x,y of the pointer if you do not cause an event by clicking, but if I can atleast find the X,Y now I can simply use the new pointer while it's clicked
What about:
turf/Click()
usr.Move(src)
client/Mouse_Entered(O, turf/L)
mouse_pointer_icon=new/icon('icon.dmi',"",get_dir(mob.loc,L))
In response to Peewee_RotA
If all you want is the turf-based x,y coordinates, then those are easy to get. MouseEntered() should work for what you want. MouseEntered() will return an atom of some kind if it's above one. Then you can just check the atom's x and y coordinates to see where the mouse is.
In response to Jon88
I'm trying everything and the function you mentioned doesn't return anything.

Here's what I got, what did i do wrong:

mob
icon = 'p1.dmi'
icon_state = "stand_S"

client
North()
return 0
South()
return 0
East()
return 0
West()
return 0
MouseDown(O, L)
step_on_click(L)
return

proc
step_on_click(L)
var
atom/obj1

obj1 = MouseEntered()
usr << obj1
//step_to(usr,object1,1)
return


I've also tried:
step_on_click(L)
var
atom/obj1

obj1 = MouseEntered(obj1)
usr << obj1
//step_to(usr,object1,1)
return

-----AND-----

step_on_click(L)
var
atom/obj1

MouseEntered(obj1)
usr << obj1
//step_to(usr,object1,1)
return


In response to Peewee_RotA
Your code confuses me. O.o

Something like this should work.
client
var
mousex
mousey

client
MouseEntered(atom/A, location)
if(isturf(location)) // Make sure the mouse is over the map
src.mousex = A.x
src.mousey = A.y
..()
Found solution so we can finally have a working version of this in the archives of this chat

client
North()
return 0
South()
return 0
East()
return 0
West()
return 0
MouseDown(O, turf/L)
step_on_click(L)
return

proc
step_on_click(turf/L)
usr << "[L.x] [L.y]"
return


The problem is that I didn't realize that in order to determing the data type you use the type and then the "tab" character. If you do not specify a data type it defaults to a simple string
In response to Peewee_RotA
There are <dm></dm> tags, use 'em.