#Advice Re: Structuring Complicated / Deeply Nested Data

1 messages · Page 1 of 1 (latest)

split yacht
#

Hi there, I have a background generally in programming and development but am new to Roblox Studio. I'm working currently on something that would require a more detailed set of data per mission to resolve logic correctly, which I've shown below.

In other engines like Godot or Unity I would create a class or the like that would enforce the structure and limit human error from inputs. However, here I have everything inside of a ModuleScript (which is what from what I have seen has been the blanket solution) which I have below. This is a simple mock-up of a mission without any extensive writing for the descriptions, success_text or failure_text.

Just wanting to see what the general best practice is, if there's maybe a better way that I could represent this data that I'm unaware of, and any other advice. Thanks for reading!

local defaultMissionStorage = {
    missions = {
        ["Mission_1"] = {
            id = "Mission_1",
            name = "Mission 1",
            description = "Defeat 10 enemies",
            image = "LINK",
            options = {
                ["violence"] = {
                    name = "Choose Violence",
                    type = "Might",
                    required_stat = 5,
                    success_text = "You won!",
                    failure_text = "You lost."
                },                
                ["peace"] = {
                    name = "Choose Peace",
                    type = "Intellect",
                    required_stat = 5,
                    success_text = "You won!",
                    failure_text = "You lost."
                },
            }
        }
    }
}

return defaultMissionStorage
nimble oar
#

second, break up your data if applicable

#

i.e. server doesn't care about the success text, so have it in a separate module purely for client display

split yacht
#

So there isn't an easy way around the issue of this being all written by hand and not able to be enforced within Roblox Studio? I'd need to come up with some other little thing to format the data?

nimble oar
#

if you want a concrete structure for a "mission" structure you'd need to code that yourself lmao

#

you could make an abstraction using OOP with inheritance ig??