Jump to content

Working on function (need help)


Recommended Posts

Hello!

Please tell me, how can I remove unnecessary lines in a file of a certain prefab using this or similar function?

AddPrefabPostInit("bedroll_straw", function(inst)
	if TUNING.BEDROLL_STRAW_USES > 1 then
		inst:AddComponent("finiteuses")
		inst.components.finiteuses:SetConsumption(GLOBAL.ACTIONS.SLEEPIN, 1)
		inst.components.finiteuses:SetMaxUses(TUNING.BEDROLL_STRAW_USES)
		inst.components.finiteuses:SetUses(TUNING.BEDROLL_STRAW_USES)
	end
end)

I need to remove these two lines of code for prefab "bedroll_straw":
    inst:AddComponent("stackable")
    inst.components.stackable.maxsize = TUNING.STACK_SIZE_LARGEITEM

I don't want to modify this prefab file.
Can I do this using only code in modmain.lua?

Thank you for attention.

Edited by Tezumoto
Link to comment
Share on other sites

11 minutes ago, CarlZalph said:

if inst.components.stackable
then
    inst:RemoveComponent("stackable")
end

 

So it's so simple :D
Thanks, with this code everything works great.

Edited by Tezumoto
Link to comment
Share on other sites

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
 Share

×
  • Create New...