forked from DFHack/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
force.lua
44 lines (36 loc) · 1.03 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
-- Forces an event (wrapper for modtools/force)
--[====[
force
=====
A simpler wrapper around the `modtools/force` script.
Usage:
- ``force event_type``
- ``force event_type civ_id`` - civ ID required for ``Diplomat`` and ``Caravan``
events
See `modtools/force` for a complete list of event types.
]====]
local utils = require 'utils'
local args = {...}
if #args < 1 then qerror('missing event type') end
if args[1]:find('help') then
return print(dfhack.script_help())
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
if not args[2] then
qerror('event type ' .. eventType .. ' requires civ ID')
else
table.insert(newArgs, '-civ')
table.insert(newArgs, args[2])
end
end
dfhack.run_script('modtools/force', table.unpack(newArgs))