Amnesiac Posted April 4, 2019 Share Posted April 4, 2019 I'm building, or trying to build, a mod called More Drops (DS). I ported it to Don't Starve from "Don't Starve Together", so my lua knowledge is very limited, but I've been working on this thing for days and can't figure it out, so I need to ask for help. I figured out how to expand on the original mod authors work by adding new trees and resources, but when it comes to "hackable" resources, I'm stumped. So this is what I was trying, and tons of variations on this. This doesn't work and I don't understand why, and I'll show you what does work in the next two. --bamboo if inst.name == "Bamboo Patch" and utils.LootRandom(bambooChance) then utils.DoTimes(GetModConfigData("bambooAmount", KnownModIndex:GetModActualName("(JEM) More Drops DS")), inst.components.lootdropper.SpawnLootPrefab, inst.components.lootdropper, "bamboo") end This does work --Spawn extra logs for tall trees if inst.components.growable.stage == 3 and utils.LootRandom(logChance) then utils.DoTimes(GetModConfigData("extralogstall", KnownModIndex:GetModActualName("(JEM) More Drops DS")), inst.components.lootdropper.SpawnLootPrefab, inst.components.lootdropper, "log") end And this works as well if inst.name == "Evergreen" and inst.components.growable.stage ~= 1 then if utils.DropLootRandom(inst, "pinecone", seed_chance) then print("Dropped seed") end end Now I'm not sure how much of the files I should paste here, but here's the start of the trees.lua just to add a bit more context local utils = require("utils") local logChance = GetModConfigData("logChance", KnownModIndex:GetModActualName("(JEM) More Drops DS")) local function ImproveTree(inst) --Do these when the tree is fully chopped local seed_chance = GetModConfigData("treeseedchance", KnownModIndex:GetModActualName("(JEM) More Drops DS")) local egg_chance = GetModConfigData("eggChance", KnownModIndex:GetModActualName("(JEM) More Drops DS")) local coconut_seed_chance = GetModConfigData("coconutChance", KnownModIndex:GetModActualName("(JEM) More Drops DS")) local bambooChance = GetModConfigData("bambooChance", KnownModIndex:GetModActualName("(JEM) More Drops DS")) local oldonfinish = inst.components.workable.onfinish inst.components.workable:SetOnFinishCallback(function(inst, chopper) All of the info is called in modmain.lua correctly as far as I can tell, I made sure to add things in the same way as the working code. I expected this to drop some extra bamboo! I've tried so many different ways, even made my own choppable.lua file and added it the same way the original author added pickable.lua, but I figured it's gotta be a bit more like trees than regular resources, since you use a tool and it drops the item on the ground rather than adding to invetory. If you want to see the whole mod, I've uploaded it here and in dropbox: https://www.dropbox.com/s/ahss2d0s861j2an/%28JEM%29%20More%20Drops%20DS.7z?dl=0 (JEM) More Drops DS.7z Link to comment https://forums.kleientertainment.com/forums/topic/104555-dont-starve-lua-cant-figure-out-how-to-spawn-additional-bamboo-with-each-bamboo-tree-or-other-machete-resources/ Share on other sites More sharing options...
Ultroman Posted April 4, 2019 Share Posted April 4, 2019 Well, it LOOKS like it's set up correctly. What I'd do if I were you, is just splash in some print-statements all over the hackables code AND in the code like it that works (e.g. the trees), just to see what gets called and what doesn't get called. If everything is getting called, you can start printing values, to see if what you're doing is actually taking hold. If you things are NOT getting called, try stepping back to where they are called, and do some more print-statement investigation. Make sure that e.g. bambooChance and bambooAmount are being read correctly. All that stuff. You'll probably find that it's some small thing. Link to comment https://forums.kleientertainment.com/forums/topic/104555-dont-starve-lua-cant-figure-out-how-to-spawn-additional-bamboo-with-each-bamboo-tree-or-other-machete-resources/#findComment-1174319 Share on other sites More sharing options...
MidrealmDM Posted April 30, 2019 Share Posted April 30, 2019 should work for bamboo =-=-=-=- AddPrefabPostInit("bambootree", function(inst) inst:ListenForEvent("hacked", function(inst, data) if math.random() < 0.4 then -- 40% chance to drop extra (can make this configurable variable) SpawnDrop(inst, "bamboo") end end) end) Link to comment https://forums.kleientertainment.com/forums/topic/104555-dont-starve-lua-cant-figure-out-how-to-spawn-additional-bamboo-with-each-bamboo-tree-or-other-machete-resources/#findComment-1187535 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