[Done] Inserting minable help

Place to get help with not working mods / modding interface.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1456
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

[Done] Inserting minable help

Post by TheSAguy »

Hi,

I'm trying to make Spawners and Worms Minable, when you play with NE Buildings.
I'm testing if the entity has a minable settign already. In most cases it should not, but if it has, then skip the insert, if not, then I insert mine mining result.
Currently the first test is always true so nothing is inserted. If I remove the test, I get an error on the insert part.

My below code is not working and not exactly sure why:

Code: Select all

--- All other Spawners
local spawners = data.raw["unit-spawner"]
for k, v in pairs(spawners) do

	if v.minable then
		break		
	else
		local minable = {hardness = 1.5, mining_time = 1.6, results = {{type="item", name="Natural_Evolution_Biter-Spawner-exhausted", amount=1},}}
		table.insert(v.minable, minable)
	end

end

--- All other turrets
local worms = data.raw["turret"]
for k, v in pairs(worms) do

	if v.minable then
		break		
	else
		local minable = {hardness = 0.5, mining_time = 1.6, results = {{type="item", name="small-worm-hatching-exhausted", amount=1},}}
		table.insert(v.minable, minable)
	end

end

Thanks.
Last edited by TheSAguy on Tue Jul 24, 2018 6:50 pm, edited 1 time in total.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Inserting minable help

Post by eradicator »

Code: Select all

--- All other Spawners
local spawners = data.raw["unit-spawner"]
for k, v in pairs(spawners) do
   if not (v.minable and (v.minable.result or v.minable.results)) then
      v.minable = {hardness = 1.5, mining_time = 1.6, results = {{type="item", name="Natural_Evolution_Biter-Spawner-exhausted", amount=1},}}
   end
end

Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1456
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Inserting minable help

Post by TheSAguy »

Thanks Eradicator!
That did it.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [Done] Inserting minable help

Post by eradicator »

So the best "weapon" against biter nests is a mining axe now? Sounds pretty imbalanaced when combined with long reach mods.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1456
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: [Done] Inserting minable help

Post by TheSAguy »

You can't mine something that's has an "Enemy" force.
In my mod I have a building that can convert bases, worms and units to the players force.
So now, you can move (mine) those converted bases and worms.
Post Reply

Return to “Modding help”