dfhack/scripts/modtools/spawn-flow.lua

93 lines
2.0 KiB
Lua

2014-07-03 17:22:01 -06:00
--scripts/modtools/spawn-flow.lua
--author expwnent
--spawns flows at locations
2015-10-23 17:57:04 -06:00
--[[=begin
2014-07-03 17:22:01 -06:00
2015-10-23 17:57:04 -06:00
modtools/spawn-flow
===================
Creates flows at the specified location.
=end]]
2014-07-03 17:22:01 -06:00
local utils = require 'utils'
2014-07-09 04:21:52 -06:00
validArgs = validArgs or utils.invert({
2014-07-03 17:22:01 -06:00
'help',
'material',
'flowType',
'location',
'flowSize',
})
local args = utils.processArgs({...}, validArgs)
if args.help then
print([[scripts/modtools/spawn-flow.lua
arguments:
-help
print this help message
-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
]])
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
args.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
args.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, args.flowType, mat_type, mat_index, args.flowSize)