Jump to content

Recommended Posts

Hello.

I want to remove the 'inventoryitemmoisture' component from all items. I figure I'd do this by calling InventoryItem:EnableMoisture(false) on all items. However, I have no idea how to get a reference to all items.

Is there a way to do that, without having to write every single name down in an array?

Edited by FlawlessHair

Thank you Arkathorn!

I have no idea where to find the API for Don't Starve, so I would have no way figuring that one out. How did you know about the line 'AddPrefabPostInitAny'? 


EDIT:

Also, the code doesn't seem to work.

AddPrefabPostInitAny(function(inst))
	--Remove moisture from items
	if inst.components.inventoryitem then
		inst.components.inventoryitem:EnableMoisture(false)
	end

	--Remove moisture components
	if inst.components.moisture then
		inst:RemoveComponent("moisture")
	end
end

It gives me the error: 65: Unexpected symbol near ')'

Which is where I placed the extra ) since it seemed missing from your script (2 open and only 1 closing).
Removing it gives me an error saying it expected ')' to close at 65. Not sure what it wants me to do.
 

EDIT2:
Fixed it! Turns out you have to place ')' after the final 'end'. What a weird way to code, but I guess that's how .lua works.

Edited by FlawlessHair

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...