forked from DFHack/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
force.lua
30 lines (27 loc) · 767 Bytes
/
force.lua
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
-- Forces an event (wrapper for modtools/force)
local utils = require 'utils'
local args = {...}
if #args < 1 then qerror('missing event type') end
if args[1]:find('help') then
print(dfhack.script_help())
return
end
local eventType = nil
for _, type in ipairs(df.timed_event_type) do
if type:lower() == args[1]:lower() then
eventType = type
end
end
if not eventType then
qerror('unknown event type: ' .. args[1])
end
local newArgs = {'--eventType', eventType}
if eventType == 'Caravan' or eventType == 'Diplomat' then
table.insert(newArgs, '--civ')
if not args[2] then
table.insert(newArgs, 'player')
else
table.insert(newArgs, args[2])
end
end
dfhack.run_script('modtools/force', table.unpack(newArgs))