ID:146995
 
I'm coding in something, so when you drag a "testobj" onto a "circle" the "testobj" moves to the "circle"'s location.
client/mouse_pointer_icon='mousepointer.dmi' atom/mouse_drag_pointer=MOUSE_ACTIVE_POINTER mob/mouse_over_pointer=MOUSE_ACTIVE_POINTER obj mouse_over_pointer=MOUSE_ACTIVE_POINTER Circle icon='Circles.dmi' Testobj icon='TV.dmi' Click() src.MouseDrag() src.MouseDrop(/obj/Circle) src.loc=/obj/Circle

But when I do the mousedrop() part, it doesn't seem to work..Anyone know how to fix it?
FireEmblem wrote:
I'm coding in something, so when you drag a "testobj" onto a "circle" the "testobj" moves to the "circle"'s location.

You've misused MouseDrop(). This should do what you want.

client/mouse_pointer_icon='mousepointer.dmi'
atom/mouse_drag_pointer=MOUSE_ACTIVE_POINTER
mob/mouse_over_pointer=MOUSE_ACTIVE_POINTER
obj
mouse_over_pointer=MOUSE_ACTIVE_POINTER
Circle
icon='Circles.dmi'
Testobj
icon='TV.dmi'
MouseDrop(over_object,src_location,over_location)
if(istype(over_object, /obj/Circle))
src.loc = over_object
In response to Shadowdarke
Uh, now the testobj dissappears when I drag it to another circle.
In response to FireEmblem
Sorry. It's placing the testobj inside the circle obj, not in the circle's loc. Change it to this:
        MouseDrop(atom/over_object,src_location,over_location) 
if(istype(over_object, /obj/Circle))
src.loc = over_object.loc
In response to Shadowdarke
Thanks a bunch, Shadowdarke :D By the way, would it matter if the circle (and testobj) are HUD objects?
In response to FireEmblem
FireEmblem wrote:
Thanks a bunch, Shadowdarke :D

Very welcome :)

By the way, would it matter if the circle (and testobj) are HUD objects?

MouseDrop would still work the same, but you would have to make the testobj's screen_loc match the circle's, instead of their physical loc.
In response to Shadowdarke
So.. "src.screen_loc" instead of "src.loc"?
In response to FireEmblem
FireEmblem wrote:
So.. "src.screen_loc" instead of "src.loc"?

Yes. You should also make sure it is in the client's screen and probably update it's layer so that it appears on your HUD's layer.

Make sure to move the actual loc of the obj someplace else too. If you don't the item will stay on the map AND be in your HUD. If this is for a HUD inventory system, move it to the mob's contents.
In response to Shadowdarke
Uh...
src.loc = over_object.loc doesn't work.
src.screen_loc = over_object.loc doesn't work.
src.loc = over_object:screen_loc doesn't work.
src.loc = over_object.screen_loc gets an error.
src.screen_loc = over_object:screen_loc doesn't work.

Am I doing it wrong?
In response to FireEmblem
I changed over_object to an atom in the second code post. That's important. If you're using screen_loc you'll need to check it to be certain it is an atom/movable, then make an atom/movable alias to it and access screen_loc
In response to Shadowdarke
MouseDrop(atom/over_object,src_location,over_location)
if(istype(over_object, /obj/hud/circles))
src.loc = over_object.loc
In response to FireEmblem
Here is tested and verified code that will display 3 HUD Circles where you may drag and drop Testobjs. It also shows you a more efficient way to create your HUD circles than you used in Post [link]. There is no need to create multiple obj types for a single variable change.


Please examine it in detail.
#define HUD_LAYER 50
atom/mouse_drag_pointer=MOUSE_ACTIVE_POINTER
mob/mouse_over_pointer=MOUSE_ACTIVE_POINTER

client
mouse_pointer_icon='mousepointer.dmi'
New()
..()
new /obj/Circle(src, "EAST, NORTH")
new /obj/Circle(src, "EAST-1, NORTH")
new /obj/Circle(src, "EAST-2, NORTH")

obj
mouse_over_pointer=MOUSE_ACTIVE_POINTER
Circle
icon='Circles.dmi'
layer = HUD_LAYER
New(client/C, ScreenLoc)
..()
screen_loc = ScreenLoc
C.screen += src

Testobj
icon='TV.dmi'
MouseDrop(over_object,src_location,over_location)
if(istype(over_object, /obj/Circle))
var/obj/Circle/C = over_object
src.loc = usr // move into mob contents
src.screen_loc = C.screen_loc
layer = HUD_LAYER + 1 // over the circles
if(!(src in usr.client.screen))
usr.client.screen += src
In response to Shadowdarke
Woah, thanks a bundle, but now, I didn't exactly want them in the top of the screen, so I would just change them to "EAST-x" or "NORTH-y" or something, right?
In response to FireEmblem
FireEmblem wrote:
Woah, thanks a bundle

Very welcome.

I didn't exactly want them in the top of the screen, so I would just change them to "EAST-x" or "NORTH-y" or something, right?

Yes, you can move them wherever you like easily in the client/New() proc.
In response to Shadowdarke
You are my hero...again.

But now, how would I be able to put an item on the circle AND put it in usr.contents at the same time?
In response to FireEmblem
Uh...bump? <_<;
In response to FireEmblem
Look at [link]. I'm not sure if he edited it for you or you just didn't notice, but it is being put in your contents at the same time it is being put in your screen. =)
In response to YMIHere
YMIHere wrote:
Look at [link]. I'm not sure if he edited it for you or you just didn't notice, but it is being put in your contents at the same time it is being put in your screen. =)

No edit. It was there from the beginning. ;)

FireEmblem wrote:
But now, how would I be able to put an item on the circle AND put it in usr.contents at the same time?

As YMIHere pointed out, the snippet I posted already does that.

loc and screen_loc are independant of each other. You could display an obj on the map and in the HUD if you wanted. In that snippet, the obj.loc is set to the mob, placing it in mob.contents. At the same time, it adds it to client.screen and makes the screen_loc match the circle's. All you see on the HUD circle is a display of it, when it is actually in your contents.
In response to Shadowdarke
What I meant was, like, using a "get" verb, or something, and making the object appearing in usr.contents and a blank circle.
In response to FireEmblem
<_<; Bump? I need ze ansoh! X_X
Page: 1 2