#Making a custom inventory, need a bit of help figuring it out
1 messages · Page 1 of 1 (latest)
Wdym
im trying to make an ID-based custom inventory
using a number to define an item and its values
for example
1 would represent a goat cheese wheel, which has a value of 5, a weight of 1, and a category of Food
Use module scripts and metatables
Or without metatables I think it can be done too
If u want help dm me @hushed galleon
Don't take any help from him it's ai generated
Bro just go learn from YouTube
noted
But yeah you should learn OOP and module scripts
Module scripts will make it so easy if you learn it
alr
Personally instead of an array table I'd do ItemID = ItemCount if you want to allow for item stacking
Your question is kind of vague though I mean there's a lot that goes into a system like this
i know
I'm not even intermediate in scripting but I would make a modulescriot for each item and store their data there
im still trying to figure out how im gonna do this myself
aight
Like make a module script named Apple or wtv and a dictionary for ID weight and anything you need
could you send a documentation for it?
Unless u want the weight to change
You should check out some videos on yt about module scripts
id like to be able to customize value
You wanna make it so that when a player gets an item the weight of each item won't be the same each time?
as in value in gold
nope
Yes.
ModuleScript.Items = {
GoatCheese = {DisplayName = "Goat Cheese", "Weight = 2, Value = 5, Category = "Food"}
}
or
ModuleScript.Items = {
1 = {Name = "Goat Cheese" Weight = 2, Value = 5, Category = "Food"}
}
Then you should probably make a new folder parent it to player name it inventory and store string values in there with attributes like weight etc
Do note that this is for a singleplayer game, so some limitations can be lifted
Changing the value of the item is a bit different, if you want every player to have different item values you would need to save it to datastore
Oh that's way easier, just edit Value like so;
ModuleScript.Items.GoatCheese.Value = 10
you will still need to save it to a datastore though and load it when the player first joins
awesome!
i should send a screenshot of the inventory display rq
left rectangle displays category, right rectangle displays items
in a real system it would look something like this (This is simplified)
local ModuleScript = require(script.ModuleScript)
local function UpdateItemValue(ItemID, Value)
if ModuleScript.Items[ItemID] then
ModuleScript.Items[ItemID].Value = Value
end
end)
** You are now Level 5! **
i need to add another rectangle rq
A note for UI: UIPadding, UIListLayout, and UIGridLayout are all very useful
ooo that second one looks useful
If I were making this system I would make item categories not hard coded and use both UIPadding and UiListLayout to add all valid Item categories as buttons
Oh you got that no problem
Making a ViewportFrame to display the model of the items is not as hard as you're probably thinking
awesome
https://create.roblox.com/docs/reference/engine/classes/ModuleScript - Useful for organizing / optimizing system IMO this isn't optional
https://create.roblox.com/docs/reference/engine/classes/ViewportFrame - Useful for displaying model of item
https://create.roblox.com/docs/ui/ui-drag-detectors - Useful if you want to rotate the model when you hold click and move mouse over displayed model
A script type that runs once when Global.LuaGlobals.require() is called with
it. Returns exactly one value, usually a table of functions, to used by other
scripts. Useful for compartmentalizing code.
how would i make a scrollable list for the items and category?
in skyrim the inventory is scrolled up and down, but the category at the center is bigger than the others
ScrollableFrame
And inside of it uigridlayout or uilistlayout depending on what youre trying to achieve and also inside the scrollableframe frames of the items
i got that set up, is there a way i can stop the player from scrolling past the top boundary?
nvm
canvas size
im gonna use the scrolling list to display items instead
also you can use UIPadding in a scrolling frame if I recall, handy for getting it looking just right
I would use the absolute value for UIPadding though
so do something like {0.1, 0} not {0, 1}
i got the thing set up
now to make it display the player's inventory
ill give the player one goat cheese wheel to start
i gotta make the info display UI rq
when I made it I (personally) never used module scripts, I just had a server script which had an array that had name of all players and inside of it dictionaries with an item name and quantity lua local GlobalInventories = { ["PlayerName"] = { ["Item1"] = 5 } }
vro 💔 code block ain't blocking
its not multiplayer
u can do the same
epic
i cant use this for players, however... i can use it for containers
ill work on it more tomorrow
Damn that means every time you edited the inventory it was in that one script, how long was it?