MrBlueYeti Posted May 10, 2019 Share Posted May 10, 2019 (edited) Hello, I am trying to make a mod which makes you able to light a fire pit with a torch just like you can light a tree on fire with a torch. I tried something but my game crashes. code: AddPrefabPostInit("firepit", function(inst) if not inst.components.canlight("firepit") then inst:AddComponent("canlight") inst:MakeSmallBurnable(inst, TUNING.SMALL_BURNTIME) end end) the picture attached is the crash. Thanks for the help. Edited May 10, 2019 by MrBlueYeti Link to comment Share on other sites More sharing options...
Ultroman Posted May 11, 2019 Share Posted May 11, 2019 There is no "canlight" function on "components". This is not valid code. Didn't we solve this already in this thread? It works on my server with the code in that thread. I can light firepits with my torch with that. MakeSmallBurnable() just makes the torch able to burn while it's lying on the ground, you know, it controls whether it can be set on fire by a nearby fire. While MakeSmallPropagator() makes it spread fire. Link to comment Share on other sites More sharing options...
MrBlueYeti Posted May 11, 2019 Author Share Posted May 11, 2019 (edited) The code you mentioned works, but the thing I am trying to do now is not to turn the torch into fuel for the firepit but rather making you able to right click the firepit to light it without consuming the torch while your character is holding the torch in the equipment slot. The light option i ment is in the screenshot Sorry for the confusion. Edited May 11, 2019 by MrBlueYeti Link to comment Share on other sites More sharing options...
Ultroman Posted May 11, 2019 Share Posted May 11, 2019 Ah, I understand. But the fire in the firepit only goes out when the fuel in it runs out. If you make it so you can light the firepit without consuming the torch, you will have to add free fuel to the firepit for it to be able to burn, which will be heavily exploitable. Link to comment Share on other sites More sharing options...
MrBlueYeti Posted May 14, 2019 Author Share Posted May 14, 2019 so far i have come up with this: AddPrefabPostInit("firepit", function(inst) local function onextinguish(inst) inst:AddComponent("burnable") end end) The game loads but it doesn't seem to be working. I also tried copy pasting the code of the "log" prefab and change every "log" specification in there to "flint" for testing purposes but that also doesn't allow me to light the flint. Is the ability to light a prefab with a torch stored in another folder or is it impossible to make a prefab lightable? Thanks in advance. Link to comment Share on other sites More sharing options...
Ultroman Posted May 14, 2019 Share Posted May 14, 2019 Your code simply declares a function and doesn't call it or hook it up to anything. Like I said, the firepit goes out when it has no more fuel. It turns on when you give it fuel. You can't light it without fuel, and even if you find a way, it'll turn off instantly because it has no fuel. The only way you can do this, is to make your own action for lighting a firepit (in order to get the highlighting and click-to-do-action thing working), and what that action must do is to add free fuel to the firepit. There is no way to just turn on the firepit. It needs fuel. Link to comment 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