forked from DFHack/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspawn-flow.lua
More file actions
89 lines (76 loc) · 1.93 KB
/
spawn-flow.lua
File metadata and controls
89 lines (76 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
-- spawns flows at locations
--author expwnent
local usage = [====[
modtools/spawn-flow
===================
Creates flows at the specified location.
Arguments::
-material mat
specify the material of the flow, if applicable
examples:
INORGANIC:IRON
CREATURE_MAT:DWARF:BRAIN
PLANT_MAT:MUSHROOM_HELMET_PLUMP:DRINK
-location [ x y z]
the location to spawn the flow
-flowType type
specify the flow type
examples:
Miasma
Steam
Mist
MaterialDust
MagmaMist
Smoke
Dragonfire
Fire
Web
MaterialGas
MaterialVapor
OceanWave
SeaFoam
-flowSize size
specify how big the flow is
]====]
local utils = require 'utils'
local validArgs = utils.invert({
'help',
'material',
'flowType',
'location',
'flowSize',
})
local args = utils.processArgs({...}, validArgs)
if args.help then
print(usage)
return
end
local mat_index = -1;
local mat_type = -1;
if args.material then
local mat = dfhack.matinfo.find(args.material)
if not mat then
error ('Invalid material: ' .. mat)
end
mat_index = mat.index
mat_type = mat['type']
end
if args.flowSize and not tonumber(args.flowSize) then
error ('Invalid flow size: ' .. args.flowSize)
end
local flowSize = tonumber(args.flowSize or 'z') or 100
if not args.flowType or not df.flow_type[args.flowType] then
error ('Invalid flow type: ' .. (args.flowType or 'none specified'))
end
local flowType = df.flow_type[args.flowType]
if not args.location then
error 'Specify a location.'
end
local pos = df.coord:new();
pos.x = tonumber(args.location[1] or 'a')
pos.y = tonumber(args.location[2] or 'a')
pos.z = tonumber(args.location[3] or 'a')
if not pos.x or not pos.y or not pos.z then
error ('Invalid pos.')
end
dfhack.maps.spawnFlow(pos, flowType, mat_type, mat_index, flowSize)