ID:147587
 
I'm trying to make a drag 'n drop inventory placement system (which in retrospect seemed simple at the time), but of course I'm having problems, or I wouldn't be pleading for help, no?
        Pogga
icon = 'Cards.dmi'
icon_state = "card"
cardname = "Pogga"
suffix = "Rare"
mouse_drag_pointer = 'carddrag.dmi'
MouseDrop(src)
return
MouseDrop(obj/Cards/Card_Box)
var/obj/Cards/Card_Box/B
src.loc = B
B.icon_state = "fullbox"
B.numcards++
B.suffix = "[B.numcards] card(s)"
Enigmaster2002 wrote:
I'm trying to make a drag 'n drop inventory placement system (which in retrospect seemed simple at the time), but of course I'm having problems, or I wouldn't be pleading for help, no?
>       Pogga
> icon = 'Cards.dmi'
> icon_state = "card"
> cardname = "Pogga"
> suffix = "Rare"
> mouse_drag_pointer = 'carddrag.dmi'
> MouseDrop(src)
> return
> MouseDrop(obj/Cards/Card_Box)
> var/obj/Cards/Card_Box/B
> src.loc = B
> B.icon_state = "fullbox"
> B.numcards++
> B.suffix = "[B.numcards] card(s)"
>

I will assume you are trying to drag a card onto the Card_Box object and have it moved there. If so, there are a few problems with that code.

1) The MouseDrop(src)return is not what you want. That may actually hinder your attempts as it returns before your other MouseDrop code is called.
2) You have an extra Card_Box reference variable, you only need the parameter one.
3) The parameter variable mentioned in 2 is not a variable of type /obj/Cards/Card_Box, it is a variable of type /obj/Cards and the variable is called Card_Box, at least when done that way.

Solution...
Take out the first version of MouseDrop.
Delete this line:
var/obj/Cards/Card_Box/B

And change this line:
MouseDrop(obj/Cards/Card_Box)

To this:
MouseDrop(obj/Cards/Card_Box/B)


So then you have...
        Pogga
icon = 'Cards.dmi'
icon_state = "card"
cardname = "Pogga"
suffix = "Rare"
mouse_drag_pointer = 'carddrag.dmi'
MouseDrop(obj/Cards/Card_Box/B)
src.loc = B
B.icon_state = "fullbox"
B.numcards++
B.suffix = "[B.numcards] card(s)"
In response to Loduwijk (#1)
Alright, that fixes my inital problem. Many thanks.
Now, as to the next one; if I were to drop the Pogga card onto another card, it places it in the other card's contents, and I obviously don't want that to happen. Also, is there any way I could only allow this kind of action within an inventory panel and not while the card is lying on the map?
For some reason, the mouse events confuse me to no end.
In response to Enigmaster2002 (#2)
Enigmaster2002 wrote:
Alright, that fixes my inital problem. Many thanks.
Now, as to the next one; if I were to drop the Pogga card onto another card, it places it in the other card's contents, and I obviously don't want that to happen. Also, is there any way I could only allow this kind of action within an inventory panel and not while the card is lying on the map?
For some reason, the mouse events confuse me to no end.

Well, if they confuse you, try not to think of them as Mouse events. Basically what you're doing here is a Move() proc type thing, so perhaps it would help if you were to think of it in a manner as such. But breaking down the code into what you're actually trying to accomplish, and what it takes to do so, not just the result, seems to help me somewhat.

Now, I've never messed with Mouse events myself, but I'm pretty sure that to keep it out of the other cards contents, you wouldn't even need to use the Mouse events, you would just use the Enter() or Entered() proc for a card; overrride the parent to keep it from allowing other cards in it.
In response to Enigmaster2002 (#2)
            MouseDrop(obj/Cards/Card_Box/B)

That isn't restricting what the proc is being called for. All it is doing is saying "Okay, we're dropping this thing on an obj/Cards/Card_Box, and we'll call it B. No, shut up, Johnson, I don't CARE if that's not what we're dropping it on!" You've told it what the variable will be, but that won't restrict anything. You'll need an istype() check in there:
if(istype(B))