Page 1 of 1

[0.13.1] Lua event triggering incorrectly

Posted: Wed Jun 29, 2016 10:40 pm
by barrykun
The event on_preplayer_mined_item is fired when mining is complete while the description says "Called when the player starts mining something."

Re: [0.13.1] Lua event triggering incorrectly

Posted: Thu Jun 30, 2016 8:47 am
by Rseding91
The description is wrong - the event is correct.

It's called right before the entity is fully mined after the progress bar has hit 100%.

Re: [0.13.1] Lua event triggering incorrectly

Posted: Thu Jun 30, 2016 2:22 pm
by barrykun
In that case, is there any event to check permissions for mining? Lets say *player starts mining entity* check who placed the entity, does this person have permission to mine that? if not cancel the action. I thought I could do that with this event, that's what the name/description would suggest. How can that be solved?

Re: [0.13.1] Lua event triggering incorrectly

Posted: Thu Jun 30, 2016 2:34 pm
by Rseding91
No, Factorio doesn't have any kind of permissions system like that.

Whitelist your server and don't let people join that you don't want to join until the day we might implement such a thing (unlikely).

Re: [0.13.1] Lua event triggering incorrectly

Posted: Thu Jun 30, 2016 8:52 pm
by barrykun
Sorry I think you misunderstood me, the white-list was just an example. and it would not be kept by server it would be kept by the mod.

Like not deconstructing entities that you did not make?

Code: Select all

script.on_event(defines.events.on_preplayer_mined_item, function(event) -- obviously wrong event by the way it works
  if event.entity.built_by ~= game.players[event.player_index].name then
    return false; -- no idea how to tell the game to cancel the action
  end
end)
This code snippet has two flaws, obviously. But don't you think this should be possible? This topic is probably heading more towards suggestion then bug report, sorry about that.

Re: [0.13.1] Lua event triggering incorrectly

Posted: Thu Jun 30, 2016 9:52 pm
by Rseding91
Factorio doesn't currently support any kind of event cancellation.