ID:1696432
 
Code:
mob/var
slot1taken=0
slot1source
slot2taken=0
slot2source
slot3taken=0
slot3source
slot4taken=0
slot4source
slot5taken=0
slot5source
slot6taken=0
slot6source
obj/techniques
MouseDrop(var/X)
if(src==X)return
if(istype(X,/obj/techniques/Skill_Slot) || istype(X,/obj/techniques))
var/obj/Y = X
if(Y.screen_loc=="10,4")
if(usr.slot1taken==1)
Y.overlays = 0
Y.overlays -= usr.slot1source
usr.client.screen -= usr.slot1source
usr.SkillSlot["SkillSlot[Y:slot_num]"]=null
usr.slot1taken=0
usr.slot1source = null
Y.overlays = 0
Y.overlays += src
src.screen_loc=Y.screen_loc
usr.client.screen += src
usr.SkillSlot["SkillSlot[Y:slot_num]"]=src
usr <<output( "Re-loaded [Y] with [src]","chatoutput")
usr.slot1taken=1
usr.slot1source = src
return
else
Y.overlays = 0
Y.overlays += src
src.screen_loc=Y.screen_loc
usr.client.screen += src
usr.SkillSlot["SkillSlot[Y:slot_num]"]=src
usr <<output( "Placed [src] on [Y]","chatoutput")
usr.slot1taken=1
usr.slot1source = src
if(Y.screen_loc=="11,4")
if(usr.slot2taken==1)
Y.overlays = 0
Y.overlays -= usr.slot2source
usr.client.screen -= usr.slot2source
usr.SkillSlot["SkillSlot[Y:slot_num]"]=null
usr.slot2taken=0
usr.slot2source = null
Y.overlays = 0
Y.overlays += src
src.screen_loc=Y.screen_loc
usr.client.screen += src
usr.SkillSlot["SkillSlot[Y:slot_num]"]=src
usr <<output( "Re-loaded [Y] with [src]","chatoutput")
usr.slot2taken=1
usr.slot2source = src
return
else
Y.overlays = 0
Y.overlays += src
src.screen_loc=Y.screen_loc
usr.client.screen += src
usr.SkillSlot["SkillSlot[Y:slot_num]"]=src
usr <<output( "Placed [src] on [Y]","chatoutput")
usr.slot2taken=1
usr.slot2source = src
if(Y.screen_loc=="12,4")
if(usr.slot3taken==1)
Y.overlays = 0
Y.overlays -= usr.slot3source
usr.client.screen -= usr.slot3source
usr.SkillSlot["SkillSlot[Y:slot_num]"]=null
usr.slot3taken=0
usr.slot3source = null
Y.overlays = 0
Y.overlays += src
src.screen_loc=Y.screen_loc
usr.client.screen += src
usr.SkillSlot["SkillSlot[Y:slot_num]"]=src
usr <<output( "Re-loaded [Y] with [src]","chatoutput")
usr.slot3taken=1
usr.slot3source = src
return
else
Y.overlays = 0
Y.overlays += src
src.screen_loc=Y.screen_loc
usr.client.screen += src
usr.SkillSlot["SkillSlot[Y:slot_num]"]=src
usr <<output( "Placed [src] on [Y]","chatoutput")
usr.slot3taken=1
usr.slot3source = src
if(Y.screen_loc=="13,4")
if(usr.slot4taken==1)
Y.overlays = 0
Y.overlays -= usr.slot4source
usr.client.screen -= usr.slot4source
usr.SkillSlot["SkillSlot[Y:slot_num]"]=null
usr.slot4taken=0
usr.slot4source = null
Y.overlays = 0
Y.overlays += src
src.screen_loc=Y.screen_loc
usr.client.screen += src
usr.SkillSlot["SkillSlot[Y:slot_num]"]=src
usr <<output( "Re-loaded [Y] with [src]","chatoutput")
usr.slot4taken=1
usr.slot4source = src
return
else
Y.overlays = 0
Y.overlays += src
src.screen_loc=Y.screen_loc
usr.client.screen += src
usr.SkillSlot["SkillSlot[Y:slot_num]"]=src
usr <<output( "Placed [src] on [Y]","chatoutput")
usr.slot4taken=1
usr.slot4source = src
if(Y.screen_loc=="14,4")
if(usr.slot5taken==1)
Y.overlays = 0
Y.overlays -= usr.slot5source
usr.client.screen -= usr.slot5source
usr.SkillSlot["SkillSlot[Y:slot_num]"]=null
usr.slot5taken=0
usr.slot5source = null
Y.overlays = 0
Y.overlays += src
src.screen_loc=Y.screen_loc
usr.client.screen += src
usr.SkillSlot["SkillSlot[Y:slot_num]"]=src
usr <<output( "Re-loaded [Y] with [src]","chatoutput")
usr.slot5taken=1
usr.slot5source = src
return
else
Y.overlays = 0
Y.overlays += src
src.screen_loc=Y.screen_loc
usr.client.screen += src
usr.SkillSlot["SkillSlot[Y:slot_num]"]=src
usr <<output( "Placed [src] on [Y]","chatoutput")
usr.slot5taken=1
usr.slot5source = src
if(Y.screen_loc=="15,4")
if(usr.slot6taken==1)
Y.overlays = 0
Y.overlays -= usr.slot6source
usr.client.screen -= usr.slot6source
usr.SkillSlot["SkillSlot[Y:slot_num]"]=null
usr.slot6taken=0
usr.slot6source = null
Y.overlays = 0
Y.overlays += src
src.screen_loc=Y.screen_loc
usr.client.screen += src
usr.SkillSlot["SkillSlot[Y:slot_num]"]=src
usr <<output( "Re-loaded [Y] with [src]","chatoutput")
usr.slot6taken=1
usr.slot6source = src
return
else
Y.overlays = 0
Y.overlays += src
src.screen_loc=Y.screen_loc
usr.client.screen += src
usr.SkillSlot["SkillSlot[Y:slot_num]"]=src
usr <<output( "Placed [src] on [Y]","chatoutput")
usr.slot6taken=1
usr.slot6source = src





Skill_Slot
icon = 'Skills.dmi'
icon_state = "blank"
layer = 20
var/slot_num = 0


One
New(client/C)
screen_loc = "10,4"
slot_num = 1
if(C)C.screen += src
Two
New(client/C)
screen_loc = "11,4"
slot_num = 2
if(C)C.screen += src
Three
New(client/C)
screen_loc = "12,4"
slot_num = 3
if(C)C.screen += src
Four
New(client/C)
screen_loc = "13,4"
slot_num = 4
if(C)C.screen += src
Five
New(client/C)
screen_loc = "14,4"
slot_num = 5
if(C)C.screen += src
Six
New(client/C)
screen_loc = "15,4"
slot_num = 6
if(C)C.screen += src

mob/proc/skilltest()
usr << "[usr.SkillSlot["SkillSlot1"]]"


mob/var/SkillSlot = list("SkillSlot1"=null,"SkillSlot2"=null,"SkillSlot3"=null,"SkillSlot4"=null,"SkillSlot5"=null,"SkillSlot6"=null)

mob/var/HUD = list()
mob/var/hotkeys_loaded = 0

mob/proc/load_slots()
if(src.hotkeys_loaded||!usr||!usr.client)return
var/obj/x = new/obj/techniques/Skill_Slot(usr.client)
usr.HUD += x
usr.hotkeys_loaded = 1


mob/verb
slot1()
set hidden = 1
for(var/obj/x in usr.client.screen)
if(x && x.screen_loc == "10,4")
x.Click()

slot2()
set hidden = 1

for(var/obj/x in usr.client.screen)
if(x && x.screen_loc == "11,4")
x.Click()
slot3()
set hidden = 1

for(var/obj/x in usr.client.screen)
if(x && x.screen_loc == "12,4")
x.Click()
slot4()
set hidden = 1

for(var/obj/x in usr.client.screen)
if(x && x.screen_loc == "13,4")
x.Click()

slot5()
set hidden = 1

for(var/obj/x in usr.client.screen)
if(x && x.screen_loc == "14,4")
x.Click()
slot6()
set hidden = 1

for(var/obj/x in usr.client.screen)
if(x && x.screen_loc == "15,4")
x.Click()


Problem description:
So, You can drag the same skill into a different hotkey and have the command run on two separate macros, don't know if thats a big issue, but id like to restrict that, and then you can literally drag one hotkey slot into the next, thus eliminating hotkey slot 1 and having slot 1 on top of slot 2. If you need a picture let me know!
... so what's your How-To question? Sounds more like a demo :P

Could be optimized though. Here are some of my questions to you:
1. Why not use a /list with a defined size instead of those variables? Esp. since you use one for SkillSlot[].
Why do you have SkillSlot[] defined when slotNsource ontains the skills?

2. Why do you have to define BOTH slotNtaken and slotNsource (N = number)? You only need one defined as you can do:
if(slotNsource) which translate to if(slotNsource != FALSE/0/null/""


I'm sure I can tare some more things in to it (such as why not just up an algorithm to check if the screen_loc is within a certain X,Y value and set which slot to look based on X-9) ... but I'm feeling rather lazy right now.
My question was how can I prevent someone from actually dragging one of my hotkey boxes into the other.

And I appreciate your help. Ill try and mess around with the ideas that you brought up. and post if I fix it.
Ah sorry, I missed that part.

You can always check if the object already exists in a hotkey slot then either prevent it or, if you wished to, swap it.

It would be easier to do it if it was a /list containing the skills but we can still check with the variable you have:
//  src = the object that has been dragged
var
OldSlot = 0 // Doing /list.Find() would have been easier or having a variable in the skill to set the value for the slot it is in. But there's an alternative since we don't have these
NewSlot = src.New_ScreenLoc.X - 9 // Parse X,Y for screen_loc, X - 9 of the position so we can find which slot it goes in (1-6)

for(var/i = 1 to 6) // Loop through the 6 slots
if(i == NewSlot) continue // Skip the new slot location
if(src == src.vars["slot[i]sources"]) // As soon as we find the slot the src is in
OldSlot = i
break // Get out of this loop

if(!OldSlot) // A slot was not found
if(NewSlot == src) // We should check if the NewSlot is the object we dragged (since we skipped it in the example above)
return // If it is in the NewSlot, we'll stop it from doing anything

// Since the above was returned, we do not need to do an else to it
src.Set_Slot(NewSlot)

else // if there was an OldLoc found
if(NewSlot)
Swap_slots(OldLoc, NewLoc)
else
src.Slot= NewSlot
OldSlot = null