Page 1 of 1

entity.minable not changeable?

Posted: Tue Aug 30, 2016 11:43 pm
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

Re: entity.minable not changeable?

Posted: Wed Aug 31, 2016 12:01 am
by Rseding91

Code: Select all

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

Code: Select all

player.selected.minable = false

Re: entity.minable not changeable?

Posted: Wed Aug 31, 2016 12:06 am
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!