Setting a value for multiple items in a grid

Place to get help with not working mods / modding interface.
Post Reply
Sigor
Burner Inserter
Burner Inserter
Posts: 19
Joined: Sun Nov 20, 2016 5:07 pm
Contact:

Setting a value for multiple items in a grid

Post by Sigor »

How to get to all equipment with the same name in a vehicle grid and read/set their energy?

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Setting a value for multiple items in a grid

Post by Nexela »

Code: Select all

if vehicle.grid then
  for _, eq in pairs vehicle.grid.equipment do
    if eq.name == "eq-name" then
      eq.energy = 0
    end
  end
end

Post Reply

Return to “Modding help”