How to get owner of construction robot?

Place to get help with not working mods / modding interface.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

How to get owner of construction robot?

Post by darkfrei »

Hi all! How to get the owner of the construction robot? Player index for personal roboport or nothing, if it was from standard roboport.
User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1631
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: How to get owner of construction robot?

Post by jodokus31 »

I stumbled over this, when searching an answer for this question.

My solution on this is now, that the robot has a force and not a unique owner.
So, the owners are all players of the force

Code: Select all

        local players = {}
        for _, player in pairs(game.players) do
        if player.force.name == robot.force.name then
          table.insert(players, player)
        end
Post Reply

Return to “Modding help”