Jump to content

Recommended Posts

I need help with loading prefab files. I would like to load only what is needed for the options chosen. I want to add prefab files to the list only if the option is enabled. for example have base prefab files that are needed then add prefab files needed based on options. If option 1 and 5 are enabled only add those prefabs to the list for loading.

 

Currently this is what I have.

modinfo option

    {
        name = "chester_config",
        label = "# of extra Chesters",
        hover = "Max atm is 3.",
        options =
    {
        {description = "One", data = 0, hover = "This will add Blue Chester."},
        {description = "Two", data = 1, hover = "This will add Blue Chester & Big Daddy."},
        {description = "Three", data = 2, hover = "This will add Blue Chester & Big Daddy, & Party Chester."},
        {description = "Four", data = 3, hover = "This will add Blue Chester & Big Daddy, Party Chester, & Afester."},
    },
        default = 0,
    },

modmain

if chester_config == 0 then
        PrefabFiles =
        {"bluechester","bluechester_eyebone","basic_commands","console_0"}
elseif chester_config == 1 then
        PrefabFiles =
        {"bluechester","bluechester_eyebone","basic_commands","console_0","console_1","bigdaddy","bigdaddy_eyebone"}
elseif chester_config == 2 then
        PrefabFiles =
        {"bluechester","bluechester_eyebone","basic_commands","console_0","console_1","console_3","bigdaddy","bigdaddy_eyebone","partychester","partybone"}
elseif chester_config == 3 then
        PrefabFiles =
        {"bluechester","bluechester_eyebone","basic_commands","console_0","console_1","console_2","console_3","bigdaddy","bigdaddy_eyebone","afester","afestertoy","partychester","partybone"}
end

I would like to be able to enable or disable different chesters like this

modinfo

    {
        name = "afester_config",
        label = "Enable Afester",
        hover = "Even in his own dimention Afester didn't fit in.",
        options =
    {
        {description = "Enable", data = true, hover = "This will enable Afester."},
        {description = "Disable", data = false, hover = "This will disable Afester."},
    },
        default = true,
    },
    
    {
        name = "cavester_config",
        label = "Enable Cavester",
        hover = "Cavester is all about the underground scene.",
        options =
    {
        {description = "Enable", data = true, hover = "This will enable Cavester."},
        {description = "Disable", data = false, hover = "This will disable Cavester."},
    },
        default = true,
    },    

The problem is I can't get it to load only the prefab files for the enabled chesters. I have tried a few things and can only get this to work if I load all the prefab files and then elsewhere in the mod change things. like if disabled it won't spawn on a new map but you can still use commands to get the eyebone.

I also tried to look around for other mods that might have something like this and I couldn't find any mod that loaded different prefab files based on options.

Edited by afetogbo

@Muche it has two sets and loads one or the other. That is how mine works now only with more sets of prefabs. I had to edit the thread because after reading it I thought it sounded wrong. I want to add prefabfiles to the list instead of having multiple lists.

Edited by afetogbo

Well, PrefabFiles is a table, so you can do with it anything a table can do, for example:

PrefabFiles = { "basic_commands" }
if bluechester_config then
	table.insert(PrefabFiles, "console_0")
	table.insert(PrefabFiles, "bluechester")
	table.insert(PrefabFiles, "bluechester_eyebone")
end
if bigdaddy_config then
	table.insert(PrefabFiles, "console_1")
	table.insert(PrefabFiles, "bigdaddy")
	table.insert(PrefabFiles, "bigdaddy_eyebone")
end
if partychester_config then
	table.insert(PrefabFiles, "console_3")
	table.insert(PrefabFiles, "partychester")
	table.insert(PrefabFiles, "partybone")
end
if afester_config then
	table.insert(PrefabFiles, "console_2")
	table.insert(PrefabFiles, "afester")
	table.insert(PrefabFiles, "afestertoy")
end
if cavester_config then
	table.insert(PrefabFiles, "cavester")
	table.insert(PrefabFiles, "cavester_eyebone")
end

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...