amazingGob Posted August 15, 2025 Share Posted August 15, 2025 I'm very new to modding, how do I make my character to cause nearby players to gain wetness. I know sanity aura is a thing but i don't think there's one for wetness? Link to comment https://forums.kleientertainment.com/forums/topic/167583-aura-for-wetness/ Share on other sites More sharing options...
Edible Coal Posted August 15, 2025 Share Posted August 15, 2025 modify it so it give nearby players wetness 1 1 Link to comment https://forums.kleientertainment.com/forums/topic/167583-aura-for-wetness/#findComment-1831913 Share on other sites More sharing options...
amazingGob Posted August 15, 2025 Author Share Posted August 15, 2025 3 hours ago, Edible Coal said: modify it so it give nearby players wetness how do i do that? is there any example? i'm very new to coding 😔 Link to comment https://forums.kleientertainment.com/forums/topic/167583-aura-for-wetness/#findComment-1831926 Share on other sites More sharing options...
FerniFrenito Posted August 15, 2025 Share Posted August 15, 2025 Hi. I think you can use the FindPlayersInRange(x, y, z, range, isalive) function from simutils.lua. It doesn't look like you need to import simutils.lua to use it because none of the implementations I've seen do. The function returns a list of all player instances within the specified range. You can use that to modify the wetness aura, but I haven't looked into how that aura works. If you need help with that, I can look into it for you. I hope this is useful for you. 1 Link to comment https://forums.kleientertainment.com/forums/topic/167583-aura-for-wetness/#findComment-1831950 Share on other sites More sharing options...
amazingGob Posted August 17, 2025 Author Share Posted August 17, 2025 On 8/15/2025 at 7:16 PM, FerniFrenito said: Hi. I think you can use the FindPlayersInRange(x, y, z, range, isalive) function from simutils.lua. It doesn't look like you need to import simutils.lua to use it because none of the implementations I've seen do. The function returns a list of all player instances within the specified range. You can use that to modify the wetness aura, but I haven't looked into how that aura works. If you need help with that, I can look into it for you. I hope this is useful for you. With the help of a more code inclined friend and this post , we came up with this -- DoPeriodicTask calls the given function every X seconds. -- I set it to 1.0. You can set it to e.g. 0.5 seconds if you want. inst:DoPeriodicTask(1.0, function(inst) -- Do nothing if the player is dead. if inst.components.health:IsDead() or inst:HasTag("playerghost") then return end -- Store the position of the player in x, y, z variables. local x,y,z = inst.Transform:GetWorldPosition() -- Description of important function, which finds specific entities within a range: -- TheSim:FindEntities(x, y, z, radius, mustHaveTags, cantHaveTags, mustHaveOneOfTheseTags) -- We have limited it to any player that is not a ghost or in limbo. -- I have set the radius to be the one used for standard negative auras. You can set it to whatever radius you want. local ents = TheSim:FindEntities(x, y, z, TUNING.SANITY_EFFECT_RANGE, {"player"}, {"playerghost", "INLIMBO"}, nil) for i, v in ipairs(ents) do if v and v:IsValid() and v.prefab ~= "my_character" then v.components.moisture:DoDelta(0.5, true) -- "true" disables the pulse on the badge and disables that it plays a sound. end end end) which seems to work. But i noticed that when you stand near them, even though the wetness was going up, the indicator arrow was still pointing down Link to comment https://forums.kleientertainment.com/forums/topic/167583-aura-for-wetness/#findComment-1832074 Share on other sites More sharing options...
FerniFrenito Posted August 17, 2025 Share Posted August 17, 2025 (edited) Hi hi hi hi. Don't use DoDelta because it doesn't activate all the things that are supposed to happen when a character gets wet. Instead, use this: playerInst.components.moisture:AddRateBonus(playerInst, 1, "name_bonus") Here, playerInst, the first parameter, is your "v" variable from the loop (I think, I'm not entirely sure, but I saw the code and assumed it was a player instance; besides, putting a player instance there doesn't cause any bugs). The second parameter is the value you want to use for the wetness aura, and the third is the bonus name. If you want to remove the bonus, you must use: playerInst.components.moisture:RemoveRateBonus(PlayerInst, "name_bonus") You don't need to use a DoPeriodicTask for this, and the great thing about this method is that the game automatically factors in other sources of wetness. I hope this was helpful. (^▽^) Edited August 17, 2025 by FerniFrenito I forgot to mention which object the RemoveRateBonus method belongs to. Link to comment https://forums.kleientertainment.com/forums/topic/167583-aura-for-wetness/#findComment-1832112 Share on other sites More sharing options...
amazingGob Posted August 18, 2025 Author Share Posted August 18, 2025 8 hours ago, FerniFrenito said: Hi hi hi hi. Don't use DoDelta because it doesn't activate all the things that are supposed to happen when a character gets wet. Instead, use this: playerInst.components.moisture:AddRateBonus(playerInst, 1, "name_bonus") Here, playerInst, the first parameter, is your "v" variable from the loop (I think, I'm not entirely sure, but I saw the code and assumed it was a player instance; besides, putting a player instance there doesn't cause any bugs). The second parameter is the value you want to use for the wetness aura, and the third is the bonus name. If you want to remove the bonus, you must use: playerInst.components.moisture:RemoveRateBonus(PlayerInst, "name_bonus") You don't need to use a DoPeriodicTask for this, and the great thing about this method is that the game automatically factors in other sources of wetness. I hope this was helpful. (^▽^) ohhh i see thank you! But how do i detect when the player leave the range to remove it? Link to comment https://forums.kleientertainment.com/forums/topic/167583-aura-for-wetness/#findComment-1832130 Share on other sites More sharing options...
FerniFrenito Posted August 18, 2025 Share Posted August 18, 2025 You can create a table to hold the players within range: local players_in_range = {} Then, in your loop, add the players to the table and apply the bonus to them: for i, v in ipairs(ents) do if v and v:IsValid() and v.prefab ~= "my_character" then players_in_range[v.userid] = v v.components.moisture:AddRateBonus(v, 1, "WetWet") end end Now, loop through the AllPlayers table and check if each player is in the players_in_range list using their userid (since it's a string, it's faster to compare than a full object). If they're not, remove the wetness bonus using the same ID: for i, v in ipairs(AllPlayers) do if players_in_range[v.userid] == nil then -- player out of range v.components.moisture:RemoveRateBonus(v, 1, "WetWet") end end Make sure that players_in_range is created fresh every time this set of instructions runs. Otherwise, its values will persist from the previous players who were in range. I can't test this code because I don't have anyone to test it with (ㅠ﹏ㅠ) , but if you find any errors, let me know and I'll fix them. This algorithm isn't the most computationally efficient, but since there are usually no more than 100 players per game, I don't think it will cause performance issues. I hope it helps you (◠‿◠) 1 Link to comment https://forums.kleientertainment.com/forums/topic/167583-aura-for-wetness/#findComment-1832168 Share on other sites More sharing options...
amazingGob Posted August 21, 2025 Author Share Posted August 21, 2025 Thank you! I came up with this, the counter show it properly now, but it doesn't remove the rate bonus when the character leave the range. I'm also not sure how to do it without DoPeriodicTask, im very new to Lua (and coding in general lol) inst.wet_players = {} -- DoPeriodicTask calls the given function every X seconds. -- I set it to 1.0. You can set it to e.g. 0.5 seconds if you want. inst:DoPeriodicTask(1.0, function(inst) -- Do nothing if the player is dead. if inst.components.health:IsDead() or inst:HasTag("playerghost") then return end -- Store the position of the player in x, y, z variables. local x,y,z = inst.Transform:GetWorldPosition() -- Description of important function, which finds specific entities within a range: -- TheSim:FindEntities(x, y, z, radius, mustHaveTags, cantHaveTags, mustHaveOneOfTheseTags) -- We have limited it to any player that is not a ghost or in limbo. -- I have set the radius to be the one used for standard negative auras. You can set it to whatever radius you want. local ents = TheSim:FindEntities(x, y, z, TUNING.SANITY_EFFECT_RANGE, {"player"}, {"playerghost", "INLIMBO"}, nil) local players_in_range = {} for i, v in ipairs(ents) do if v and v:IsValid() and v.prefab ~= "my_character" then players_in_range[v.userid] = v if inst.wet_players[v.userid] == nil then v.components.moisture:AddRateBonus(v, 1, "WetWet") end end end for i, v in ipairs(AllPlayers) do if players_in_range[v.userid] == nil and inst.wet_players[v.userid] ~= nil then -- wet player out of range v.components.moisture:RemoveRateBonus(v, 1, "WetWet") end end inst.wet_players = players_in_range end) On 8/18/2025 at 8:27 PM, FerniFrenito said: I can't test this code because I don't have anyone to test it with (ㅠ﹏ㅠ) , but if you find any errors, let me know and I'll fix them. This algorithm isn't the most computationally efficient, but since there are usually no more than 100 players per game, I don't think it will cause performance issues. I'm also testing it alone lol. I just spawn in the mod character using the Too Many Items Plus mod to check Link to comment https://forums.kleientertainment.com/forums/topic/167583-aura-for-wetness/#findComment-1832434 Share on other sites More sharing options...
Edible Coal Posted August 21, 2025 Share Posted August 21, 2025 5 hours ago, amazingGob said: Thank you! I came up with this, the counter show it properly now, but it doesn't remove the rate bonus when the character leave the range. I'm also not sure how to do it without DoPeriodicTask, im very new to Lua (and coding in general lol) inst.wet_players = {} -- DoPeriodicTask calls the given function every X seconds. -- I set it to 1.0. You can set it to e.g. 0.5 seconds if you want. inst:DoPeriodicTask(1.0, function(inst) -- Do nothing if the player is dead. if inst.components.health:IsDead() or inst:HasTag("playerghost") then return end -- Store the position of the player in x, y, z variables. local x,y,z = inst.Transform:GetWorldPosition() -- Description of important function, which finds specific entities within a range: -- TheSim:FindEntities(x, y, z, radius, mustHaveTags, cantHaveTags, mustHaveOneOfTheseTags) -- We have limited it to any player that is not a ghost or in limbo. -- I have set the radius to be the one used for standard negative auras. You can set it to whatever radius you want. local ents = TheSim:FindEntities(x, y, z, TUNING.SANITY_EFFECT_RANGE, {"player"}, {"playerghost", "INLIMBO"}, nil) local players_in_range = {} for i, v in ipairs(ents) do if v and v:IsValid() and v.prefab ~= "my_character" then players_in_range[v.userid] = v if inst.wet_players[v.userid] == nil then v.components.moisture:AddRateBonus(v, 1, "WetWet") end end end for i, v in ipairs(AllPlayers) do if players_in_range[v.userid] == nil and inst.wet_players[v.userid] ~= nil then -- wet player out of range v.components.moisture:RemoveRateBonus(v, 1, "WetWet") end end inst.wet_players = players_in_range end) I'm also testing it alone lol. I just spawn in the mod character using the Too Many Items Plus mod to check dont save players_in_range, it is suppose to be empty everytime you check Link to comment https://forums.kleientertainment.com/forums/topic/167583-aura-for-wetness/#findComment-1832448 Share on other sites More sharing options...
amazingGob Posted August 27, 2025 Author Share Posted August 27, 2025 thank you everyone, i think everything works how i wanted it to now! here's the code inst.wet_players = {} -- DoPeriodicTask calls the given function every X seconds. -- I set it to 1.0. You can set it to e.g. 0.5 seconds if you want. inst:DoPeriodicTask(1.0, function(inst) -- Do nothing if the player is dead. if inst.components.health:IsDead() or inst:HasTag("playerghost") then return end -- Store the position of the player in x, y, z variables. local x,y,z = inst.Transform:GetWorldPosition() -- Description of important function, which finds specific entities within a range: -- TheSim:FindEntities(x, y, z, radius, mustHaveTags, cantHaveTags, mustHaveOneOfTheseTags) -- We have limited it to any player that is not a ghost or in limbo. -- I have set the radius to be the one used for standard negative auras. You can set it to whatever radius you want. local ents = TheSim:FindEntities(x, y, z, TUNING.SANITY_EFFECT_RANGE, {"player"}, {"playerghost", "INLIMBO"}, nil) -- check for players near finn, and add a wetness aura to them local players_in_range = {} for i, v in ipairs(ents) do if v and v:IsValid() and v ~= inst then players_in_range[v.userid] = v if inst.wet_players[v.userid] == nil then inst.wet_players[v.userid] = v v.components.moisture:AddRateBonus(v, 0.5, "WetWet") end end end -- check all players that finn was giving the wet aura to and remove it if they're out of range for i, v in ipairs(AllPlayers) do if players_in_range[v.userid] == nil and inst.wet_players[v.userid] ~= nil then -- wet player out of range inst.wet_players[v.userid] = nil v.components.moisture:RemoveRateBonus(v, "WetWet") end end end) 1 Link to comment https://forums.kleientertainment.com/forums/topic/167583-aura-for-wetness/#findComment-1833025 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