Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Need some serious tips on making a custom-inventory system. Help?

Asked by 9 years ago

I don't know where to start on this one. I can get everything finished except for one thing, the way you can tell if a "slot" in an inventory has been used up or not. I could imagine using boolvalues to check true or false, but I honestly don't know where else I could start on this one.

This ties in with my RPG, I'd love to know some serious tips on how to accomplish this.

2 answers

Log in to vote
1
Answered by 9 years ago

If the inventory is managed by one script, I would recommend using tables.

To create a table:

tablename = {false, false, true, false, false} -- Repeat false for every inventory slot

To check if a certain value is true or false (To check if a slot is available):

tablename[slotnumber] -- This will return the value in that slot

If the slotnumber is replaced with 3 then it would return the value in the third slot, which is, in this case, true. If it were replaced with 4 (Or any number other than 3) it would, in this case, return false.

If you created a separate table for what is actually inside the inventory slots, it would make saving the inventory using datastores easier, as you would only have to save the two tables rather than each and every slot and item.

Ad
Log in to vote
0
Answered by 9 years ago

I would recommend doing this in two parts.

The first is to use data stores to check if they have an item. You can choose your flavor, but I would do it along the lines of tables with string indexes index (and perhaps have them be tables as well holding values).

The second part, would be to make a function that creates the actually (or gets it) and passes the values (if any).

You might want to keep the link: http://wiki.roblox.com/index.php?title=Data_store

Make sure to read the limitations.

Answer this question