Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I find inventory slots next to one i'm hovering?

Asked by
Fatul 9
4 years ago
Edited 4 years ago

I can't even wrap my head around it because i'm not sure where to start the math.

An explanation will be enough, no need to show anything.

This is my starting code(if you're curious, nothing right now though), what i'm trying to do is a path of exile/diablo style inventory.

--Services
local RunService = game:GetService("RunService")
--Variables
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
--Inv

local slots = script.Parent.Slots
local getSlots = slots:GetChildren()
    local mouseSizeX = 1
    local mouseSizeY = 1
    local columns = 12
    local rows = 5
    local pickup = script.Parent.Parent.Pickup
        local pickupX = pickup.SizeX.Value
        local pickupY = pickup.SizeY.Value
        local modifiers = pickup.Modifiers

local items = script.Parent.Items
local characterUI = script.Parent.Character

mouse.Move:Connect(function()
    for i = 1, #getSlots do
        if getSlots[i].ClassName ~= "UIGridLayout" then
            getSlots[i].MouseEnter:Connect(function()
                if pickupX > 1 or pickupY > 1 then
                    mouseSizeX = pickupX
                    mouseSizeY = pickupY
                elseif pickupX == 1 and pickupY == 1 then
                    mouseSizeX = 1
                    mouseSizeY = 1
                end
                getSlots[i].ImageColor3 = Color3.fromRGB(225,225,225)
                if getSlots[i].ImageColor3 == Color3.fromRGB(225,225,225) then
                    --34Y difference in each slot
                    --34.5X to 34.6X difference in each slot
                    print(getSlots[i].AbsolutePosition)


                end
            end)
            getSlots[i].MouseLeave:Connect(function()
                getSlots[i].ImageColor3 = Color3.fromRGB(255,255,255)
            end)
        end
    end
end)

Answer this question