Train Outpost


Mod that modifies resource spawning to strongly encourage outposts connected via trains

Content
8 years ago
0.13 - 0.14
9
Trains

b can_place_entity Occasionally Called Before Tile is Generated (Spawning on Water)

8 years ago

Resources are being spawned on water because the validity of the target tile is being checked before the tile is generated. As far as I can tell, "can_place_entity" will always return true if the tile is invalid.

You can "fix" the problem by checking "get_surface().get_tile(global_position.x,global_position.y).valid" in "check_resource_position"

It doesn't solve the root problem (occasionally trying to generate resources before the tile exists), but it prevents water spawns. Until the root problem is fixed, a half-assed workaround is to increase resource frequency to offset resource patches that get rejected due to touching an un-generated tile.

8 years ago

After playing around for a few hours, this seems to have solved the problem handily. I replaced the code in the check_resource_position function with the following:

return get_surface().get_tile(global_position.x,global_position.y).valid and get_surface().can_place_entity{name = resource, position = global_position} or false

8 years ago

Hi guys,
thanks for the feedback and suggestions.

I am still struggling to find out why this does not seem to happen with other mods (e.g., RSO).

It is a hen-egg problem. If the player explores a chunk, resources should be generated for the whole region already, so they are there when the player goes further. But that means sometimes generating into the unknown.

Interestingly, it was not a problem for < 0.13.

New response