entity.minable not changeable?

Bugs that are actually features.
Post Reply
devilwarriors
Filter Inserter
Filter Inserter
Posts: 311
Joined: Sat Jan 09, 2016 1:11 am
Contact:

entity.minable not changeable?

Post by devilwarriors »

hi,

trying to use entity.minable with player.selected to disable an entity from being mined.
The api say its a read/write variable, but I can only read, changing it does nothing.

here a simplified version of my code, that you can paste in a control.lua to test

it should turn any entity that you're pointing at non minable and print false, but it just always print true and things stay minable.

Code: Select all

script.on_event(defines.events.on_tick,
  function(event)
    for player_index, player in pairs(game.players) do
      if player.selected ~= nil then
        log(tostring(player.selected.name))
        log(tostring(player.selected.minable))
        player.selected.minable = "false"
        log(tostring(player.selected.minable))
      end
    end
  end
)

function log(message)
  if game ~= nil then
    for index, player in pairs(game.players) do
      player.print(message)
    end
  end
end
Thanks

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

Re: entity.minable not changeable?

Post by Rseding91 »

Code: Select all

player.selected.minable = "false"
The string "false" is incorrect. It should be:

Code: Select all

player.selected.minable = false
If you want to get ahold of me I'm almost always on Discord.

devilwarriors
Filter Inserter
Filter Inserter
Posts: 311
Joined: Sat Jan 09, 2016 1:11 am
Contact:

Re: entity.minable not changeable?

Post by devilwarriors »

Rseding91 wrote:

Code: Select all

player.selected.minable = "false"
The string "false" is incorrect. It should be:

Code: Select all

player.selected.minable = false
oh weird I had problem in some place with passing false directly and setting it as a string helped.

But yeah that worked, thanks!

Post Reply

Return to “Not a bug”