Nullpoint Posted February 28, 2014 Share Posted February 28, 2014 Hey folks. Got a few questions on lureplants that weren't covered in other threads or on the Don't Starve wiki. There's threads about lureplant digestion, but nobody seems to go into much detail about how lureplants handle item stacks. I had a lureplant grab a stack of 20 logs and another one of 40 grass, and was able to get them back, but I'm wondering if the plant would have digested each log in the stack one by one or the whole stack all at once? Does anyone have experience here? I took a look at the .lua code for the digester component and it doesn't seem to explain how it handles stacks, but I'm kind of new to .lua. I've quoted it below in case anyone can shed some light on it: local Digester = Class(function(self, inst)self.inst = instself.digesttime = 20self.itemstodigestfn = nilself.task = self.inst:DoPeriodicTask(self.digesttime, function() self:TryDigest() end) self.inst:ListenForEvent("gotnewitem", function() if not self.task then self.task = self.inst:DoPeriodicTask(self.digesttime, function() self:TryDigest() end) end end) end) function Digester:TryDigest()if self.inst.components.inventory thenlocal helditems = {} for k,v in pairs(self.inst.components.inventory.itemslots) do if not v:HasTag("irreplaceable") thenif self.itemstodigestfn thenif self.itemstodigestfn(self.inst, v) thentable.insert(helditems, v.prefab)endelsetable.insert(helditems, v.prefab)endendendif #helditems > 0 thenlocal rnd = math.random(#helditems)self.inst.components.inventory:ConsumeByName(helditems[rnd], 1)elseif self.task thenself.task:Cancel()self.task = nilendendendend return Digester Link to comment Share on other sites More sharing options...
MilleniumCount Posted February 28, 2014 Share Posted February 28, 2014 Coder question eh? @simplex ? Perhaps there is help. Woops, where are my manners? And welcome on the forums of course! ^^ Link to comment Share on other sites More sharing options...
Nullpoint Posted February 28, 2014 Author Share Posted February 28, 2014 Thanks. It's not only for coders, if anyone has input about how fast lureplants digest stacks just from playing that's useful too. Link to comment Share on other sites More sharing options...
Deacon_Blue Posted February 28, 2014 Share Posted February 28, 2014 Just glancing at it, it looks like it treats one inventory slot as an item. I think it will take out the entire stack at once. Link to comment Share on other sites More sharing options...
Nullpoint Posted February 28, 2014 Author Share Posted February 28, 2014 Thanks! What's weird is that I killed a lureplant and some of the items I recovered were dropped not by the lureplant but by an eyeplant, including five units of grass from a stack of 20. Link to comment Share on other sites More sharing options...
Developer Bryce Posted February 28, 2014 Developer Share Posted February 28, 2014 "self.inst.components.inventory:ConsumeByName(helditems[rnd], 1)" is the part that actually consumes the item. The "1" that it's passing in means that it will only consume one item at a time, even from stackable items. Link to comment Share on other sites More sharing options...
Nullpoint Posted March 1, 2014 Author Share Posted March 1, 2014 Hey, a dev response! Thanks, Bryce. So the idea of using lureplants for gathering items CAN work, potentially, so long as the items in question are too plentiful for it to digest. Guess that means I can set up harvesting if I feel like replanting 96 saplings that will essentially never be reliably harvested and then adding on however many saplings on top of that which WILL be reliably stockpiled as they'd be too much for the lureplant's digestion rate to handle. Makes sense only for games so long there's an eventual benefit, I suppose. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.