z_mirror/FluidMustFlow

git clone https://git.raiguard.me/z_mirror/FluidMustFlow

Caleb HeuerFix simulations33db450

trunk
1.8 KiB63 linesraw
1game.simulation.camera_position = { 0, 0.5 }
2
3storage.player = game.simulation.create_test_player({ name = "foo" })
4storage.character = storage.player.character
5storage.character.teleport({ 0, 3 })
6
7game.simulation.camera_player = storage.player
8
9step_0 = function()
10  game.simulation.camera_player_cursor_position = { 0, 3 }
11  game.simulation.camera_player_cursor_direction = defines.direction.east
12  target_cursor_position = { -5, -1 }
13  script.on_nth_tick(1, function()
14    local finished = game.simulation.move_cursor({ position = target_cursor_position })
15    if finished then
16      step_1()
17    end
18  end)
19end
20
21step_1 = function()
22  storage.character.cursor_stack.set_stack({ name = "duct-small", count = 10 })
23  target_cursor_position = { 5, -1 }
24  script.on_nth_tick(1, function()
25    local finished = game.simulation.move_cursor({ position = target_cursor_position, speed = 0.1 })
26
27    if storage.player.can_build_from_cursor({ position = game.simulation.camera_player_cursor_position }) then
28      storage.player.build_from_cursor({
29        position = game.simulation.camera_player_cursor_position,
30        direction = defines.direction.east,
31      })
32    end
33
34    if finished then
35      step_2()
36    end
37  end)
38end
39
40step_2 = function()
41  target_cursor_position = { 0, 3 }
42  script.on_nth_tick(1, function()
43    local finished = game.simulation.move_cursor({ position = target_cursor_position })
44    if finished then
45      finish()
46    end
47  end)
48end
49
50finish = function()
51  storage.finished_tick = game.tick
52
53  script.on_nth_tick(1, function()
54    if game.tick == storage.finished_tick + 90 then
55      for _, entity in pairs(game.surfaces[1].find_entities_filtered({ name = { "duct", "duct-long" } })) do
56        entity.destroy()
57      end
58      step_0()
59    end
60  end)
61end
62
63step_0()