deconstructible-tile-proxy in "on_marked_for_deconstruction"

This subforum contains all the issues which we already resolved.
Post Reply
User avatar
DemiPixel
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Mon Mar 21, 2016 7:27 am
Contact:

deconstructible-tile-proxy in "on_marked_for_deconstruction"

Post 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).

Rseding91
Factorio Staff
Factorio Staff
Posts: 13198
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: deconstructible-tile-proxy in "on_marked_for_deconstruction"

Post 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.
If you want to get ahold of me I'm almost always on Discord.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13198
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: deconstructible-tile-proxy in "on_marked_for_deconstruction"

Post 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.
If you want to get ahold of me I'm almost always on Discord.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13198
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: deconstructible-tile-proxy in "on_marked_for_deconstruction"

Post by Rseding91 »

Nevermind, I figured out what's going on :) I'll fix it for 0.13.5.
If you want to get ahold of me I'm almost always on Discord.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13198
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: deconstructible-tile-proxy in "on_marked_for_deconstruction"

Post by Rseding91 »

Fixed for 0.13.5.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Resolved Problems and Bugs”