Page 1 of 1

[Done] Inserting minable help

Posted: Tue Jul 24, 2018 4:04 pm
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.

Re: Inserting minable help

Posted: Tue Jul 24, 2018 5:56 pm
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


Re: Inserting minable help

Posted: Tue Jul 24, 2018 6:50 pm
by TheSAguy
Thanks Eradicator!
That did it.

Re: [Done] Inserting minable help

Posted: Tue Jul 24, 2018 6:55 pm
by eradicator
So the best "weapon" against biter nests is a mining axe now? Sounds pretty imbalanaced when combined with long reach mods.

Re: [Done] Inserting minable help

Posted: Tue Jul 24, 2018 6:58 pm
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.