GridPack - Create Grid/Tetris Style Inventories

Use Grid:SetVisibility() instead, this will also change the items.

Edit: Nevermind. I figured it out. There isnt a ā€œAutocompleteā€ so i thought i was doing it on the wrong thing.

My bad.

Sorry to add more errors, but when you try and move an item thatā€™s too big for a grid into it, the game freaks out.

1 Like

Yes, this is a bug! Please report it on the GitHub issues page so that I and others can track it easily. Thanks!

Ok!

Iā€™ve tried to fix this with ChatGPT many times, but I guess this bug is a little more complicated than that :sweat_smile:. In the mean time Iā€™ll try and find a temporary fix for myself, but let me know when itā€™s fixed!

I might use that for my game, I like thatā€¦

1 Like

Is there a Roblox model for this?

Yes! Follow the tutorial on the docs website to get it: Getting Started | GridPack

1 Like

Is there a way for new items to find an available spot instead of throwing error

Iā€™m talking about this portion of the code

1 Like

Yes, just use the Grid:GetNextFreePositionForItem(item) method. It returns a space where the item doesnā€™t collide and nil when there is no free space for the item!

1 Like

Hey, i keep on running into this bug which only happens with certain rotations (?)
image

The objects are created while the screen gui is disabled so its possibly messing with the absolute values. Dragging the objects fixes their positions.

Was just wondering if you have any proper solution to this as i dont necessarily feel like coming up with a bandaid one, thanks!
And, amazing resource, ofcourse!

1 Like

Not really sure why this happens, but try disabling a frame instead of the screen gui. I will rework this library a bit soon-ish for v0.3 so donā€™t expect a fix too soon. And if you have time, please post this as an issue on the issues page!

1 Like

Is there a cleanup function to remove an entire Grid with items?
Hereā€™s an Image of the Item Iā€™m trying to cleanup once the player is done viewing it:

1 Like

Just use Grid:ClearItems(true) and Grid:Destroy() right after.

1 Like

ClearItems is throwing this error

I think itā€™s conflicting with Trove when it attempts to cleanup after running ClearItems?

If I run LastContainer:ClearItems() instead of LastContainer:ClearItems(true) I donā€™t get this error. Essentially Trove clears the item for me and it avoids that conflict.

1 Like

Really decent resource, covers about everything you need to make a survival type of inventory. Could also create your own crafting system with it. Thanks a lot for making this.

2 Likes

Hey! This is super cool, But just wondering how does the meta Data work? And how can I access it? Because currently I havent found any documentation on how to get data from it.

1 Like

Example:

local InventoryGrid = GridPack.createGrid({
	Parent = GUI, -- Parent of the grid container.

	Visible = true, -- If the grid is visible, changes the containers visible property. Also disables item interaction on all items inside. BY DEFAULT THIS IS SET TO FALSE to prevent the inventory being shown when first creating the Grid.

	Assets = {
		Slot = nil, -- Add your own CanvasGroup here to customize the slots in the grid.
	},

	GridSize = Vector2.new(10, 20), -- How many slots the grid has on the X and Y axes.
	SlotAspectRatio = 1, -- Aspect ratio of one slot in the grid, helps with different resolutions if you're using scale instead of offset.

	AnchorPoint = InventoryFrame.AnchorPoint, -- Anchor point of the grid container.
	Position = InventoryFrame.Position, -- Position of the grid container.
	Size = InventoryFrame.Size, -- Size of the grid container.

	Metadata = {
		Type = "Inventory"
	},
})

print(InventoryGrid.Metadata.Type)

Itā€™s basically a custom table

2 Likes

Ahh, Alright thank you so much.

1 Like

is there a way to get the current item manager of the item? because i tried these but it wont give me the current one local currentItemManager = self.HoveringItemManager or self.ItemManager

1 Like