Hi everydody,
I have simple question that i cant find answer.
When on_robot_built_entity event occur, there is a table named event that contains: robot, created_entity and stack, unfortunately no player_index.
How can i determine which player is owner of this robot? or How can i determine which player is owner of created_entity?
Thank you for answer.
events.on_robot_built_entity
events.on_robot_built_entity
Lenovo Y580 8GB Ram GF660m 128GB SSD W7
Re: events.on_robot_built_entity
Do you really need an accurate player? Why not to use force-wide logic?
Anyway something like this could work(untested):
Anyway something like this could work(untested):
Code: Select all
function robot_owner(robot)
local cells = robot.logistic_network.cells
if #cells ~= 1 then
return nil
end
if not cells[1].mobile then
return nil
end
local owner = cells[1].owner
if owner.type ~= "character" then
return nil
end
return cells[1].owner.associated_player
end
Re: events.on_robot_built_entity
Thx for answer, but your function allways return nil. But this give me a clue. Im checking event.created_entity.owner.name and that works.betrok wrote:Do you really need an accurate player? Why not to use force-wide logic?
Anyway something like this could work(untested):Code: Select all
function robot_owner(robot) local cells = robot.logistic_network.cells if #cells ~= 1 then return nil end if not cells[1].mobile then return nil end local owner = cells[1].owner if owner.type ~= "character" then return nil end return cells[1].owner.associated_player end
Lenovo Y580 8GB Ram GF660m 128GB SSD W7