Jump to content

[Modding] Add GetSoilMoistureAtPoint function to farming_manager component


Recommended Posts

Somebody made a feature request for one of my mods that would require me to check the moisture value of a farm tile. Unfortunately, only "IsSoilMoistAtPoint" is accessible, which only tells if it's greater than 0.

The workaround for me would be to replace the entire "scripts/components/farming_manager.lua" with one that adds such a function, which isn't great for forward compatibility.

Instead, I'd like a public "GetSoilMoistureAtPoint" function to be implemented by Klei. (Or a "GetTileMoisture" that could be used in conjunction with "Map:GetTileCoordsAtPoint".)

It looks like you just need access to this table stored in the local variable "tile_data" to get all the information you need. You can get this by searching through the upvalues in one of the various functions referencing the variable with the debug.getupvalue library function. This is commonly known as upvalue hacking.

There isn't a performance cost because you only need to find the reference once.

Archived

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