forked from DFHack/scripts
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforce.lua
More file actions
Latest commit
58 lines (50 loc) · 1.53 KB
/
Copy pathforce.lua
File metadata and controls
58 lines (50 loc) · 1.53 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
localwildlife=reqscript('fix/wildlife')
localfunctionfindCiv(civ)
ifciv=='player' thenreturndf.historical_entity.find(df.global.plotinfo.civ_id) end
iftonumber(civ) thenreturndf.historical_entity.find(tonumber(civ)) end
civ=string.lower(tostring(civ))
for_,entityinipairs(df.global.world.entities.all) do
ifstring.lower(entity.entity_raw.code) ==civthenreturnentityend
end
end
localargs= { ... }
if#args<1thenqerror('missing event type') end
ifargs[1]:find('help') then
print(dfhack.script_help())
return
end
localeventType=args[1]:upper()
-- handle synthetic events
ifeventType=='WILDLIFE' then
wildlife.free_all_wildlife(args[2] =='all')
return
end
-- handle native events
for_, typeinipairs(df.timed_event_type) do
iftype:lower() ==args[1]:lower() then
eventType=type
end
end
ifnotdf.timed_event_type[eventType] then
qerror('unknown event type: ' ..args[1])
end
ifeventType=='FeatureAttack' then
qerror('Event type: FeatureAttack is not currently supported')
end
localciv
ifeventType=='Caravan' oreventType=='Diplomat' then
civ=findCiv(args[2] or'player')
ifnotcivthen
qerror('unable to find civilization: '..tostring(civ))
end
elseifeventType=='Migrants' then
civ=findCiv('player')
end
df.global.timed_events:insert('#', {
new=true,
type=df.timed_event_type[eventType],
season=df.global.cur_season,
season_ticks=df.global.cur_season_tick,
entity=civ,
feature_ind=-1,
})