Page 1 of 1

deconstructible-tile-proxy in "on_marked_for_deconstruction"

Posted: Tue Jul 05, 2016 12:12 am
by DemiPixel

Code: Select all

script.on_event(defines.events.on_marked_for_deconstruction, function(ev)
    game.players[1].print(tostring(ev.player_index) .. ", " .. tostring(ev.entity.built_by))
    if ev.player_index and game.players[ev.player_index].cheat_mode then
        ev.entity.destroy()
    end
end)
Outputs "nil, nil" when selecting concrete for deconstruction, making it impossible to detect the LuaPlayer who selected it for deconstruction (if any). I would imagine at least ev.player_index would be defined.

I suppose it wouldn't make sense to have a built_by attribute for that entity if we eventually get a marked_by or marked_for_descontruction_by when somebody wants to access the player that marked something for deconstruction (for example, a mod that only allows the original deconstructor to cancel their own deconstruction).

Re: deconstructible-tile-proxy in "on_marked_for_deconstruction"

Posted: Tue Jul 05, 2016 9:39 am
by Rseding91
Tiles don't store who built them and they aren't going to ever do that. They have zero ownership and act like water on the map except you can "mine" them to revert them back to what was under them.

As for the no player index when marking for destruction - that shouldn't happen. I'll look into that and see what I can find.

Re: deconstructible-tile-proxy in "on_marked_for_deconstruction"

Posted: Tue Jul 05, 2016 9:51 am
by Rseding91
Are you sure you get any event at all? Tiles in 0.13 aren't firing the deconstructed event at all when marked for deconstruction.

Re: deconstructible-tile-proxy in "on_marked_for_deconstruction"

Posted: Tue Jul 05, 2016 10:06 am
by Rseding91
Nevermind, I figured out what's going on :) I'll fix it for 0.13.5.

Re: deconstructible-tile-proxy in "on_marked_for_deconstruction"

Posted: Tue Jul 05, 2016 11:03 am
by Rseding91
Fixed for 0.13.5.