ID:2257538
 
(See the best response by Kaiochao.)
Code:
obj
HUD
var
client/client
mousefade = 0
ppx
ppy
New(client/c,px,py,f, mob/Combative/Player/M)
..()
client = c
screen_loc = "[px],[py]"
client.screen += src
ppx = px
ppy = py

if(f)
alpha = 0
mousefade = 1
animate(src,alpha=200,10)
SKILLCARDS
SELECTED_SKILL
icon = 'Selected.dmi'
layer = MOB_LAYER + 100
New(client/c,loc)
..()
client = c
screen_loc = loc
client.screen += src
BLANK_SKILLCARD
icon = 'BlankSkill.dmi'
layer = MOB_LAYER + 98
var
selected = FALSE
number
New(client/c,n,px,py)
..()
var
ppx = px+1
ppy = py+1
pppy = py-1
nn = n+1
client = c
screen_loc = "[px]:16,[py]:16"
client.screen += src
number = n
mousefade = 1
alpha = 175
if(number <= 9)
if(number/2 == round(number/2))
new/obj/HUD/SKILLCARDS/BLANK_SKILLCARD(client,nn,ppx,ppy)
else
new/obj/HUD/SKILLCARDS/BLANK_SKILLCARD(client,nn,ppx,pppy)
sleep(TICK)


Problem description:
So I haven't been able to wrap my head around how to make it so I can drop and drag GUIs into this, it's like one of the only things left to mess around with until my games pretty much ready for some testing and I figured I'd see if someone could help me xD

My skills are all under obj/GUI/ I don't really know how to make it so I can drag them either :/ so yeah I'm a bit stuck xD
MouseDrag()
MouseDrop()


Would be a good place to start
In response to Ssj4justdale
Ssj4justdale wrote:
> MouseDrag()
> MouseDrop()
>

Would be a good place to start

I've read the help on dm about them but like how would I implicate them that's what I was wondering
In response to Gold94
Best response
In general, this is how overriding procs works:
1. Go to the type that you want to modify the behavior of. In your case, you want the type of the thing that can be dragged and dropped; the skill obj.
2. Type the name of the proc followed by the arguments that are defined for it. You want MouseDrop because you want to modify what happens when the skill obj is dropped after being dragged. It has a lot of arguments because there is a lot of information provided about the event that you can use.
3. Add the code that should run when this proc is called. Usually you want to call ..() at some point so that the previous definition runs, but that's up to you.

whatever_your_skill_type_is

// Copy/pasted straight out of the DM reference.
// When you override a proc, this is the part that you don't change, so copy/paste is OK.
MouseDrop(over_object, src_location, over_location, src_control, over_control, params)

// src is the object that was dropped (the skill)
// usr is the mob that did the mouse-drop.
// over_object is the object under the mouse pointer (the hotbar, possibly)
// you probably don't need to use the other arguments

// This is what happens when this object is mouse-dropped:

// Check if the object under the mouse pointer is a hotbar object:
if(istype(over_object, /obj/GUI/whatever_the_slot_type_is))

// Do something, for example:
usr << "Dropped [src] onto slot [over_object]"
In response to Kaiochao
Kaiochao wrote:
In general, this is how overriding procs works:
1. Go to the type that you want to modify the behavior of. In your case, you want the type of the thing that can be dragged and dropped; the skill obj.
2. Type the name of the proc followed by the arguments that are defined for it. You want MouseDrop because you want to modify what happens when the skill obj is dropped after being dragged. It has a lot of arguments because there is a lot of information provided about the event that you can use.
3. Add the code that should run when this proc is called. Usually you want to call ..() at some point so that the previous definition runs, but that's up to you.

> whatever_your_skill_type_is
>
> // Copy/pasted straight out of the DM reference.
> // When you override a proc, this is the part that you don't change, so copy/paste is OK.
> MouseDrop(over_object, src_location, over_location, src_control, over_control, params)
>
> // src is the object that was dropped (the skill)
> // usr is the mob that did the mouse-drop.
> // over_object is the object under the mouse pointer (the hotbar, possibly)
> // you probably don't need to use the other arguments
>
> // This is what happens when this object is mouse-dropped:
>
> // Check if the object under the mouse pointer is a hotbar object:
> if(istype(over_object, /obj/GUI/whatever_the_slot_type_is))
>
> // Do something, for example:
> usr << "Dropped [src] onto slot [over_object]"
>


Thank you so much this has made it so much easier, I appreciate it
Just because I was bored and was typing this out as I go.
Note: Hasn't been tested.

//Below is so we have some skills to choose and drag from
var/list/available_skills = newlist(/skill_system/skills/H1,/skill_system/skills/H2,/skill_system/skills/H3,/skill_system/skills/H4);

//our datum to handle our skills
skill_system //the datum name
parent_type=/obj; //inherit object's crap
var //initialize a variable
_skill; //called _skill, so we can execute this skill later.
skill_card //path_type for our skill_cards/placeholder for our skills
var //define a variable
_slot; //to say which slot it is in our hotbar
New(_numeroSloto) //when the placeholder is created
_slot = _numeroSloto; //set the slot to _numeroSloto defined
..(); //and do built-in shit
proc //to define a function
execute(_player) //called execute with an argument which would be the player
if(hascall(_player,_skill)) //just to maker sure the player acually can call this skill
call(_player,_skill)(); //execute the skill that has been defined
skills //just a path_type to define our skills
H1 _skill = "Say1"; //H1 will execute Say1
H2 _skill = "Say2"; //H2 will execute Say2
H3 _skill = "Say3"; //H3 will execute Say3
H4 _skill = "Say4"; //H4 will execute Say4

client //our client datum
MouseDrag(object2drag,objectHoveringLoc) //to handle dragging objects
if((istype(object2drag,/skill_system/skills))) //check if it is indeed a skill
mouse_pointer_icon = icon(object2drag:icon,object2drag:icon_state); //set the mouse icon to the icon to show we are dragging it
MouseDrop(objectBeingDragged,DroppedLoc) //once we drop this crap
mouse_pointer_icon = initial(mouse_pointer_icon); //reset our pointer icon
if((istype(objectBeingDragged,/skill_system/skills))) //if the item being dragged is indeed a skill
if((istype(DroppedLoc,/skill_system/skill_card))) //and we are dropping it on the skill_card placeHolder
DroppedLoc:icon_state = objectBeingDragged:icon_state; //make the placeholder look like the skill
DroppedLoc:_skill = objectBeingDragged:_skill; //set the skill so when we try to execute it, it will execute correctly
if((istype(objectBeingDragged,/skill_system/skill_card))) //if it is a placeholder that we are dragging
objectBeingDragged:_skill = null; //just remove the skill, you can set this to change the skill location, swap etc
//if the droppedLoc is indeed a skill_card placeholder shit as well


mob //just for demo purposes
Login() //once the player logs in
hotbar = new(max_hotbar_slots) //we will create them a hotbar
var/skill_system/skill_card/my_hotbar; //a placeholder to say which skill we are altering
for(var/i in 1 to max_hotbar_slots) //so for every slot within our hotbar we will...
my_hotbar = new/skill_system/skill_card(i); //create a new hotbar object/skill_card place Holder
my_hotbar.screen_loc = "[i]+2,SOUTH"; //set its position on the screen
hotbar[i] = my_hotbar; //make it so our hotbar and slots are associated with it
client.screen += my_hotbar; //and then finally apply it to our screen

var/list/hotbar[] //just the variable for our hotbar
var/max_hotbar_slots = 4 //how many slots you want your hotbar to handle

verb //obviously a command definiton
Skill1() //First Skill
if(!hotbar[1])return; //If no object is there, don't do shit.
var/skill_system/skill_card/my_skill = hotbar[1]; //set our object to execute a command...
my_skill.execute(src); //execute this shit..
Skill2() //rinse
if(!hotbar[2])return; //and
var/skill_system/skill_card/my_skill = hotbar[2]; //repeat
my_skill.execute(src); //above
Skill3() //rinse
if(!hotbar[3])return; //and
var/skill_system/skill_card/my_skill = hotbar[3]; //repeat
my_skill.execute(src); //above
Skill4() //rinse
if(!hotbar[4])return; //and
var/skill_system/skill_card/my_skill = hotbar[4]; //repeat
my_skill.execute(src); //above
Say1() //our first skill
set hidden = TRUE; //dont want players to see this
world<<"Say1 Executed"; //our actions for executing the skill
Say2() //rinse
set hidden = TRUE; //and
world<<"Say2 Executed"; //repeat
Say3() //rinse
set hidden = TRUE; //and
world<<"Say3 Executed"; //repeat
Say4() //rinse
set hidden = TRUE; //and
world<<"Say4 Executed"; //repeat
You could probably make the Skill1, Skill2, Skill3 verbs a single command that takes an argument.

mob/verb/Skill(slot as num)
if(!skill) return
if(hotbar[slot])
var/skill_system/skill_card/my_skill = hotbar[slot]
if(my_skill) my_skill.execute(src)
In response to Nadrew
Nadrew wrote:
You could probably make the Skill1, Skill2, Skill3 verbs a single command that takes an argument.

> mob/verb/Skill(slot as num)
> if(!skill) return
> if(hotbar[slot])
> var/skill_system/skill_card/my_skill = hotbar[slot]
> if(my_skill) my_skill.execute(src)
>


Even Better xD