ID:274015
 
I can't remember if I know how to do this already or not. I might just be having a brain meltdown...

If I've sent an obj to a grid usingoutput, is there a way for me to use winget() or something like that to return what control ID they've been outputted to?
As far as I know, no.

The skin reference says that although you can output objects to grids, you should always store a reference to that object. I think that's mainly because you can have a grid display a non-existent (deleted) object, but it might mean something to you.
In response to Kaiochao
Well, my issue is 2-fold regarding a drag and drop system.
If I'm speedy enough (offline) I can cause 1 of 2 bugs; ONLINE this would be a synch.

Basically, if I drag and drop my objs from grid to grid fast enough, I either get multiples of the same obj (at the expense of another object, usually).
Or I have 2 objs in the same grid (and obviously only one is displayed).

If I could winget() their control_id each time theyre dropped into a grid, I could check that against a stored variable.


I'll put my drag and drop code in below just in case i've been too confusing.
Apologies in advance, it's my first drag and drop attempt, and I haven't got it running quite right yet, so I havent dared go back and refine it...

obj/SkillCards
icon='Card_Icons.dmi'
MouseDrop(over_object=src,src_location,over_location, src_control,over_control,params)
if((src in usr.contents) && ((findtext("[src_control]","AllJutsu"))||(findtext("[src_control]","Hotbar")))&&((findtext("[over_control]","AllJutsu"))||(findtext("[over_control]","Hotbar")))&&(src_control!=over_control))
if(!src.slot) src.slot=new()
if(IsHotBar(over_control))
var/l=IsHotBar(src_control,src.slot["HotBar"],src.slot[usr.JutsuBrowse])
var/end="[over_control]"
if(IsHotBar(src_control))
var/obj/PlaceHolder/bg=locate(/obj/PlaceHolder) in usr.contents
usr << output(bg,src_control)
else
usr << output(null,src_control) //empty original slot
usr << output(src,over_control) //place in new slot
end = copytext(end,12)
if(IsHotBar(src_control)) usr.deleteHotbarBind(l,src)
usr.onSwitch_SendBindInfo(src, end)
src.slot["HotBar"]=end
src.overlays=null; src.OnHotBar=1
src.slot[usr.JutsuBrowse]=null
src.LoseSlots()
if(!(src in usr.HotBarSkills)) usr.HotBarSkills+=src

//If theres something in the way...
for(var/obj/SkillCards/o in usr.contents)
if((o==src)||(o.slot["HotBar"]==null)) continue
if(o.slot["HotBar"]==src.slot["HotBar"])
usr << output(o,src_control)
if(IsHotBar(src_control))
usr.onSwitch_SendBindInfo(o, l)
o.slot["HotBar"]=l; o.OnHotBar=1
else
usr.HotBarSkills-=o
o.slot["HotBar"]=null; o.OnHotBar=0
o.slot[usr.JutsuBrowse]=l

else //if putting in main window
if((CanPlaceCard(src,usr))||!(IsHotBar(src_control)))
var/l=IsHotBar(src_control,src.slot["HotBar"],src.slot[usr.JutsuBrowse])
var/end="[over_control]"
if(IsHotBar(src_control))
var/obj/PlaceHolder/bg=locate(/obj/PlaceHolder) in usr.contents
usr << output(bg,src_control)
else
usr << output(null,src_control) //empty original slot
usr << output(src,over_control) //place in new slot
end = copytext(end,10)
if(istext(end)) end=text2num(end)
src.slot[usr.JutsuBrowse]=end; src.slot["HotBar"]=null
src.OnHotBar=0
if(src in usr.HotBarSkills) usr.HotBarSkills-=src
for(var/obj/SkillCards/o in usr.contents)
if((o==src)||(o.slot[usr.JutsuBrowse]==null))
continue
if(o.slot[usr.JutsuBrowse]==src.slot[usr.JutsuBrowse])
usr << output(o,src_control)
if(istext(l)) l=text2num(l)
if(IsHotBar(src_control))
o.overlays=null
o.slot["HotBar"]=l; o.OnHotBar=1
o.slot[usr.JutsuBrowse]=null
usr.HotBarSkills+=o
else
o.OnHotBar=0
o.slot[usr.JutsuBrowse]=l
In response to Saucepan Man
Your best bet is going to be parsing over_control to get the cell it's in and store that on the /obj itself for later reference.
In response to Audeuro
That's exactly what I'm doing with:
src.slot["hotbar"] = end
Where 'end' is a variable derrived from over_control

The problem is, if I'm too fast, it either doubles the obj or puts two different ones on the same grid.
If I'm able to do this in offline testing, then players will most certainly do it frequently in an online environment.

I've given up on trying to "beat the interface" for speed. Instead I'm looking to call a proc at the end of each MouseDrop() to check for errors.

If I could ask the code: "Is this obj's slot variable the same as it's control_id? If not, refresh the whole lot to fix it"

~ I'd rather focus on the specific errors each time, if I can, and fix THOSE.
Failing that, I only want to refresh all of them if there's an issue. There's no point in putting a load on the server if I don't have to. No matter how small.
In response to Saucepan Man
obj/MouseDrop()
if(usr.CanDragNDrop)
usr.CanDragNDrop=0; spawn(10) usr.CanDragNDrop=1
//dostuff

Not really what I'd like. But it's all I can think of.
In response to Saucepan Man
This is a classic problem like has been also seen with people not verifying that the object is actually still there when they use 'set' statements. Did you try winget()'ing the hotbar control before you clear or do anything as a sanity check?
In response to Audeuro
Off cuff, I'm not sure.
My entire relevant code is a couple posts up o_O
It's basically the same twice, so you could focus on the top half?
bottom half is for placing in a second window.
Fixing one half means I can fix both.