Jump to content

Recommended Posts

This time I want to figure out how to make burnable things, not burnable anymore. I have an idea but I'm not sure it'll be so easy. I imagine I have to remove the burnable component, right?

Something like:

function FunctionName(inst)    inst:RemoveComponent("burnable")end AddPrefabPostInit("prefabName",FunctionName)

that maybe?

Would that work for both items and structures? I'm not quite clear on what exactly prefabs are. And would everything work fine or would it cause some issue? And more importantly, how exactly would that work? Would an item simply not catch on fire, or would it catch on fire but not turn into ash? I dunno, there's a lot of different burnable things that react differently to being burnt.

That above would work, in theory. Practically, you'd have to remove the propagator component too, since that one handles fire spread and damage to the player.

 

Prefabs are already prepared (prefabricated) entities/instances. If you don't know what an entity or an instance is, look it up in several dictionaries to get an idea, but basically it's an individual object. As such, items and structures are both entities, and even creatures, the inventory bar and the ground itself are entities (not many games handle solid ground or HUD as entities though). Prefabs are a script (a list of stuff) describing groups/types of entities, so they don't have to be created one by one eventhough they act the same.

 

Now, to describe entities, you could use tons of code, but keep in mind why there's prefabs: to sum up the code that's used regularly. So the properties are summed up too, and that's called components.

 

EDIT: actually, you should make the function local, so it only exists where it's needed and used, and doesn't mess things up, e.g: local function FunctionName(inst)

Edited by Mobbstar

Oh, I never knew what that local thing was for.

 

Also, what I specifically want is for some things not to... turn into other things, when on fire for a while. Items not to turn into ash, structures not to turn into burnt structures, etc. But it'd actually be good if they still caught on fire for a while and did damage to things around it. I didn't think they were handled separately, though.

Also, what I specifically want is for some things not to... turn into other things, when on fire for a while. Items not to turn into ash, structures not to turn into burnt structures, etc.

 

On every type of prefab that you wish to prevent from getting destroyed when the burning completes, run this:

if inst.components.burnable then  inst.components.burnable:SetOnBurntFn(nil)	end

(Presumably you want to retain full burning capability on certain things to allow for making charcoal and ash)

Edited by Corrosive

Yeah I don't plan on making trees fireproof or anything, lol. Just a few things.

 

So I suppose I have to put that in a function as usual, and then use the AddPrefabPostInit to add it to each thing. I guess it was, as I imagined, not as simple as removing a component, heh. But even better if I can make things do exactly what I want them to.

 

 

Edit: Hmm, I got an error about a missing an "end". Do if's need an end? I added one and now it looks like this:

local function NoBurn(inst)	if inst.components.burnable then		inst.components.burnable:SetOnBurntFn(nil)   	endendAddPrefabPostInit("pighouse",NoBurn)

Is that correct?

 

 

Edit 2: Well, it's working as intended, which is better than I thought possible (keeping fire functional but not destroying things), so I assume it's correct :p

Edited by Ran

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...