• Could someone explain Droppable/Receiver please?
    2 replies, posted
I've read the two wiki pages by the same title, but can't find any further information. How does this work? What does the "string name" mean; can receivers only receive drops from droppables of the same name? I can't get any of the arguments to work either. The following is the code that does not work [CODE] --called when an inventory item is dropped to another panel local function dropped(dest, src, isdrop) debug_text("Hover from " .. src) if isdrop then debug_text("Drop from ".. src) end end icon_panel:Droppable( slot ) icon_panel:Receiver( slot, dropped() ) [/CODE]
You can't get this to work because you don't seem to understand how to code properly. I mean this: [code] icon_panel:Receiver( slot, dropped() )[/code] is not how you do it. You gotta do something like this:[code] icon_panel:Receiver( slot, dropped )[/code] Anyway, I probably should add an example on how to use this stuff to wiki. [editline]23rd February 2014[/editline] Basically, you want to apply Panel:Droppable to all your icons that should be draggable, and Panel:Receiver to all the panels that should accept those draggable panels.
This function: [CODE] --called when an inventory item is dropped to another panel local function dropped(dest, src, isdrop) if isdrop then debug_text(dest) for k,v in pairs(src) do debug_text(k) debug_text(v) end end end [/CODE] Is called by: [CODE] icon_panel:Droppable( "banana" ) icon_panel:Receiver( "banana", dropped, blank ) [/CODE] And returns: [CODE] Panel: [name:Panel][class:Panel][0,0,64,64] 1 Panel: [name:Panel][class:Panel][0,0,64,64] [/CODE] I guess a better question is - how can I 'tell' that function which panel was the source and which one was the destination? I don't understand what the point of passing the function "Panel: [name:Panel][class:Panel][0,0,64,64]" is, it contains nothing unique and seems useless [editline]24th February 2014[/editline] I think I answered my own question... I need to declare a panel name, which I can then get from the userdata passed to the function [CODE] icon_panel:SetName( astring ) [/CODE]
Sorry, you need to Log In to post a reply to this thread.