Zardexrlz Posted November 8, 2016 Share Posted November 8, 2016 (edited) 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 November 8, 2016 by Zardexrlz To be clearer Link to comment https://forums.kleientertainment.com/forums/topic/71542-how-to-add-prefabs-and-loot-on-a-mod-postinit/ Share on other sites More sharing options...
CarlZalph Posted November 9, 2016 Share Posted November 9, 2016 (edited) 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 November 9, 2016 by CarlZalph 1 Link to comment https://forums.kleientertainment.com/forums/topic/71542-how-to-add-prefabs-and-loot-on-a-mod-postinit/#findComment-835261 Share on other sites More sharing options...
Zardexrlz Posted November 9, 2016 Author Share Posted November 9, 2016 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, I appreciate it! Link to comment https://forums.kleientertainment.com/forums/topic/71542-how-to-add-prefabs-and-loot-on-a-mod-postinit/#findComment-835285 Share on other sites More sharing options...
CarlZalph Posted November 9, 2016 Share Posted November 9, 2016 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, 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. Link to comment https://forums.kleientertainment.com/forums/topic/71542-how-to-add-prefabs-and-loot-on-a-mod-postinit/#findComment-835292 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now