Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nonblocking caravans #220

Merged
merged 5 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Date: ???
- standardized moss+yaedols module speed bonuses to +100% +200% +300% +400%. no more weird floating point building crafting speeds
- buffed caravan & aerial caravan speed by 40% in order to compensate for previous update
- updated chinese translation (翻译:aotix,基于咸鱼拓展而来。)
- added non blocking mode to caravans
TURD:
- added T.U.R.D unselect infinite tech to allow the indecisive to revert a single T.U.R.D selection
- added a new T.U.R.D: the composter turd. why is it unlocked at military science? don't ask too many questions
Expand Down
1 change: 1 addition & 0 deletions locale/en/caravan.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ map-position={__1__, __2__}
refocus=Refocus
favorite-foods-main=Favorite foods:\n__1__
favorite-foods-sub=__1__ __2__ → __3__ actions
wait=Wait until fulfilled

[caravan-actions]
time-passed=Wait
Expand Down
2 changes: 1 addition & 1 deletion locale/en/tips.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ biofluid=[item=guano] Biofluid network

[pywiki-descriptions]
farming=The flora and fauna of this planet can be processed into multiple useful products. The [item=vrauks] bloodstream contains the useful [fluid=formic-acid] and [item=moondrop] can be processed into [fluid=methane].\n\nAll farmable species fall under one of three kingdoms; plant, animal, or fungi. [item=saps], [item=moss], [item=tree-mk01], [item=fish], and [item=seaweed] can be harvested from the local environment however most aliens must be synthesized through expensive GMO processes in the [entity=creature-chamber-mk01] or [entity=botanical-nursery]. This process will require DNA data stored in a codex such as [item=vrauks-codex] as well as genetic template data from the [entity=data-array].\n\nAfter you have obtained the first species, it’s important to breed further generations to avoid the complicated GMO process. Each kingdom has a unique breeding method.\n\nAnimal - Animal cubs/eggs such as [item=cocoon] can be bred in the [entity=rc-mk01]. This machine requires two parents inserted into the machine’s module slots. Once you have the young pups, each animal can be raised to adulthood in their respective enclosure such as [entity=vrauks-paddock-mk01]. This enclosure also requires adult creatures to be inserted in the module slots.\n\nPlant - Plants require seedlings such as [item=moondrop-seeds] to create the next generation. Convert adult crops into seedlings inside the [entity=botanical-nursery]. These seedlings can then be cultivated into adult crops in large farming structures such as [entity=moondrop-greenhouse-mk01]. Each farm building requires the adult crop to be placed in the module slot. Each cycle will yield more seeds than the input.\n\nFungi - Tiny mushroom spores are plentiful in the atmosphere. The [entity=spore-collector-mk01] will automatically process the air for spore particulates such as [item=fawogae-spore] at no input cost. These spores can then be grown into adult fungi in climatized shroom farms such as [entity=fawogae-plantation-mk01]. The fungi require special substrate material such as [item=fungal-substrate]. These buildings also require adult mushrooms inside the module slots.\n\nIn order to further optimize and increase the output of creature farms further genetic modification is possible up to MK04. This genetic upgrade will increase growth speeds by up to 400%. The most complicated animal species require more advanced data storage methods such as [item=zungror-codex-mk04].
caravans=[item=caravan] is a living, organic logistics creature with 30 inventory slots and a programmable schedule, similar to a locomotive. It utilizes the biter pathfinding AI.\nThe caravan requires food to function. Each action or destination requires the caravan to consume food, with different types of food providing a different number of actions.\nYou can program the caravan to visit any entity. When it reaches its destination, you can program specific actions based on that destination. Caravans cannot be killed by trains or biters. There is also an [item=flyavan].\n\nActions available for different destinations include: \n- Wait: The caravan will stay at the destination. *Does not use food\n- Store Food: The caravan will fill its fuel slots from the destination’s inventory. *Does not use food\n- Fill Cargo: The caravan will extract items until its inventory is full.\n- Empty Cargo: The caravan will empty its inventory.\n- Until caravan has exactly N items: The caravan will pick up or drop off items until it has the specified amount.\n- Until target has exactly N items: The caravan will pick up or drop off items until the outpost has the specified amount.\n- Circuit condition: The caravan will wait at the destination until the circuit condition is met. *Does not use food\n- Collect all autotrash: Collects all items from your player's autotrash inventory.\n\nActions available for different types of destinations include:\n- Player: [Wait, Store Food, Fill Cargo, Empty Cargo, Filtered Pickup, Filtered Dropoff, Collect all autotrash]\n- Outpost: [Wait, Store Food, Fill Cargo, Empty Cargo, Filtered Pickup, Filtered Dropoff, Circuit condition]\n- Another Caravan: [Wait, Store Food, Fill Cargo, Empty Cargo, Filtered Pickup, Filtered Dropoff]\n- Cargo Wagon: [Wait, Fill Cargo, Empty Cargo, Filtered Pickup, Filtered Dropoff]\n- Electric pole: [Wait, Circuit condition]\n- Default: [Wait]\n\nUse middle-click in an [entity=outpost] to set the filter. Don’t forget to leave a slot for food!
caravans=[item=caravan] is a living, organic logistics creature with 30 inventory slots and a programmable schedule, similar to a locomotive. It utilizes the biter pathfinding AI.\nThe caravan requires food to function. Each action or destination requires the caravan to consume food, with different types of food providing a different number of actions.\nYou can program the caravan to visit any entity. When it reaches its destination, you can program specific actions based on that destination. Caravans cannot be killed by trains or biters. There is also an [item=flyavan].\n\nActions available for different destinations include: \n- Wait: The caravan will stay at the destination. *Does not use food\n- Store Food: The caravan will fill its fuel slots from the destination’s inventory. *Does not use food\n- Fill Cargo (waiting checked): The caravan will extract items until its inventory is full.\n- Fill Cargo (waiting unchecked): The caravan will pick up anything that’s there and then execute the next action. \n- Empty Cargo (waiting checked): The caravan will empty its inventory and only continue if its inventory is completely empty .\n- Empty Cargo (waiting unchecked): The caravan will try to empty its inventory and then execute the next action, potentially leaving items in its inventory.\n- Until caravan has exactly N items (waiting checked): The caravan will pick up or drop off items until it has the specified amount.\n- Until caravan has exactly N items (waiting unchecked): The caravan will try to pick up or drop off items until it has the specified amount, immediately executing the next action if that's not possible. \n- Until target has exactly N items (waiting checked): The caravan will pick up or drop off items until the outpost has the specified amount.\n- Until target has exactly N items (waiting unchecked): The caravan will pick up or drop off items until the outpost has the specified amount, immediately executing the next action if that's not possible.\n- Circuit condition: The caravan will wait at the destination until the circuit condition is met. *Does not use food\n- Collect all autotrash: Collects all items from your player's autotrash inventory.\n\nActions available for different types of destinations include:\n- Player: [Wait, Store Food, Fill Cargo, Empty Cargo, Filtered Pickup, Filtered Dropoff, Collect all autotrash]\n- Outpost: [Wait, Store Food, Fill Cargo, Empty Cargo, Filtered Pickup, Filtered Dropoff, Circuit condition]\n- Another Caravan: [Wait, Store Food, Fill Cargo, Empty Cargo, Filtered Pickup, Filtered Dropoff]\n- Cargo Wagon: [Wait, Fill Cargo, Empty Cargo, Filtered Pickup, Filtered Dropoff]\n- Electric pole: [Wait, Circuit condition]\n- Default: [Wait]\n\nUse middle-click in an [entity=outpost] to set the filter. Don’t forget to leave a slot for food!
digosaurus=[item=digosaurus] is one of the native species to this planet. Over years of evolution, they have adapted to collect and use [item=nexelit-ore] as an energy source. Exploit it.\nDig-o-saurus must be placed in the [entity=dino-dig-site]. The dig site has a range which it can mine the nexelit. It also requires electricity.\n\nDig-o-saurus requires food to work. Each food allows the Dig-o-saurs gather more ores in the same trip.\n[item=guts] → 1 ore\n[item=meat] → 2 ores\n[item=workers-food] → 8 ores\n[item=workers-food-02] → 16 ores\n[item=workers-food-03] → 32 ores\n\n[item=thikat] is a larger, genetically enhanced version of the Dig-o-saurus. Thikat has 100% mining productivity.\n[item=work-o-dile] has 200% mining productivity.\n\nFloor tiles such as [item=py-steel] can improve the running speed of the Digosaurus.
mega-farm=The [entity=mega-farm] has the ability to cultivate patches of plants. You can pick a type of plant and a recipe for that plant, for example [recipe=bioreserve-super-1], then you have to feed the required materials. You then have to insert the collector, for example [item=replicator-bioreserve]. After inserting the collector, you have to 'launch' the 'rocket' - overhyped terms thought up by marketing, no doubt - which generates the patch of your chosen plants to the north of your building. This patch can then be harvested using the [entity=harvester].\n\nWhen the patch dries up, you can repeat the process, for a renewable source of plants such as [item=native-flora]. More complex recipes generate richer patches.
pydrive=You’ve created a species of giant, super fast, yet docile worms. They are able to transfer items instantaneously between different [entity=pydrive] buildings, as long as those buildings are tuned to the identification of the same worm.\n\nUse the rings of checkboxes to select a specific worm - every pattern of checked and unchecked boxes will select a different worm. Your items will still be with the worm if no logistic station is tuned to that worm, you can retrieve them by tuning to that worm again.\n\n[entity=pydrive] requires 10MW of continuous electricity.
Expand Down
6 changes: 6 additions & 0 deletions scripts/caravan/caravan-gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ function Caravan.build_schedule_gui(gui, caravan_data)
else
action_frame.add{type = 'empty-widget', style = 'py_empty_widget'}
end
if action.type == 'item-count' or action.type == 'inverse-item-count' or action.type== 'fill-inventory' or action.type == 'empty-inventory' then
action_frame.add{type = 'checkbox', name = 'py_blocking_caravan',state= not action.async,
tooltip= {'caravan-gui.wait'},
tags = tags}
end

action_frame.add{
type = 'sprite-button', name = 'py_shuffle_schedule_1', style = 'py_schedule_move_button',
Expand All @@ -106,6 +111,7 @@ function Caravan.build_schedule_gui(gui, caravan_data)
type = 'sprite-button', name = 'py_shuffle_schedule_2', style = 'py_schedule_move_button', tags = tags,
sprite = 'down-white', hovered_sprite = 'down-black', clicked_sprite = 'down-black'
}

action_frame.add{
type = 'sprite-button', name = 'py_delete_schedule', style = 'py_schedule_move_button', tags = tags,
sprite = 'utility/close_white', hovered_sprite = 'utility/close_black', clicked_sprite = 'utility/close_black'
Expand Down
12 changes: 6 additions & 6 deletions scripts/caravan/caravan-prototypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Caravan.actions = {
local inventory = caravan_data.inventory

transfer_all_items(outpost_inventory, inventory)
return inventory.is_full()
return action.async or inventory.is_full()
end,

['empty-inventory'] = function(caravan_data, schedule, action)
Expand All @@ -227,7 +227,7 @@ Caravan.actions = {
local inventory = caravan_data.inventory

transfer_all_items(inventory, outpost_inventory)
return inventory.is_empty()
return action.async or inventory.is_empty()
end,

['empty-autotrash'] = function(caravan_data, schedule, action)
Expand All @@ -250,8 +250,8 @@ Caravan.actions = {
local goal = action.item_count
local item = action.elem_value
if not goal or not item then return false end

return transfer_filtered_items(caravan_inventory, outpost_inventory, item, goal)
local result= transfer_filtered_items(caravan_inventory, outpost_inventory, item, goal)
return action.async or result
end,

['inverse-item-count'] = function(caravan_data, schedule, action)
Expand All @@ -263,8 +263,8 @@ Caravan.actions = {
local goal = action.item_count
local item = action.elem_value
if not goal or not item then return false end

return transfer_filtered_items(outpost_inventory, caravan_inventory, item, goal)
local result =transfer_filtered_items(outpost_inventory, caravan_inventory, item, goal)
return action.async or result
end,

['detonate'] = function(caravan_data, schedule, action)
Expand Down
10 changes: 10 additions & 0 deletions scripts/caravan/caravan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ gui_events[defines.events.on_gui_click]['py_delete_schedule'] = function(event)
Caravan.update_gui(Caravan.get_caravan_gui(player))
end

gui_events[defines.events.on_gui_click]['py_blocking_caravan'] = function(event)
local element = event.element
local tags = element.tags
local caravan_data = global.caravans[tags.unit_number]
local action = caravan_data.schedule[tags.schedule_id].actions[tags.action_id]
action.async= not element.state
stop_actions(caravan_data)
end


gui_events[defines.events.on_gui_click]['py_shuffle_schedule_.'] = function(event)
local player = game.get_player(event.player_index)
local element = event.element
Expand Down