Found a solution for treefarm-ac with muliple forces

Looking for a mod? Have a review on a mod you'd like to share?
User avatar
provet
Fast Inserter
Fast Inserter
Posts: 133
Joined: Thu Feb 12, 2015 9:49 pm
Contact:

Found a solution for treefarm-ac with muliple forces

Post by provet »

I'm playing a multiplayer game where every player have a different faction/force. We don't share the same technology-tree and we all have our own bases. We use lots of mods, most of them work (believe it or not). All of the entities from treefarm-ac works except the important cokery. It's placed as the force "player" and not as my force "blue".

After some questioning and digging I found the following fix:

Path:Factorio/mods/Treefarm-AC 0.2.1.zip/control.lua

Code: Select all

require "defines"



game.on_event(defines.events.on_built_entity, function(event)
	if event.created_entity.name == "tf-cokery-dummy" then
		local force = game.players[event.player_index].force
      game.get_surface("nauvis").create_entity{name = "tf-cokery", position = event.created_entity.position, force = force}
		event.created_entity.destroy()
	end
end)
Changes:
Added: "local force = game.players[event.player_index].force"
Changed to this: "force = force"

Now the cokery is placed as my current force



Why does this matter? Because force.player is an enemy of force.blue :) so I can't interact with force.players entities
Post Reply

Return to “Questions, reviews and ratings”