-
Notifications
You must be signed in to change notification settings - Fork 3
/
jobs.lua
46 lines (40 loc) · 1.14 KB
/
jobs.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
45
46
local _ENV = mkmodule('hack.scripts.http.jobs')
local tile_attrs = df.tiletype.attrs
function assignJobToUnit(job,unit,from_pos)
if unit.job.current_job ~= nil then
--unassignJob(unit)
return false
end
job.general_refs:insert("#",{new=df.general_ref_unit_workerst,unit_id=unit.id})
unit.job.current_job=job
unit.path.dest:assign(from_pos or unit.pos)
end
function clear_path( unit )
unit.path.path.x:resize(0)
unit.path.path.y:resize(0)
unit.path.path.z:resize(0)
end
function pickup_equipment( unit,item )
if unit.job.current_job then
return false
end
local job=df.job:new()
job.job_type=df.job_type.PickupEquipment
assignJobToUnit(job,unit,copyall(item.pos))
job.items:insert("#",{new=true,item=item,job_item_idx=0})
dfhack.job.linkIntoWorld(job,true)
return true
end
function fish( unit, pos )
if unit.job.current_job then
return false
end
local job=df.job:new()
job.job_type=df.job_type.Fish
assignJobToUnit(job,unit,pos)
dfhack.job.linkIntoWorld(job,true)
clear_path(unit)
return true
end
return _ENV
--:lua require'hack.scripts.http.jobs'.pickup_equipment(df.unit.find(1573),df.item.find(4071))