File tree 1 file changed +29
-20
lines changed
1 file changed +29
-20
lines changed Original file line number Diff line number Diff line change 1
- local flows_to_delete = {}
1
+ -- @ module = true
2
2
3
- function clearSmoke (flows )
4
- local success
5
- for i = # flows - 1 , 0 , - 1 do
6
- local flow = flows [i ]
7
- if flow .type == df .flow_type .Smoke then
8
- flows :erase (i )
9
- flows_to_delete [flow ] = true
10
- success = true
11
- end
3
+ function removeFlow (flow ) -- have DF remove the flow
4
+ if not flow then
5
+ return
12
6
end
13
- return success
14
- end
7
+ flow .flags .DEAD = true
15
8
16
- clearSmoke (df .global .flows )
9
+ local block = dfhack .maps .getTileBlock (flow .pos )
10
+ if block then
11
+ block .flow_pool .flags .active = true
12
+ else
13
+ df .global .world .orphaned_flow_pool .flags .active = true
14
+ end
15
+ end
17
16
18
- for _ ,block in pairs (df .global .world .map .map_blocks ) do
19
- if clearSmoke (block .flows ) then
20
- dfhack .maps .enableBlockUpdates (block , true )
17
+ function removeFlows (flow_type ) -- remove all if flow_type is nil
18
+ local count = 0
19
+ for _ ,flow in ipairs (df .global .flows ) do
20
+ if not flow .flags .DEAD and (flow_type == nil or flow .type == flow_type ) then
21
+ removeFlow (flow )
22
+ count = count + 1
23
+ end
21
24
end
25
+
26
+ return count
22
27
end
23
28
24
- for flow ,_ in pairs (flows_to_delete ) do
25
- if flow then
26
- flow :delete ()
29
+ function clearSmoke ()
30
+ if dfhack .isWorldLoaded () then
31
+ print ((' %d smoke flows removed.' ):format (removeFlows (df .flow_type .Smoke )))
32
+ else
33
+ qerror (' World not loaded!' )
27
34
end
28
- end
35
+ end
36
+
37
+ clearSmoke ()
You can’t perform that action at this time.
0 commit comments