|
| 15 Dec 2014 04:19 PM |
So I've made a basic inventory system set up, and I have everything I would need as of now done, except for one important feature. I need to find a way to drag items in one slow into a different slot.
Any ideas on how to do this? I know that I would need .MouseButton1Down events and such and the draggable property set to true, but how would I actually go about doing this?
If you would like to see the inventory; http://www.roblox.com/Inventory-System-place?id=186778639 |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 04:24 PM |
| http://wiki.roblox.com/index.php?title=API:Class/Mouse |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 04:26 PM |
| No, that wouldnt help, and I already know what the mouse is. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 15 Dec 2014 04:29 PM |
Mouse down >> move to mouse position every frame Mouse up >> Snap to grid position (math.floor(Pos/scale+0.5)*scale), check a table for items in grid position, handle event. |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 04:35 PM |
| How would I snap it if every square is 75x75 pixels and has a spacing of 7 pixels? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 15 Dec 2014 04:39 PM |
| Scale is 82 then isn't it. Just snap it to (math.floor((Pos/82)+0.5)*82)-7 (or -3.5 or something) |
|
|
| Report Abuse |
|
|
|
| 15 Dec 2014 04:39 PM |
| Im using offset, not scale |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 15 Dec 2014 04:44 PM |
I didn't mean that kind of scale...
Also I was silly. It's actually
local grid = math.floor((Pos/82)+0.5) return (grid*82)-((grid-1)*7)-3.5 |
|
|
| Report Abuse |
|
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 15 Dec 2014 04:54 PM |
| Eh whatever I'm tired I can't validate it in my head for some reason it's one of those two or some variation of |
|
|
| Report Abuse |
|
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 15 Dec 2014 04:59 PM |
| Remember you'll have to do it for X and Y offsets individually |
|
|
| Report Abuse |
|
|