Jump to content

Burnable Chests


Recommended Posts

I'm trying to make a small mod that simply allows chests to be ignitable as well as being able to catch fire and propagate said fire.


"Why" might you ask?  Well, I like the trash can mod that was uploaded, but for some reason it glitches a little for me and sometimes crashes my game.  Not to mention, I'm not a fan of having sixteen followers.  I almost never find Chester anymore - for one reason or another and probably because of one of the crazy amount of mods I'm running - but I have Waldo because he's funny and that's pretty much enough for me.


Instead, I'd love the ability to set treasurechests - particularly the player built ones, or simply all wooden ones in general - to be able to be set alight and for all objects within to drop as ashes - excepting, of course, the irreplaceable ones, like Lucy, which should just drop.  This would allow chests to be used as trash cans for a bunch of junk that you just don't want to see anymore.  Craft a chest, throw everything you want incinerated inside, and use your torch.  It'd be awesome.


Now, I've tried simply adding the        


into my code.  I don't think I'm doing it right, but that's because I'm not sure how to call on a specific chest within a prefab.  There are four chests listed in the treasurechest.lua prefab.  I only want one of them to be ignitable/burnable.  I also realize that, if something is burnable, it needs some sort of timeline for when it extinguishes, but I'm not sure if that's built into those commands.  Anyway, what I have so far is this:

function BurningChestsPostInit( inst )  if bank == "treasure_chest" then	MakeLargeBurnable(inst)	MakeSmallPropagator(inst)    inst.components.burnable:SetOnIgniteFn(OnIgnite)  endAddPrefabPostInit("treasurechest", BurningChestsPostInit)end

So tell me what I'm doing wrong please.  I don't know this coding language and, so far, I'm sort of frankensteining codes together to figure out how things work.  It's progressing me in my understanding, but I lack the basics still.


Thanks in advance for any help you may be.  :-)

Link to comment
Share on other sites

You have nested logic operators.


function BurningChestsPostInit( inst )
  if bank == "treasure_chest" then
AddPrefabPostInit("treasurechest", BurningChestsPostInit)


Although I'm not sure where the variable bank is being defined. And I don't see an OnIgnite function either.

Link to comment
Share on other sites

Yes, I had an OnIgnite function, but I managed to leave it out somewhere in my editing and forgot to put it back in.  Thank you for pointing that out.  By the way, I really like your RPG Items mod.  :)


1.  What is this nested logic operator that you're talking about?  I don't understand this language, and I'm trying to figure it out by myself through simple trial and error.


2.  The variable "bank" isn't defined by me.  I'm not sure how, in a prefab that has multiple chests (data/scripts/prefabs/treasurechest.lua), to select just one of those treasure chests.  I don't want ornate chests, for instance, being burnable.  I do want regular treasure chests to be burnable and ignitable.  So, I'm going to try adding the OnIgnite function and I'll let you know of the results.

Link to comment
Share on other sites

local require = GLOBAL.requirelocal SpawnPrefab = GLOBAL.SpawnPrefabfunction treasurechestPostInit( inst )    local chests = {        treasure_chest = {            bank="chest",            build="treasure_chest",            }        }    MakeLargeBurnable(inst)    MakeSmallPropagator(inst)    inst.components.burnable:SetOnIgniteFn(OnIgnite)endAddPrefabPostInit("treaasure_chest", treasurechestPostInit)

Alright, so I did this in my modmain.lua.  This is all there is.  It doesn't crash the game (which is a huge step for me, :)), but it doesn't do anything.  I pulled the code for the chest directly from treasurechest.lua.  I figured if I gave the game its own code back and just added in my changes it would have no problems.  Apparently it doesn't, but again, it doesn't do anything.



Link to comment
Share on other sites


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.

  • Create New...