#Making a custom inventory, need a bit of help figuring it out

1 messages · Page 1 of 1 (latest)

hushed galleon
#

I just need help figuring out how to script this

both containers and the player's inventory store items/data using numbers inside of arrays like this

Barrel Inventory (four Goat Cheese Wheels)

local inventory = {1,1,1,1}```

Player Inventory (Nothing)
```lua
local inventory = {}```
#

in this case, Goat Cheese Wheels have an ID of 1

steep obsidian
#

Wdym

hushed galleon
#

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

steep obsidian
#

Use module scripts and metatables

#

Or without metatables I think it can be done too

hushed galleon
#

could you elaborate a bit?

#

im still kinda new to scripts

thin halo
#

If u want help dm me @hushed galleon

hushed galleon
#

are you gonna make me pay for it

#

cause im trying to learn how to do this

steep obsidian
#

Don't take any help from him it's ai generated

thin halo
#

Bro just go learn from YouTube

hushed galleon
steep obsidian
#

But yeah you should learn OOP and module scripts

#

Module scripts will make it so easy if you learn it

pliant idol
#

Your question is kind of vague though I mean there's a lot that goes into a system like this

hushed galleon
#

i know

steep obsidian
#

I'm not even intermediate in scripting but I would make a modulescriot for each item and store their data there

hushed galleon
steep obsidian
#

Like make a module script named Apple or wtv and a dictionary for ID weight and anything you need

hushed galleon
steep obsidian
#

Unless u want the weight to change

steep obsidian
hushed galleon
steep obsidian
#

You wanna make it so that when a player gets an item the weight of each item won't be the same each time?

hushed galleon
#

as in value in gold

pliant idol
hushed galleon
#

im making Skyrim's inventory system

#

weight is consistent, however value changes

steep obsidian
#

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

hushed galleon
#

Do note that this is for a singleplayer game, so some limitations can be lifted

pliant idol
#

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

pliant idol
hushed galleon
#

awesome!

#

i should send a screenshot of the inventory display rq

#

left rectangle displays category, right rectangle displays items

pliant idol
#

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)
surreal vergeBOT
#

studio** You are now Level 5! **studio

hushed galleon
#

i need to add another rectangle rq

pliant idol
hushed galleon
pliant idol
#

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

hushed galleon
#

this is what skyrim's inventory looks like

#

for reference

pliant idol
#

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

hushed galleon
#

awesome

pliant idol
#

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.

Class.GuiObject that renders 3D objects inside its bounds.

UI drag detectors facilitate and encourage interaction with 2D user interface elements in an experience, such as sliders and spinners.

hushed galleon
hushed galleon
# hushed galleon

in skyrim the inventory is scrolled up and down, but the category at the center is bigger than the others

steep obsidian
#

And inside of it uigridlayout or uilistlayout depending on what youre trying to achieve and also inside the scrollableframe frames of the items

hushed galleon
#

nvm

pliant idol
#

canvas size

hushed galleon
#

im gonna use the scrolling list to display items instead

pliant idol
#

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}

hushed galleon
#

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

chrome pasture
# hushed galleon are you gonna make me pay for it

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

hushed galleon
#

its not multiplayer

chrome pasture
#

u can do the same

hushed galleon
#

epic

hushed galleon
hushed galleon
#

ill work on it more tomorrow

pliant idol