generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Inventory Table?

Previous Thread :: Next Thread 
MightyDantheman is not online. MightyDantheman
Joined: 06 May 2011
Total Posts: 5108
08 Mar 2016 01:53 AM
How would I have a table that constantly updates according to what children are inside a folder.

Example:

local inv script:FindFirstChild("Inventory")

invTable = {}

for i,v in pairs(inv:GetChildren()) do
table.insert(invTable, v.Name)
end

print(table.concat(invTable, ', '))

--//

How would I have the table be constantly updated by what children are present inside of the Inventory folder? I was thinking I could have it remove everything from the table, and add everything that's currently in the folder, every time the folder has a child added or removed. But is there an easier way?


~MightyDantheman
Report Abuse
MightyDantheman is not online. MightyDantheman
Joined: 06 May 2011
Total Posts: 5108
08 Mar 2016 01:58 AM
Also, what's the function called to detect if a child has been added, removed, or changed?


~MightyDantheman
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
08 Mar 2016 01:59 AM
You know, that's so pointless.

invTable = inv:GetChildren();
local function Update()
local t = inv:GetChildren()
for i=1,#invTable do invTable[i] = t[i] end;
-- Or, invTable = inv:GetChildren()
end;
inv.ChildAdded:connect(Update);
inv.ChildRemoved:connect(Update);
Report Abuse
MightyDantheman is not online. MightyDantheman
Joined: 06 May 2011
Total Posts: 5108
08 Mar 2016 02:41 AM
Wait, how would I make a GUI for the inventory? Would I have to make a scroll GUI and insert a new button for each item (by counting how many items exist in the inventory, and changing each one to match each item)?


~MightyDantheman
Report Abuse
MightyDantheman is not online. MightyDantheman
Joined: 06 May 2011
Total Posts: 5108
08 Mar 2016 03:13 AM
Anyone know of a good tutorial video for an inventory system? The GUI part is confusing me.


~MightyDantheman
Report Abuse
Fatul is not online. Fatul
Joined: 28 Sep 2008
Total Posts: 254
08 Mar 2016 04:13 AM
One very inconsistent way would be to make several slots in a gui,then a loop to check and order things.
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
08 Mar 2016 04:18 AM
Here I will let you try a snapshot of my inventory system.

http://pastebin.com/DwxJtwbQ - Inventory
http://pastebin.com/rJqyb3ss - Item
http://pastebin.com/mQhAqLhK - Debug module, easy print stuff

How to use...

local Inventory = require("Inventory")
local Item = require("Item")

local invy = Inventory.new(10) --allocate an inventory of 10 space
invy[2] = Item.new(12, {})

The table {} is metadata specific to the item. With other versions, come different data structures. This is the only one I am leaking right now until my system is better. It is free and open source ofc.

With my inventory 2D class, it features

print(invy[{2,1}].Id) --> prints id of item in slot 2,1

It's pretty neat.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image