Do you have the item defined? If so you can run youritem.ItemManager
and it will give you the item manager. I probably could help more if you show a little snippet of the code that you are trying to get the currentItemManager for.
Would anyone know a way to blacklist items from an ItemManager? For example making it so the item cannot go into that ItemManager. If so please reply.
You would use something called MoveMiddleware
Here’s how I implemented it in my code:
local NewItem = GridPack.createItem({
Position = if v:FindFirstChild("Position") then Vector2.new(v.Position.Value.X, v.Position.Value.Y) else Vector2.new(0, 0), -- Position in a Grid.
Rotation = if v:FindFirstChild("Rotation") then v.Rotation.Value else 0,
Size = v:GetAttribute("GridSize") or Vector2.new(1, 1), -- Size in a Grid.
Assets = {
Item = ItemViewport,
},
MoveMiddleware = function(movedItem, newGridPosition, newRotation, lastItemManager, newItemManager)
lastItemManager = lastItemManager.Metadata
newItemManager = newItemManager.Metadata
print(movedItem, newGridPosition, newRotation, lastItemManager, newItemManager)
if newItemManager then
return Rem_Fun_MoveItemAcrossItemManager:InvokeServer(v, newGridPosition, newRotation, lastItemManager, newItemManager, ItemFolder)
else
return Rem_Fun_MoveItem:InvokeServer(v, newGridPosition, newRotation, lastItemManager)
end
end,
Metadata = {SlotType = Folder.Name},
})
It’s also documented here:
Thank you for answering questions! This is the solution that I would’ve used as well. This problem gave me an idea to also add a similar MoveMiddleware feature to all ItemManagers!
This is perfect, But just a question what is v
defined as? Also do you think you could explain it in a little bit more detail so I fully understand how it works?
In my case v can be seen as any of these items listed in the picture:
Basically datastore interpreted and based off the data the item would be cloned from ReplicatedStorage and rendered into a GUI.
As for MoveMiddleware it’s a function that runs before the item is placed into any grid.
It sends a call through a RemoteFunction which you need to setup and then add your own server sided code to handle the RemoteFunction.
Here’s my version of the serversided code, you can use it as an example but It’s incomplete and arguably insecure.
local function EditItem(movedItem, newGridPosition, newRotation)
local vGridPos = movedItem:FindFirstChild("Position") or Instance.new("Vector3Value")
vGridPos.Value = Vector3.new(newGridPosition.X, newGridPosition.Y,0)
vGridPos.Name = "Position"
vGridPos.Parent = movedItem
local vGridRot = movedItem:FindFirstChild("Rotation") or Instance.new("NumberValue")
vGridRot.Value = newRotation
vGridRot.Name = "Rotation"
vGridRot.Parent = movedItem
end
local function HandleData(Player, movedItem, newGridPosition, newRotation, lastItemManager, newItemManager, Folder)
if not newItemManager then
EditItem(movedItem, newGridPosition, newRotation)
return true
end
local Inventory = Player.Data.Inventory
local IsContainer = Folder:IsDescendantOf(ReplicatedStorage.Containers)
if newItemManager.Type == "Inventory" and lastItemManager.Type == "Container" then
local Prompt = Folder.Parent.Value
local PromptCF = if Prompt.Parent:IsA("Attachment") then Prompt.Parent.WorldCFrame else Prompt.Parent.CFrame
local Distance = Player:DistanceFromCharacter(PromptCF.Position)
if Distance <= Prompt.MaxActivationDistance then
EditItem(movedItem, newGridPosition, newRotation)
Folder.Parent = Inventory
return true
else
return false
end
end
end
Remotes:WaitForChild("MoveItemAcrossItemManager").OnServerInvoke = HandleData
Remotes:WaitForChild("MoveItem").OnServerInvoke = HandleData
im getting a nil value when its getting added it only works when i move it then it will give me it and i can’t show the rest because i changed so much thing and its for my project
Nevermind what i wrote before. Ive modified it a little bit to this:
MoveMiddleware = function(movedItem, newGridPosition, newRotation, lastItemManager, newItemManager)
lastItemManager = lastItemManager.Metadata
newItemManager = newItemManager.Metadata
if newItemManager then
if movedItem.Metadata.Type == newItemManager.Type then
print("match")
return true
else
print("not a match")
return false
end
else
return true
end
end,
This is all handled on the local side, but if this is wrong then please lmk.
But would there be anyway to change the highlight color to a red to indicate that it cannot be placed in that itemManager? I understand that there is a highlight function and in which i have used before but im unsure if that is the appropriate way to do this.
Ive done a little bit of tinkering with the modules and i’ve gotten it to work. I appreciate all of your help @ShiatAli_IbnAbuTalib !
This is an awesome module. Is it possible to make items in a single slot be replaced when another item is dragged over, rather than just blocking it and requiring the player to first unequip the item and then put the new item in?
I have been able to do heaps with this system, how would I go on about highlighting the squares that the item is hovering over?
What do you mean? It should already do that
Not automatically, at least not for me
Also how would I go about making it so that the items size is the same as the grid slots, for example a 1x2 item sitting perfectly in the grid slots and not overhanging them
Sorry, but you would have to add this yourself at the moment. Noting this to add it to a future version!
The items should already align, there could sometimes be some gaps due to rounding errors. If you meant the visual gaps between the grid cells, then follow this tutorial: Customizing | GridPack
The grid should be highlighted as shown here:
how would I do that I couldnt figure it out with the documentation provided
How would this behave on Console?
This should be working once you start dragging an item. Have you changed out some of the assets?