Skip to content

Commit

Permalink
Add task parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
kinbei committed Apr 12, 2024
1 parent bdc6d2c commit 184ad08
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
18 changes: 12 additions & 6 deletions startup/pkg/vaststars.gamerender/gameplay/prototype_cache/task.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ custom_type :
count = 1
12.building_to_backpack
task = {"unknown", 0, 12},
task_params = {building = "xx"}
task_params = {building = "xx", item = "xx", }
count = xx
13.backpack_to_building
task = {"unknown", 0, 13},
task_params = {building = "xx"}
task_params = {building = "xx", item = "xx", }
count = xx
--]]

local function check_path_connected(sx, sy, dx, dy, road)
Expand Down Expand Up @@ -243,11 +245,15 @@ local custom_type_mapping = {
end
return count
end},
[12] = {s = "building_to_backpack", check = function(task_params, progress, building)
return task_params.building == building
[12] = {s = "building_to_backpack", check = function(task_params, progress, building, item, count)
if task_params.building == building and task_params.item == item then
return (progress or 0) + count
end
end},
[13] = {s = "backpack_to_building", check = function(task_params, progress, building)
return task_params.building == building
[13] = {s = "backpack_to_building", check = function(task_params, progress, building, item, count)
if task_params.building == building and task_params.item == item then
return (progress or 0) + count
end
end},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ click_item_handers["chest"] = function(datamodel, e, index)
local base = ibackpack.get_base_entity(gameplay_core.get_world())
if ibackpack.place(gameplay_core.get_world(), base, item.id, item.count) then
ibackpack.pickup(gameplay_world, e, item.id, item.count)
itask.update_progress("building_to_backpack", iprototype.queryById(e.eid).name)
itask.update_progress("building_to_backpack", iprototype.queryById(e.eid).name, iprototype.queryById(item.id).name, item.count)
else
print("click item", "can not place item", index)
end
Expand Down Expand Up @@ -572,15 +572,15 @@ click_item_handers["assembler"] = function(datamodel, e, itype, index)
if c > 0 then
assert(ibackpack.pickup(gameplay_world, base, slot.item, c))
ichest.place_at(gameplay_world, e, index, c)
itask.update_progress("backpack_to_building", iprototype.queryById(e.eid).name)
itask.update_progress("backpack_to_building", iprototype.queryById(e.eid).name, iprototype.queryById(slot.item).name, c)
end
elseif itype == "outputs" then
local slot = assert(ichest.get(gameplay_world, e.chest, index))
local c = math.min(ibackpack.get_capacity(gameplay_world, base, slot.item), slot.amount)
if c > 0 then
ichest.pickup_at(gameplay_world, e, index, c)
assert(ibackpack.place(gameplay_world, base, slot.item, c))
itask.update_progress("building_to_backpack", iprototype.queryById(e.eid).name)
itask.update_progress("building_to_backpack", iprototype.queryById(e.eid).name, iprototype.queryById(slot.item).name, c)
end
end
end
Expand Down

0 comments on commit 184ad08

Please sign in to comment.