Jump to content

Help understanding why moisture.lua causes massive performance issues when lots of mobs have that component


Recommended Posts

I added the component moisture to mobs so that they have a wetness meter. While I don't notice performance issues unless it hits about 200+ mobs, other users may not have as beefy a cpu as me. I've tried reading and understanding moisture.lua, but I don't see what part of it is causing lag when lots of mobs gain that component. In base-game, only players and Dragonfly have inst:AddComponent("moisture").

I noticed that there was a moisture_replica.lua, which imo leads me to believe that the developers were aware of this issue and that was there workaround for mobs to get wet when it rains.

I don't have a reason to believe that my code is the issue since it is just simply two separate for loops, one that checks what mobs the user wants enabled, the other to do inst:AddComponent("moisture") to mobs, though if there is something that I don't know, I'd appreciate it.

Attached is modmain.lua, modinfo.lua, moisture.lua, and moisture_replica.lua

modinfo.lua

modmain.lua

moisture.lua

moisture_replica.lua

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