Jump to content

Character's inventory waterproofness?


Recommended Posts

I tried to make that one.
But either I add




It's just not working... Items in my character's inventory still get wet.

What should I do? ;_;

Link to comment
Share on other sites


The "IsWaterproof()" function is just to check the waterproofness of the inventory. You can't pass in a variable and expect it to change anything.


I'm not sure what the second one is doing. What is "inst" referring to? An instance of the inventory? Of your character?



Try this. It overrides the function that checks each inventory slot for waterproofness. "inst" should be referring to your character, so this would go in your character's create fn.

Though I'm not sure if this kind of overriding works the same through prefab files, so you may encounter an error.

local function new_GetWaterproofness(slot)    return TUNING.WATERPROOFNESS_ABSOLUTEendinst.components.inventory.GetWaterproofness = new_GetWaterproofness
Link to comment
Share on other sites

@Coffgirl, according to a wiki page.. "The wetness of an item depends on the wetness of the player when it's in their inventory". Wait for the wetness to go down to 0 and see if it stays that way even when it's raining?


Edit: Add this in too. It should instantly make your character dry again.

Link to comment
Share on other sites

@Coffgirl, ah okay. There should be a way to do it. But I'm not sure why you would want that. Isn't the whole point of being wet that the items you're carrying become wet too?



Put this in your modmain.lua. See if it works.

local function post_moisturelistener(self, inst)	-- Find owner of item, if possible	local owner	if self.inst.components.inventoryitem then		owner =  self.inst.components.inventoryitem.owner		if owner and owner.prefab == "your_character_prefab_name" then			-- Check if the owner is a valid player with inventory and moisture			if owner.components.inventory and owner.components.moisture then				-- Change function to return a 0				self.GetTargetMoisture = function() return 0 end			end -- owner has invt/moisture		end -- prefab name	end -- is invt itemendAddComponentPostInit("moisturelistener", post_moisturelistener)

Remember to change "your_character_prefab_name" accordingly.



Edit: Changed code above. Added a check for "owner" being nil before

owner.prefab == "your_character_prefab_name"
Link to comment
Share on other sites

@Blueberrys I'm sorry!

I'm trying to scripting a bit more but end up your code is not working anymore. D:
(What I was trying to do is stop her sanity drains from high wetness)

Now I don't know what's wrong and where... So I upload my mod here.
I'm sorry, please help me again. Orz


Link to comment
Share on other sites

@Coffgirl, the code I provided earlier was only changing the items. Changing something for your character, such as sanity, would probably use quite a different kind of approach.


I'll have a look at it.


Edit: I tested the mod, and the inventory items are in fact not getting wet for me. Although, I think there is some sort of issue with the sanity.. What was the problem, exactly?


Edit 2: To simply remove the penalty for wetness, add this in your character's create fn:

inst.components.sanity.GetMoistureDelta = function() return 0 end
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...