Jump to content

Recommended Posts

I'm making a mod that makes the Old Bell usable in DST. I know that there is already mods that do this out there, but i'm doing it mainly for the experience and learning, as i'm just learning to program now.

I managed to get pretty much everything working, but I'm currently altering statueglommer.lua, that is a DST .lua file, but i wanted to have a completely independent mod, that could work without altering game files.

local prefabs =
{
    "glommer",
    "glommerflower",
    "marble",
    "bell_blueprint", -- This line
}

SetSharedLootTable('statueglommer',
{
    {'marble',  1.00},
    {'marble',  1.00},
    {'marble',  1.00},
    {'bell_blueprint', 1.00}, -- and this line too
})

Is there anyway to make these two commented lines in PostInit (ex.: using  AddPrefabPostInit) ?

Thanks for all the help

Edited by Zardexrlz
To be clearer
1 hour ago, Zardexrlz said:

Is there anyway to make these two commented lines in PostInit (ex.: using  AddPrefabPostInit) ?

Thanks for all the help

This functions on a listen server, didn't check on a full shard setup.

AddGamePostInit(
    function()
        if GLOBAL.LootTables and GLOBAL.LootTables.statueglommer
        then
            table.insert(GLOBAL.LootTables.statueglommer, {'bell_blueprint',  1.00})
        end
    end
)

As for editing the prefabs for the dependencies tree I don't think it would be much of a bother not having it for when the sim registers the prefab.

The game already spews about orphaned resources a bunch anyway without mods.

Edited by CarlZalph
  • Like 1
33 minutes ago, CarlZalph said:

This functions on a listen server, didn't check on a full shard setup.


AddGamePostInit(
    function()
        if GLOBAL.LootTables and GLOBAL.LootTables.statueglommer
        then
            table.insert(GLOBAL.LootTables.statueglommer, {'bell_blueprint',  1.00})
        end
    end
)

As for editing the prefabs for the dependencies tree I don't think it would be much of a bother not having it for when the sim registers the prefab.

The game already spews about orphaned resources a bunch anyway without mods.

Yes! Worked like a charm.

Just one more question (as i said, i'm just starting to learn lua):
I do get the table.insert part of the code, just not too sure about the
if GLOBAL.LootTables and GLOBAL.LootTables.statueglommer then part
Does the LootTables get created only when the thing is destroyed(or they are nil until things are destroyed)? therefore this "if" checks if the statueglommer is going to drop loot and only then add bell_blueprint to the table? If yes, I get the GLOBAL.LootTables.statueglommer, because when it is unassinged, it is nil with is interpreted as false, but why is GLOBAL.LootTables necessary too?

@CarlZalph thanks for the help dude, :D I appreciate it!

21 minutes ago, Zardexrlz said:

Yes! Worked like a charm.

Just one more question (as i said, i'm just starting to learn lua):
I do get the table.insert part of the code, just not too sure about the
if GLOBAL.LootTables and GLOBAL.LootTables.statueglommer then part
Does the LootTables get created only when the thing is destroyed(or they are nil until things are destroyed)? therefore this "if" checks if the statueglommer is going to drop loot and only then add bell_blueprint to the table? If yes, I get the GLOBAL.LootTables.statueglommer, because when it is unassinged, it is nil with is interpreted as false, but why is GLOBAL.LootTables necessary too?

@CarlZalph thanks for the help dude, :D I appreciate it!

The ifs are in case something goes wrong by another mod breaking the LootTables variable or by extension if a Klei dev touches the name for any reason.

Then the second check is to ensure the statueglommer one exists for the same reason.

Just higher compatibility without allowing your mod to make a crash happen.

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...