No sadly there is not full console support yet, though it is going to come in a future update. If you enable the virtual cursor it might work.
I use canvasgroups for each item but even when I dont it doesnt seem to make a difference on highlight
Sorry, I forgot about your reply. Have you changed the slot assets in any way? You donât need any configuration to have highlights working. You just need to create a grid and an item.
Hey, Iâm not sure if this has been asked before, but does anyone know how to loop through the available grid spots to try and find a spot for the item if the one itâs trying to place itself to isnât available when you use the createItem function? Because right now itâs really annoying if I forgot to move an item out of the starting position and it just eats the item.
local function CreateItem(ReplicatedItem)
local ItemFrame
local Size = ReplicatedItem:GetAttribute("Size")
local Item = GridPack.createItem({
Position = Vector2.new(0, 0),
Size = Size,
Assets = {
Item = game:GetService("ReplicatedStorage"):WaitForChild("ItemElement"),
},
Metadata = {
-- Here you are free to store any values you want.
},
})
Items[ReplicatedItem] = Item
local ItemFrame
ScreenGui:WaitForChild("Background").ChildAdded:Connect(function(Child)
if Child and Child.Name == "ItemElement" then
ItemFrame = Child
end
end)
Grid:AddItem(Item)
repeat task.wait() until ItemFrame
ItemFrame:WaitForChild("Item").Value = ReplicatedItem
local Item = ReplicatedItem:Clone()
Item.PrimaryPart.Anchored = true
Item:SetPrimaryPartCFrame(Item:GetAttribute("ViewportCFrame"))
Item.Parent = ItemFrame:WaitForChild("ViewportFrame")
end
My function if anyone can help or if this even helps anyone else.
Use pcalls to see if the item adding failed. And to get an empty position for the item use Grid:GetNextFreePositionForItem()
.
Sorry, silly question, but Iâve never really used pcalls before. Iâve attempted to use this, but it doesnât seem to work, so how do they work in this case?
local Success, Item = pcall(function()
return GridPack.createItem({
Position = Vector2.new(0, 0),
Size = Size,
Assets = {
Item = game:GetService("ReplicatedStorage"):WaitForChild("ItemElement"),
},
Metadata = {}
})
end)
if not Success or not Item then
print("Error")
return
end
It still prints âSuccessâ as true even when it errors.
(Also how do you even use GridGetNextFreePositionForItem? Iâve tried doing Position = Grid:GetNextFreePositionForItem()
, however that obviously didnât work, but funnily enough that did trigger the pcall)
Mythaman found a fix
Iâm not really sure what this is supposed to fix, as my problem is regarding the Grid:AddItem() function and not the Item.new function. I replaced it anyway, however it still doesnât catch the error.
Yeahhh, sorry, yâall, I was up for ~24 hours at that point and was not thinking clearly, lol. I fixed it the main issues by just setting the item position to the next free position via Item.Position = Grid:GetNextFreePositionForItem(Item)
Btw pcalls are used for error handling so if any of the lines fail then the pcall returns success = false and an error message so for example:
-- this pcall will always return an error message
local success, errorMessageOrReturn = pcall(function()
error("example error message")
end)
-- this pcall will always return "example value"
local success, errorMessageOrReturn = pcall(function()
return "example value"
end)
-- put this under the pcalls to handle the errors
if success == false then
print(errorMessageOrReturn) -- always prints error message because it failed (in this case "example error message")
else
print(errorMessageOrReturn) -- always prints the thing you returned in the pcall (in this case "example value")
end
Pcalls are often used in things like data stores since Robloxâs data store api doesnât always work since the servers might be down or slow.
As in the slots in the grid, I dont believe I have. Only thing I have done is in the script the transferlink gets enabled and disabled and the grid frame gets visible turned on and off
The only thing that I think you could be doing wrong is turning the visibility on and off. You should be using ItemManager:SetVisibility()
instead of ItemManager.GuiElement.Visible
. So switch to that if youâre not using it.
Highlights should be working out of the box, you just need to create a grid and an item, no configuration needed.