I am trying to find an effiecient way to code a collectible encyclopedia.
I dont really know how to make a encyclopedia.
Our method was ineffiecient and very time consuming.
We’re creating a game where you can collect cans and each can is datastored and we’re trying to make a encyclopedia to show players their collection progress with icons of all of the cans. Its a system heavily inspired by “Find The Markers”. If you have any input please comment below.
By “encyclopedia”, are you referring to the ones similar to egg hunt books which hold all of the eggs you’ve collected? If so, you would have to store all of the players “cans” in a table, serialize them when the player leaves as then reload them onto the server which can then be passed to the client.
Hey there, co–owner here, we have the data stored in a folder, it already automatically saves and loads, our issue is this: We need an efficient way to detect the player having said collectibles and making their icons visible in the collectible “encyclopedia” we made, much like how the egg hunt was done. The way I’ve done it so far is to check to see if the player has a value with a certain name with an if/then statement, and just copy/pasted those few lines of code with their respective names. It’s REALLY bad, but it’s the only way I could think of with my limited knowledge of lua.
Yeah there’s definitely a better way where you won’t have to manually copy/paste any code at all. Someone you’ll need to get a list of all the collectibles and their information. That way you can just iterate through each collectible-info and set up GUI elements and check if the player has collected them and such.
You mentioned having player data in a Folder, if that’s the case you might be able to generate the list of collectible-info automatically, which is way better than manually writing out the table. If you’d like help with getting that set up, could you post a screenshot of the folder structure?
I appreciate all your assistance, and your offer. Honestly, I don’t think I could pull it off at my current skill level, so we’ll probably end up hiring someone for it. Thanks a bunch, really.
Well, if things in the Blox folder are the collectibles, you can create a list of their names like so:
local collectibleInfos = {}
for _, collectible in ipairs(BloxFolder:GetChildren()) do
local collectibleInfo = {
name = collectible.Name,
isCollected = false --probably add datastore code here?
}
table.insert(collectibleInfos, collectibleInfo)
end
If you want to automatically generate the GUI for showing the status of each collectible, you could do something like
local collectibleList = --whatever thing with a UIListLayout you want to show the collectibles
local collectibleEntry = collectibleList.CollectibleEntry --I like to just have one "list entry" that gets cloned for each item
collectibleEntry.Parent = nil --Remove it, but still keep a reference to it so we can clone it
for _, collectibleInfo in ipairs(collectibleInfos) do
local collectibleEntry = collectibleEntry:Clone()
collectibleEntry.Parent = collectibleList
collectibleEntry.CollectibleNameLabel.Text = collectibleInfo.name
collectibleEntry.IsCollectedFrame.Visible = collectibleInfo.isCollected
end
You might also want to modify the collectibleEntry to show if it’s been collected or not, so you’ll somehow need to connect that to the data stores through the server (gui code has to be on the client which can’t interact with data stores).