Code: Select all
script.on_event(defines.events.on_tick, function(event)
local interval = 10 * 60 * 1
if game.tick >= interval then
if (game.tick % interval) == 0 then
local X = math.random(-1000,1000)
local Y = math.random(100,1000)
local radius = 32
for y=-10,10 do for x=-10,10 do
local pos1 = {X+math.random(1,50),Y+math.random(1,50)}
if game.surfaces.nauvis.can_place_entity{name = "spitter-spawner", position = pos1} == true then
game.surfaces.nauvis.create_entity({ name="spitter-spawner", position=pos1});
game.forces.player.chart(game.surfaces.nauvis, {{X - radius, Y - radius}, {X + radius, Y + radius}})
end
end
end
end
end
end)
How can I do this if random choose in not generate chunk, then reroll the script again ignore interval?
I I used "is_chunk_generated", but it not works:
Code: Select all
script.on_event(defines.events.on_tick, function(event)
local interval = 10 * 60 * 60
if game.tick >= interval then
if (game.tick % interval) == 0 then
local X = math.random(-200,200)
local Y = math.random(100,200)
local radius = 32
for y=-10,10 do for x=-10,10 do
local pos1 = {X+math.random(1,50),Y+math.random(1,50)}
if game.surfaces.nauvis.can_place_entity{name = "spitter-spawner", position = pos1} == true then
game.surfaces.nauvis.create_entity({ name="spitter-spawner", position=pos1});
game.forces.player.chart(game.surfaces.nauvis, {{X - radius, Y - radius}, {X + radius, Y + radius}})
elseif game.surfaces.nauvis.is_chunk_generated({X, Y}) == false then -- How to reroll the script again ignore interval?
game.print("chunk not generated")
end
end
end
end
end
end
end)