From 30fe2946e62935fdda34b6ed57c77fa9bfdaee15 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Thu, 1 Dec 2022 19:04:58 -0500 Subject: [PATCH 01/12] updated api --- .../factorio/runtime-api-LuaAISettings.lua | 2 +- ...time-api-LuaAccumulatorControlBehavior.lua | 2 +- .../runtime-api-LuaAchievementPrototype.lua | 2 +- .../runtime-api-LuaAmmoCategoryPrototype.lua | 2 +- ...LuaArithmeticCombinatorControlBehavior.lua | 2 +- ...ntime-api-LuaAutoplaceControlPrototype.lua | 2 +- .vscode/factorio/runtime-api-LuaBootstrap.lua | 22 +++---- .vscode/factorio/runtime-api-LuaBurner.lua | 2 +- .../runtime-api-LuaBurnerPrototype.lua | 2 +- .../factorio/runtime-api-LuaChunkIterator.lua | 2 +- .../runtime-api-LuaCircuitNetwork.lua | 2 +- ...ntime-api-LuaCombinatorControlBehavior.lua | 2 +- .../runtime-api-LuaCommandProcessor.lua | 2 +- ...i-LuaConstantCombinatorControlBehavior.lua | 2 +- ...untime-api-LuaContainerControlBehavior.lua | 2 +- .vscode/factorio/runtime-api-LuaControl.lua | 2 +- .../runtime-api-LuaControlBehavior.lua | 2 +- .../runtime-api-LuaCustomChartTag.lua | 2 +- .../runtime-api-LuaCustomInputPrototype.lua | 2 +- .../factorio/runtime-api-LuaCustomTable.lua | 2 +- .../runtime-api-LuaDamagePrototype.lua | 2 +- ...pi-LuaDeciderCombinatorControlBehavior.lua | 2 +- .../runtime-api-LuaDecorativePrototype.lua | 2 +- ...e-api-LuaElectricEnergySourcePrototype.lua | 2 +- .vscode/factorio/runtime-api-LuaEntity.lua | 4 +- .../runtime-api-LuaEntityPrototype.lua | 2 +- .vscode/factorio/runtime-api-LuaEquipment.lua | 2 +- ...time-api-LuaEquipmentCategoryPrototype.lua | 2 +- .../factorio/runtime-api-LuaEquipmentGrid.lua | 2 +- .../runtime-api-LuaEquipmentGridPrototype.lua | 2 +- .../runtime-api-LuaEquipmentPrototype.lua | 2 +- .../runtime-api-LuaFlowStatistics.lua | 2 +- .vscode/factorio/runtime-api-LuaFluidBox.lua | 2 +- .../runtime-api-LuaFluidBoxPrototype.lua | 2 +- ...time-api-LuaFluidEnergySourcePrototype.lua | 2 +- .../runtime-api-LuaFluidPrototype.lua | 2 +- .../factorio/runtime-api-LuaFontPrototype.lua | 2 +- .vscode/factorio/runtime-api-LuaForce.lua | 2 +- .../runtime-api-LuaFuelCategoryPrototype.lua | 2 +- .../factorio/runtime-api-LuaGameScript.lua | 6 +- ...ime-api-LuaGenericOnOffControlBehavior.lua | 2 +- .vscode/factorio/runtime-api-LuaGroup.lua | 2 +- .vscode/factorio/runtime-api-LuaGui.lua | 2 +- .../factorio/runtime-api-LuaGuiElement.lua | 6 +- .../runtime-api-LuaHeatBufferPrototype.lua | 2 +- ...ntime-api-LuaHeatEnergySourcePrototype.lua | 2 +- ...runtime-api-LuaInserterControlBehavior.lua | 2 +- .vscode/factorio/runtime-api-LuaInventory.lua | 10 +++- .../factorio/runtime-api-LuaItemPrototype.lua | 59 ++++++++++++++++++- .vscode/factorio/runtime-api-LuaItemStack.lua | 2 +- .../runtime-api-LuaLampControlBehavior.lua | 2 +- .../runtime-api-LuaLazyLoadedValue.lua | 2 +- .../factorio/runtime-api-LuaLogisticCell.lua | 2 +- ...pi-LuaLogisticContainerControlBehavior.lua | 4 +- .../runtime-api-LuaLogisticNetwork.lua | 2 +- .../factorio/runtime-api-LuaLogisticPoint.lua | 2 +- ...time-api-LuaMiningDrillControlBehavior.lua | 2 +- .../runtime-api-LuaModSettingPrototype.lua | 2 +- ...runtime-api-LuaModuleCategoryPrototype.lua | 2 +- .../runtime-api-LuaNamedNoiseExpression.lua | 2 +- .../runtime-api-LuaNoiseLayerPrototype.lua | 2 +- .../runtime-api-LuaParticlePrototype.lua | 2 +- .../runtime-api-LuaPermissionGroup.lua | 2 +- .../runtime-api-LuaPermissionGroups.lua | 2 +- .vscode/factorio/runtime-api-LuaPlayer.lua | 6 +- .vscode/factorio/runtime-api-LuaProfiler.lua | 2 +- ...-LuaProgrammableSpeakerControlBehavior.lua | 2 +- .vscode/factorio/runtime-api-LuaRCON.lua | 2 +- ...-api-LuaRailChainSignalControlBehavior.lua | 2 +- .vscode/factorio/runtime-api-LuaRailPath.lua | 2 +- ...ntime-api-LuaRailSignalControlBehavior.lua | 2 +- .../runtime-api-LuaRandomGenerator.lua | 2 +- .vscode/factorio/runtime-api-LuaRecipe.lua | 2 +- ...runtime-api-LuaRecipeCategoryPrototype.lua | 2 +- .../runtime-api-LuaRecipePrototype.lua | 2 +- .vscode/factorio/runtime-api-LuaRemote.lua | 2 +- .vscode/factorio/runtime-api-LuaRendering.lua | 2 +- ...ntime-api-LuaResourceCategoryPrototype.lua | 2 +- ...runtime-api-LuaRoboportControlBehavior.lua | 2 +- .vscode/factorio/runtime-api-LuaSettings.lua | 2 +- .../runtime-api-LuaShortcutPrototype.lua | 2 +- ...time-api-LuaStorageTankControlBehavior.lua | 2 +- .vscode/factorio/runtime-api-LuaStyle.lua | 2 +- .vscode/factorio/runtime-api-LuaSurface.lua | 2 +- .../factorio/runtime-api-LuaTechnology.lua | 2 +- .../runtime-api-LuaTechnologyPrototype.lua | 2 +- .vscode/factorio/runtime-api-LuaTile.lua | 2 +- .../factorio/runtime-api-LuaTilePrototype.lua | 2 +- .vscode/factorio/runtime-api-LuaTrain.lua | 2 +- ...untime-api-LuaTrainStopControlBehavior.lua | 2 +- ...me-api-LuaTransportBeltControlBehavior.lua | 2 +- .../factorio/runtime-api-LuaTransportLine.lua | 2 +- .../runtime-api-LuaTrivialSmokePrototype.lua | 2 +- .vscode/factorio/runtime-api-LuaUnitGroup.lua | 2 +- .../runtime-api-LuaVirtualSignalPrototype.lua | 2 +- ...ntime-api-LuaVoidEnergySourcePrototype.lua | 2 +- .../runtime-api-LuaWallControlBehavior.lua | 2 +- .vscode/factorio/runtime-api-builtin.lua | 2 +- .vscode/factorio/runtime-api-concepts.lua | 4 +- .vscode/factorio/runtime-api-custom.lua | 2 +- .vscode/factorio/runtime-api-defines.lua | 8 ++- .vscode/factorio/runtime-api-events.lua | 40 ++++++++++++- .../factorio/runtime-api-global_functions.lua | 2 +- .vscode/factorio/runtime-api-table_types.lua | 2 +- 104 files changed, 232 insertions(+), 123 deletions(-) diff --git a/.vscode/factorio/runtime-api-LuaAISettings.lua b/.vscode/factorio/runtime-api-LuaAISettings.lua index 224babe..6f16d0a 100644 --- a/.vscode/factorio/runtime-api-LuaAISettings.lua +++ b/.vscode/factorio/runtime-api-LuaAISettings.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaAISettings -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaAccumulatorControlBehavior.lua b/.vscode/factorio/runtime-api-LuaAccumulatorControlBehavior.lua index 3f82cf4..32cbe0a 100644 --- a/.vscode/factorio/runtime-api-LuaAccumulatorControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaAccumulatorControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaAccumulatorControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaAchievementPrototype.lua b/.vscode/factorio/runtime-api-LuaAchievementPrototype.lua index 90fa333..0f2a5ca 100644 --- a/.vscode/factorio/runtime-api-LuaAchievementPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaAchievementPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaAchievementPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaAmmoCategoryPrototype.lua b/.vscode/factorio/runtime-api-LuaAmmoCategoryPrototype.lua index 812d6ce..1a84da6 100644 --- a/.vscode/factorio/runtime-api-LuaAmmoCategoryPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaAmmoCategoryPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaAmmoCategoryPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaArithmeticCombinatorControlBehavior.lua b/.vscode/factorio/runtime-api-LuaArithmeticCombinatorControlBehavior.lua index 8087806..da4be23 100644 --- a/.vscode/factorio/runtime-api-LuaArithmeticCombinatorControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaArithmeticCombinatorControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaArithmeticCombinatorControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaAutoplaceControlPrototype.lua b/.vscode/factorio/runtime-api-LuaAutoplaceControlPrototype.lua index 97a65fe..fb9ad7b 100644 --- a/.vscode/factorio/runtime-api-LuaAutoplaceControlPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaAutoplaceControlPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaAutoplaceControlPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaBootstrap.lua b/.vscode/factorio/runtime-api-LuaBootstrap.lua index e279aa0..9b7f974 100644 --- a/.vscode/factorio/runtime-api-LuaBootstrap.lua +++ b/.vscode/factorio/runtime-api-LuaBootstrap.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaBootstrap -- This file is automatically generated. Edits will be overwritten. @@ -70,8 +70,8 @@ get_event_order=function()end, ---**Note:** For more context, refer to the page. --- ---[View documentation](https://lua-api.factorio.com/latest/LuaBootstrap.html#LuaBootstrap.on_configuration_changed) ----@param f fun(param1:ConfigurationChangedData)|nil@The handler for this event. Passing `nil` will unregister it. -on_configuration_changed=function(f)end, +---@param handler fun(param1:ConfigurationChangedData)|nil@The handler for this event. Passing `nil` will unregister it. +on_configuration_changed=function(handler)end, ---Register a handler to run on the specified event(s). Each mod can only register once for every event, as any additional registration will overwrite the previous one. This holds true even if different filters are used for subsequent registrations. --- ---[View documentation](https://lua-api.factorio.com/latest/LuaBootstrap.html#LuaBootstrap.on_event) @@ -91,9 +91,9 @@ on_configuration_changed=function(f)end, ---{{filter = "name", name = "fast-inserter"}}) ---``` ---@param event defines.events|defines.events[]|string@The event(s) or custom-input to invoke the handler on. ----@param f fun(param1:EventData)|nil@The handler for this event. Passing `nil` will unregister it. +---@param handler fun(param1:EventData)|nil@The handler for this event. Passing `nil` will unregister it. ---@param filters EventFilter?@The filters for this event. Can only be used when registering for individual events. -on_event=function(event,f,filters)end, +on_event=function(event,handler,filters)end, ---Register a function to be run on mod initialization. This is only called when a new save game is created or when a save file is loaded that previously didn't contain the mod. During it, the mod gets the chance to set up initial values that it will use for its lifetime. It has full access to [LuaGameScript](https://lua-api.factorio.com/latest/LuaGameScript.html) and the table and can change anything about them that it deems appropriate. No other events will be raised for the mod until it has finished this step. --- ---**Note:** For more context, refer to the page. @@ -107,8 +107,8 @@ on_event=function(event,f,filters)end, --- global.players = {} ---end) ---``` ----@param f fun()|nil@The handler for this event. Passing `nil` will unregister it. -on_init=function(f)end, +---@param handler fun()|nil@The handler for this event. Passing `nil` will unregister it. +on_init=function(handler)end, ---Register a function to be run on save load. This is only called for mods that have been part of the save previously, or for players connecting to a running multiplayer session. It gives the mod the opportunity to do some very specific actions, should it need to. Doing anything other than these three will lead to desyncs, which breaks multiplayer and replay functionality. Access to [LuaGameScript](https://lua-api.factorio.com/latest/LuaGameScript.html) is not available. The table can be accessed and is safe to read from, but not write to, as doing so will lead to an error. --- ---The only legitimate uses of this event are the following: @@ -121,14 +121,14 @@ on_init=function(f)end, ---**Note:** For more context, refer to the page. --- ---[View documentation](https://lua-api.factorio.com/latest/LuaBootstrap.html#LuaBootstrap.on_load) ----@param f fun()|nil@The handler for this event. Passing `nil` will unregister it. -on_load=function(f)end, +---@param handler fun()|nil@The handler for this event. Passing `nil` will unregister it. +on_load=function(handler)end, ---Register a handler to run every nth-tick(s). When the game is on tick 0 it will trigger all registered handlers. --- ---[View documentation](https://lua-api.factorio.com/latest/LuaBootstrap.html#LuaBootstrap.on_nth_tick) ---@param tick uint|uint[]|nil@The nth-tick(s) to invoke the handler on. Passing `nil` as the only parameter will unregister all nth-tick handlers. ----@param f fun(param1:NthTickEventData)|nil@The handler to run. Passing `nil` will unregister it for the provided nth-tick(s). -on_nth_tick=function(tick,f)end, +---@param handler fun(param1:NthTickEventData)|nil@The handler to run. Passing `nil` will unregister it for the provided nth-tick(s). +on_nth_tick=function(tick,handler)end, ---[View documentation](https://lua-api.factorio.com/latest/LuaBootstrap.html#LuaBootstrap.raise_biter_base_built) ---@class LuaBootstrap.raise_biter_base_built_param ---The entity that was built. diff --git a/.vscode/factorio/runtime-api-LuaBurner.lua b/.vscode/factorio/runtime-api-LuaBurner.lua index 32992ff..b606604 100644 --- a/.vscode/factorio/runtime-api-LuaBurner.lua +++ b/.vscode/factorio/runtime-api-LuaBurner.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaBurner -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaBurnerPrototype.lua b/.vscode/factorio/runtime-api-LuaBurnerPrototype.lua index b5e2a36..373a8b9 100644 --- a/.vscode/factorio/runtime-api-LuaBurnerPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaBurnerPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaBurnerPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaChunkIterator.lua b/.vscode/factorio/runtime-api-LuaChunkIterator.lua index ada1853..2fa5751 100644 --- a/.vscode/factorio/runtime-api-LuaChunkIterator.lua +++ b/.vscode/factorio/runtime-api-LuaChunkIterator.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaChunkIterator -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaCircuitNetwork.lua b/.vscode/factorio/runtime-api-LuaCircuitNetwork.lua index 76216ad..d7994b5 100644 --- a/.vscode/factorio/runtime-api-LuaCircuitNetwork.lua +++ b/.vscode/factorio/runtime-api-LuaCircuitNetwork.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaCircuitNetwork -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaCombinatorControlBehavior.lua b/.vscode/factorio/runtime-api-LuaCombinatorControlBehavior.lua index d6e569f..8171314 100644 --- a/.vscode/factorio/runtime-api-LuaCombinatorControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaCombinatorControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaCombinatorControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaCommandProcessor.lua b/.vscode/factorio/runtime-api-LuaCommandProcessor.lua index c9039d6..c405a3d 100644 --- a/.vscode/factorio/runtime-api-LuaCommandProcessor.lua +++ b/.vscode/factorio/runtime-api-LuaCommandProcessor.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaCommandProcessor -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaConstantCombinatorControlBehavior.lua b/.vscode/factorio/runtime-api-LuaConstantCombinatorControlBehavior.lua index 3d3802c..d04aa28 100644 --- a/.vscode/factorio/runtime-api-LuaConstantCombinatorControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaConstantCombinatorControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaConstantCombinatorControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaContainerControlBehavior.lua b/.vscode/factorio/runtime-api-LuaContainerControlBehavior.lua index 7383a3d..25d3de7 100644 --- a/.vscode/factorio/runtime-api-LuaContainerControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaContainerControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaContainerControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaControl.lua b/.vscode/factorio/runtime-api-LuaControl.lua index 91291b3..bce7c1e 100644 --- a/.vscode/factorio/runtime-api-LuaControl.lua +++ b/.vscode/factorio/runtime-api-LuaControl.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaControl -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaControlBehavior.lua b/.vscode/factorio/runtime-api-LuaControlBehavior.lua index 4fc360f..1561e39 100644 --- a/.vscode/factorio/runtime-api-LuaControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaCustomChartTag.lua b/.vscode/factorio/runtime-api-LuaCustomChartTag.lua index f9dc650..ce35397 100644 --- a/.vscode/factorio/runtime-api-LuaCustomChartTag.lua +++ b/.vscode/factorio/runtime-api-LuaCustomChartTag.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaCustomChartTag -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaCustomInputPrototype.lua b/.vscode/factorio/runtime-api-LuaCustomInputPrototype.lua index baccea3..a671513 100644 --- a/.vscode/factorio/runtime-api-LuaCustomInputPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaCustomInputPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaCustomInputPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaCustomTable.lua b/.vscode/factorio/runtime-api-LuaCustomTable.lua index 1fd3b7e..9a26039 100644 --- a/.vscode/factorio/runtime-api-LuaCustomTable.lua +++ b/.vscode/factorio/runtime-api-LuaCustomTable.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaCustomTable -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaDamagePrototype.lua b/.vscode/factorio/runtime-api-LuaDamagePrototype.lua index d5732d9..203e147 100644 --- a/.vscode/factorio/runtime-api-LuaDamagePrototype.lua +++ b/.vscode/factorio/runtime-api-LuaDamagePrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaDamagePrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaDeciderCombinatorControlBehavior.lua b/.vscode/factorio/runtime-api-LuaDeciderCombinatorControlBehavior.lua index f604812..ffae530 100644 --- a/.vscode/factorio/runtime-api-LuaDeciderCombinatorControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaDeciderCombinatorControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaDeciderCombinatorControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaDecorativePrototype.lua b/.vscode/factorio/runtime-api-LuaDecorativePrototype.lua index f653295..378016e 100644 --- a/.vscode/factorio/runtime-api-LuaDecorativePrototype.lua +++ b/.vscode/factorio/runtime-api-LuaDecorativePrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaDecorativePrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaElectricEnergySourcePrototype.lua b/.vscode/factorio/runtime-api-LuaElectricEnergySourcePrototype.lua index a029a3c..01ea5fc 100644 --- a/.vscode/factorio/runtime-api-LuaElectricEnergySourcePrototype.lua +++ b/.vscode/factorio/runtime-api-LuaElectricEnergySourcePrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaElectricEnergySourcePrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaEntity.lua b/.vscode/factorio/runtime-api-LuaEntity.lua index 601cb15..5573c7a 100644 --- a/.vscode/factorio/runtime-api-LuaEntity.lua +++ b/.vscode/factorio/runtime-api-LuaEntity.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaEntity -- This file is automatically generated. Edits will be overwritten. @@ -1307,7 +1307,7 @@ create_build_effect_smoke=function()end, ---_Can only be used if this is EntityWithHealth_ ---@param damage float@The amount of damage to be done. ---@param force ForceIdentification@The force that will be doing the damage. ----@param type string?@The type of damage to be done, defaults to "impact". +---@param type string?@The type of damage to be done, defaults to "impact". Can't be `nil`. ---@param dealer LuaEntity?@The entity to consider as the damage dealer. Needs to be on the same surface as the entity being damaged. ---@return float@the total damage actually applied after resistances. damage=function(damage,force,type,dealer)end, diff --git a/.vscode/factorio/runtime-api-LuaEntityPrototype.lua b/.vscode/factorio/runtime-api-LuaEntityPrototype.lua index 7760292..e7f47dd 100644 --- a/.vscode/factorio/runtime-api-LuaEntityPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaEntityPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaEntityPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaEquipment.lua b/.vscode/factorio/runtime-api-LuaEquipment.lua index 000daf7..98410ad 100644 --- a/.vscode/factorio/runtime-api-LuaEquipment.lua +++ b/.vscode/factorio/runtime-api-LuaEquipment.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaEquipment -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaEquipmentCategoryPrototype.lua b/.vscode/factorio/runtime-api-LuaEquipmentCategoryPrototype.lua index 6217a36..7857a13 100644 --- a/.vscode/factorio/runtime-api-LuaEquipmentCategoryPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaEquipmentCategoryPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaEquipmentCategoryPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaEquipmentGrid.lua b/.vscode/factorio/runtime-api-LuaEquipmentGrid.lua index 06df396..5f1046e 100644 --- a/.vscode/factorio/runtime-api-LuaEquipmentGrid.lua +++ b/.vscode/factorio/runtime-api-LuaEquipmentGrid.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaEquipmentGrid -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaEquipmentGridPrototype.lua b/.vscode/factorio/runtime-api-LuaEquipmentGridPrototype.lua index ad6c918..443cdc1 100644 --- a/.vscode/factorio/runtime-api-LuaEquipmentGridPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaEquipmentGridPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaEquipmentGridPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaEquipmentPrototype.lua b/.vscode/factorio/runtime-api-LuaEquipmentPrototype.lua index d82cb27..fd2a836 100644 --- a/.vscode/factorio/runtime-api-LuaEquipmentPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaEquipmentPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaEquipmentPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaFlowStatistics.lua b/.vscode/factorio/runtime-api-LuaFlowStatistics.lua index 85384b5..87e78b9 100644 --- a/.vscode/factorio/runtime-api-LuaFlowStatistics.lua +++ b/.vscode/factorio/runtime-api-LuaFlowStatistics.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaFlowStatistics -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaFluidBox.lua b/.vscode/factorio/runtime-api-LuaFluidBox.lua index 64e64f9..a6525f8 100644 --- a/.vscode/factorio/runtime-api-LuaFluidBox.lua +++ b/.vscode/factorio/runtime-api-LuaFluidBox.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaFluidBox -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaFluidBoxPrototype.lua b/.vscode/factorio/runtime-api-LuaFluidBoxPrototype.lua index d20585b..c5c9966 100644 --- a/.vscode/factorio/runtime-api-LuaFluidBoxPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaFluidBoxPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaFluidBoxPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaFluidEnergySourcePrototype.lua b/.vscode/factorio/runtime-api-LuaFluidEnergySourcePrototype.lua index 96f33c4..5ba8827 100644 --- a/.vscode/factorio/runtime-api-LuaFluidEnergySourcePrototype.lua +++ b/.vscode/factorio/runtime-api-LuaFluidEnergySourcePrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaFluidEnergySourcePrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaFluidPrototype.lua b/.vscode/factorio/runtime-api-LuaFluidPrototype.lua index 323e73d..def2dd5 100644 --- a/.vscode/factorio/runtime-api-LuaFluidPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaFluidPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaFluidPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaFontPrototype.lua b/.vscode/factorio/runtime-api-LuaFontPrototype.lua index 20ea356..35bebcd 100644 --- a/.vscode/factorio/runtime-api-LuaFontPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaFontPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaFontPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaForce.lua b/.vscode/factorio/runtime-api-LuaForce.lua index b2f383e..e42425d 100644 --- a/.vscode/factorio/runtime-api-LuaForce.lua +++ b/.vscode/factorio/runtime-api-LuaForce.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaForce -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaFuelCategoryPrototype.lua b/.vscode/factorio/runtime-api-LuaFuelCategoryPrototype.lua index eba1945..402cf46 100644 --- a/.vscode/factorio/runtime-api-LuaFuelCategoryPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaFuelCategoryPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaFuelCategoryPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaGameScript.lua b/.vscode/factorio/runtime-api-LuaGameScript.lua index 77d71bb..088e421 100644 --- a/.vscode/factorio/runtime-api-LuaGameScript.lua +++ b/.vscode/factorio/runtime-api-LuaGameScript.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaGameScript -- This file is automatically generated. Edits will be overwritten. @@ -715,9 +715,9 @@ json_to_table=function(json)end, ---@param player PlayerIdentification@The player to kick. ---@param reason LocalisedString?@The reason given if any. kick_player=function(player,reason)end, ----Marks two forces to be merged together. All entities in the source force will be reassigned to the target force. The source force will then be destroyed. +---Marks two forces to be merged together. All players and entities in the source force will be reassigned to the target force. The source force will then be destroyed. Importantly, this does not merge technologies or bonuses, which are instead retained from the target force. --- ----**Note:** The three built-in forces -- player, enemy and neutral -- can't be destroyed. I.e. they can't be used as the source argument to this function. +---**Note:** The three built-in forces (player, enemy and neutral) can't be destroyed, meaning they can't be used as the source argument to this function. --- ---**Note:** The source force is not removed until the end of the current tick, or if called during the [on_forces_merging](https://lua-api.factorio.com/latest/events.html#on_forces_merging) or [on_forces_merged](https://lua-api.factorio.com/latest/events.html#on_forces_merged) event, the end of the next tick. --- diff --git a/.vscode/factorio/runtime-api-LuaGenericOnOffControlBehavior.lua b/.vscode/factorio/runtime-api-LuaGenericOnOffControlBehavior.lua index 129d26b..b0d67bd 100644 --- a/.vscode/factorio/runtime-api-LuaGenericOnOffControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaGenericOnOffControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaGenericOnOffControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaGroup.lua b/.vscode/factorio/runtime-api-LuaGroup.lua index 4be90e8..255a279 100644 --- a/.vscode/factorio/runtime-api-LuaGroup.lua +++ b/.vscode/factorio/runtime-api-LuaGroup.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaGroup -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaGui.lua b/.vscode/factorio/runtime-api-LuaGui.lua index 4335ce0..2e8d9c7 100644 --- a/.vscode/factorio/runtime-api-LuaGui.lua +++ b/.vscode/factorio/runtime-api-LuaGui.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaGui -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaGuiElement.lua b/.vscode/factorio/runtime-api-LuaGuiElement.lua index 5ffd124..70cac00 100644 --- a/.vscode/factorio/runtime-api-LuaGuiElement.lua +++ b/.vscode/factorio/runtime-api-LuaGuiElement.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaGuiElement -- This file is automatically generated. Edits will be overwritten. @@ -967,6 +967,10 @@ clear=function()end, --- ---_Can only be used if this is drop-down or list-box_ clear_items=function()end, +---Closes the dropdown list if this is a dropdown and it is open. +--- +---[View documentation](https://lua-api.factorio.com/latest/LuaGuiElement.html#LuaGuiElement.close_dropdown) +close_dropdown=function()end, ---Remove this element, along with its children. Any [LuaGuiElement](https://lua-api.factorio.com/latest/LuaGuiElement.html) objects referring to the destroyed elements become invalid after this operation. --- ---**Note:** The top-level GUI elements - [LuaGui::top](https://lua-api.factorio.com/latest/LuaGui.html#LuaGui.top), [LuaGui::left](https://lua-api.factorio.com/latest/LuaGui.html#LuaGui.left), [LuaGui::center](https://lua-api.factorio.com/latest/LuaGui.html#LuaGui.center) and [LuaGui::screen](https://lua-api.factorio.com/latest/LuaGui.html#LuaGui.screen) - can't be destroyed. diff --git a/.vscode/factorio/runtime-api-LuaHeatBufferPrototype.lua b/.vscode/factorio/runtime-api-LuaHeatBufferPrototype.lua index ec8a954..7ba8043 100644 --- a/.vscode/factorio/runtime-api-LuaHeatBufferPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaHeatBufferPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaHeatBufferPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaHeatEnergySourcePrototype.lua b/.vscode/factorio/runtime-api-LuaHeatEnergySourcePrototype.lua index 65a02e2..499a8dc 100644 --- a/.vscode/factorio/runtime-api-LuaHeatEnergySourcePrototype.lua +++ b/.vscode/factorio/runtime-api-LuaHeatEnergySourcePrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaHeatEnergySourcePrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaInserterControlBehavior.lua b/.vscode/factorio/runtime-api-LuaInserterControlBehavior.lua index 27f994c..1d8ceed 100644 --- a/.vscode/factorio/runtime-api-LuaInserterControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaInserterControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaInserterControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaInventory.lua b/.vscode/factorio/runtime-api-LuaInventory.lua index 365ae70..674143c 100644 --- a/.vscode/factorio/runtime-api-LuaInventory.lua +++ b/.vscode/factorio/runtime-api-LuaInventory.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaInventory -- This file is automatically generated. Edits will be overwritten. @@ -89,8 +89,9 @@ clear=function()end, --- ---[View documentation](https://lua-api.factorio.com/latest/LuaInventory.html#LuaInventory.count_empty_stacks) ---@param include_filtered boolean?@If true, filtered slots will be included. Defaults to false. +---@param include_bar boolean?@If true, slots blocked by the current bar will be included. Defaults to true. ---@return uint -count_empty_stacks=function(include_filtered)end, +count_empty_stacks=function(include_filtered,include_bar)end, ---Destroys this inventory. --- ---**Note:** Only inventories created by [LuaGameScript::create_inventory](https://lua-api.factorio.com/latest/LuaGameScript.html#LuaGameScript.create_inventory) can be destroyed this way. @@ -167,6 +168,11 @@ is_empty=function()end, ---[View documentation](https://lua-api.factorio.com/latest/LuaInventory.html#LuaInventory.is_filtered) ---@return boolean is_filtered=function()end, +---Is every stack in this inventory full? Ignores stacks blocked by the current bar. +--- +---[View documentation](https://lua-api.factorio.com/latest/LuaInventory.html#LuaInventory.is_full) +---@return boolean +is_full=function()end, ---Remove items from this inventory. --- ---[View documentation](https://lua-api.factorio.com/latest/LuaInventory.html#LuaInventory.remove) diff --git a/.vscode/factorio/runtime-api-LuaItemPrototype.lua b/.vscode/factorio/runtime-api-LuaItemPrototype.lua index 409f552..7b7e30e 100644 --- a/.vscode/factorio/runtime-api-LuaItemPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaItemPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaItemPrototype -- This file is automatically generated. Edits will be overwritten. @@ -39,6 +39,63 @@ ---_Can only be used if this is SelectionTool_ ---@field alt_entity_type_filters? {[string]: boolean} ---[R] +---The alt reverse entity filter mode used by this selection tool. +--- +---[View documentation](https://lua-api.factorio.com/latest/LuaItemPrototype.html#LuaItemPrototype.alt_reverse_alt_entity_filter_mode) +--- +---_Can only be used if this is SelectionTool_ +---@field alt_reverse_alt_entity_filter_mode? string +---[R] +---The alt reverse entity filters used by this selection tool indexed by entity name. +--- +---[View documentation](https://lua-api.factorio.com/latest/LuaItemPrototype.html#LuaItemPrototype.alt_reverse_entity_filters) +--- +---_Can only be used if this is SelectionTool_ +---@field alt_reverse_entity_filters? {[string]: LuaEntityPrototype} +---[R] +---The alt reverse entity type filters used by this selection tool indexed by entity type. +--- +---**Note:** The boolean value is meaningless and is used to allow easy lookup if a type exists in the dictionary. +--- +---[View documentation](https://lua-api.factorio.com/latest/LuaItemPrototype.html#LuaItemPrototype.alt_reverse_entity_type_filters) +--- +---_Can only be used if this is SelectionTool_ +---@field alt_reverse_entity_type_filters? {[string]: boolean} +---[R] +---The color used when doing alt reverse selection with this selection tool prototype. +--- +---[View documentation](https://lua-api.factorio.com/latest/LuaItemPrototype.html#LuaItemPrototype.alt_reverse_selection_border_color) +--- +---_Can only be used if this is SelectionTool_ +---@field alt_reverse_selection_border_color? Color +---[R] +--- +---[View documentation](https://lua-api.factorio.com/latest/LuaItemPrototype.html#LuaItemPrototype.alt_reverse_selection_cursor_box_type) +--- +---_Can only be used if this is SelectionTool_ +---@field alt_reverse_selection_cursor_box_type? string +---[R] +---Flags that affect which entities will be selected during alt reverse selection. +--- +---[View documentation](https://lua-api.factorio.com/latest/LuaItemPrototype.html#LuaItemPrototype.alt_reverse_selection_mode_flags) +--- +---_Can only be used if this is SelectionTool_ +---@field alt_reverse_selection_mode_flags? SelectionModeFlags +---[R] +---The alt reverse tile filter mode used by this selection tool. +--- +---[View documentation](https://lua-api.factorio.com/latest/LuaItemPrototype.html#LuaItemPrototype.alt_reverse_tile_filter_mode) +--- +---_Can only be used if this is SelectionTool_ +---@field alt_reverse_tile_filter_mode? string +---[R] +---The alt reverse tile filters used by this selection tool indexed by tile name. +--- +---[View documentation](https://lua-api.factorio.com/latest/LuaItemPrototype.html#LuaItemPrototype.alt_reverse_tile_filters) +--- +---_Can only be used if this is SelectionTool_ +---@field alt_reverse_tile_filters? {[string]: LuaTilePrototype} +---[R] ---The color used when doing alt selection with this selection tool prototype. --- ---[View documentation](https://lua-api.factorio.com/latest/LuaItemPrototype.html#LuaItemPrototype.alt_selection_border_color) diff --git a/.vscode/factorio/runtime-api-LuaItemStack.lua b/.vscode/factorio/runtime-api-LuaItemStack.lua index e25608e..2bffa2f 100644 --- a/.vscode/factorio/runtime-api-LuaItemStack.lua +++ b/.vscode/factorio/runtime-api-LuaItemStack.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaItemStack -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaLampControlBehavior.lua b/.vscode/factorio/runtime-api-LuaLampControlBehavior.lua index 4f70705..633cc26 100644 --- a/.vscode/factorio/runtime-api-LuaLampControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaLampControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaLampControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaLazyLoadedValue.lua b/.vscode/factorio/runtime-api-LuaLazyLoadedValue.lua index ec11d80..6866fb6 100644 --- a/.vscode/factorio/runtime-api-LuaLazyLoadedValue.lua +++ b/.vscode/factorio/runtime-api-LuaLazyLoadedValue.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaLazyLoadedValue -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaLogisticCell.lua b/.vscode/factorio/runtime-api-LuaLogisticCell.lua index 965356c..7294d0b 100644 --- a/.vscode/factorio/runtime-api-LuaLogisticCell.lua +++ b/.vscode/factorio/runtime-api-LuaLogisticCell.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaLogisticCell -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaLogisticContainerControlBehavior.lua b/.vscode/factorio/runtime-api-LuaLogisticContainerControlBehavior.lua index e27e3a3..e155051 100644 --- a/.vscode/factorio/runtime-api-LuaLogisticContainerControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaLogisticContainerControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaLogisticContainerControlBehavior -- This file is automatically generated. Edits will be overwritten. @@ -11,7 +11,7 @@ ---[View documentation](https://lua-api.factorio.com/latest/LuaLogisticContainerControlBehavior.html) ---@class LuaLogisticContainerControlBehavior:LuaControlBehavior ---[RW] ----The circuit mode of operations for the logistic container. +---The circuit mode of operations for the logistic container. Can only be set on containers whose [logistic_mode](https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.logistic_mode) is set to "requester". --- ---[View documentation](https://lua-api.factorio.com/latest/LuaLogisticContainerControlBehavior.html#LuaLogisticContainerControlBehavior.circuit_mode_of_operation) ---@field circuit_mode_of_operation defines.control_behavior.logistic_container.circuit_mode_of_operation diff --git a/.vscode/factorio/runtime-api-LuaLogisticNetwork.lua b/.vscode/factorio/runtime-api-LuaLogisticNetwork.lua index db9e572..a4dd1d7 100644 --- a/.vscode/factorio/runtime-api-LuaLogisticNetwork.lua +++ b/.vscode/factorio/runtime-api-LuaLogisticNetwork.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaLogisticNetwork -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaLogisticPoint.lua b/.vscode/factorio/runtime-api-LuaLogisticPoint.lua index 9fd0c05..4ef9766 100644 --- a/.vscode/factorio/runtime-api-LuaLogisticPoint.lua +++ b/.vscode/factorio/runtime-api-LuaLogisticPoint.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaLogisticPoint -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaMiningDrillControlBehavior.lua b/.vscode/factorio/runtime-api-LuaMiningDrillControlBehavior.lua index a485d03..83e9283 100644 --- a/.vscode/factorio/runtime-api-LuaMiningDrillControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaMiningDrillControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaMiningDrillControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaModSettingPrototype.lua b/.vscode/factorio/runtime-api-LuaModSettingPrototype.lua index 373ec83..4b09205 100644 --- a/.vscode/factorio/runtime-api-LuaModSettingPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaModSettingPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaModSettingPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaModuleCategoryPrototype.lua b/.vscode/factorio/runtime-api-LuaModuleCategoryPrototype.lua index 647925b..bfadf89 100644 --- a/.vscode/factorio/runtime-api-LuaModuleCategoryPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaModuleCategoryPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaModuleCategoryPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaNamedNoiseExpression.lua b/.vscode/factorio/runtime-api-LuaNamedNoiseExpression.lua index 16fd4b0..46e7c67 100644 --- a/.vscode/factorio/runtime-api-LuaNamedNoiseExpression.lua +++ b/.vscode/factorio/runtime-api-LuaNamedNoiseExpression.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaNamedNoiseExpression -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaNoiseLayerPrototype.lua b/.vscode/factorio/runtime-api-LuaNoiseLayerPrototype.lua index 1b7ff53..9c74a0a 100644 --- a/.vscode/factorio/runtime-api-LuaNoiseLayerPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaNoiseLayerPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaNoiseLayerPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaParticlePrototype.lua b/.vscode/factorio/runtime-api-LuaParticlePrototype.lua index 541cb68..9f56a54 100644 --- a/.vscode/factorio/runtime-api-LuaParticlePrototype.lua +++ b/.vscode/factorio/runtime-api-LuaParticlePrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaParticlePrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaPermissionGroup.lua b/.vscode/factorio/runtime-api-LuaPermissionGroup.lua index ed3b159..9d1c569 100644 --- a/.vscode/factorio/runtime-api-LuaPermissionGroup.lua +++ b/.vscode/factorio/runtime-api-LuaPermissionGroup.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaPermissionGroup -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaPermissionGroups.lua b/.vscode/factorio/runtime-api-LuaPermissionGroups.lua index 9c296b1..fdcccae 100644 --- a/.vscode/factorio/runtime-api-LuaPermissionGroups.lua +++ b/.vscode/factorio/runtime-api-LuaPermissionGroups.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaPermissionGroups -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaPlayer.lua b/.vscode/factorio/runtime-api-LuaPlayer.lua index 0e135f7..9f8fb08 100644 --- a/.vscode/factorio/runtime-api-LuaPlayer.lua +++ b/.vscode/factorio/runtime-api-LuaPlayer.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaPlayer -- This file is automatically generated. Edits will be overwritten. @@ -328,7 +328,7 @@ can_build_from_cursor=function(param)end, ---@field direction? defines.direction ----Checks if this player can build the give entity at the given location on the surface the player is on. +---Checks if this player can build the given entity at the given location on the surface the player is on. --- ---[View documentation](https://lua-api.factorio.com/latest/LuaPlayer.html#LuaPlayer.can_place_entity) ---@param param LuaPlayer.can_place_entity_param @@ -741,8 +741,6 @@ set_goal_description=function(text,only_update)end, ---Sets the filter for this map editor infinity filters at the given index. --- ---[View documentation](https://lua-api.factorio.com/latest/LuaPlayer.html#LuaPlayer.set_infinity_inventory_filter) ---- ----_Can only be used if this is InfinityContainer_ ---@param index uint@The index to set. ---@param filter InfinityInventoryFilter|nil@The new filter or `nil` to clear the filter. set_infinity_inventory_filter=function(index,filter)end, diff --git a/.vscode/factorio/runtime-api-LuaProfiler.lua b/.vscode/factorio/runtime-api-LuaProfiler.lua index 5f5843e..4519bac 100644 --- a/.vscode/factorio/runtime-api-LuaProfiler.lua +++ b/.vscode/factorio/runtime-api-LuaProfiler.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaProfiler -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaProgrammableSpeakerControlBehavior.lua b/.vscode/factorio/runtime-api-LuaProgrammableSpeakerControlBehavior.lua index 3781580..6e4e352 100644 --- a/.vscode/factorio/runtime-api-LuaProgrammableSpeakerControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaProgrammableSpeakerControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaProgrammableSpeakerControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaRCON.lua b/.vscode/factorio/runtime-api-LuaRCON.lua index 88275f4..fcfab71 100644 --- a/.vscode/factorio/runtime-api-LuaRCON.lua +++ b/.vscode/factorio/runtime-api-LuaRCON.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaRCON -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaRailChainSignalControlBehavior.lua b/.vscode/factorio/runtime-api-LuaRailChainSignalControlBehavior.lua index 49c1e73..db087f7 100644 --- a/.vscode/factorio/runtime-api-LuaRailChainSignalControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaRailChainSignalControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaRailChainSignalControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaRailPath.lua b/.vscode/factorio/runtime-api-LuaRailPath.lua index cb8198a..659b629 100644 --- a/.vscode/factorio/runtime-api-LuaRailPath.lua +++ b/.vscode/factorio/runtime-api-LuaRailPath.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaRailPath -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaRailSignalControlBehavior.lua b/.vscode/factorio/runtime-api-LuaRailSignalControlBehavior.lua index 5f0db48..1873eb0 100644 --- a/.vscode/factorio/runtime-api-LuaRailSignalControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaRailSignalControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaRailSignalControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaRandomGenerator.lua b/.vscode/factorio/runtime-api-LuaRandomGenerator.lua index fff18ad..709a286 100644 --- a/.vscode/factorio/runtime-api-LuaRandomGenerator.lua +++ b/.vscode/factorio/runtime-api-LuaRandomGenerator.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaRandomGenerator -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaRecipe.lua b/.vscode/factorio/runtime-api-LuaRecipe.lua index d0e7380..ba56776 100644 --- a/.vscode/factorio/runtime-api-LuaRecipe.lua +++ b/.vscode/factorio/runtime-api-LuaRecipe.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaRecipe -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaRecipeCategoryPrototype.lua b/.vscode/factorio/runtime-api-LuaRecipeCategoryPrototype.lua index f5ee746..08bee72 100644 --- a/.vscode/factorio/runtime-api-LuaRecipeCategoryPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaRecipeCategoryPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaRecipeCategoryPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaRecipePrototype.lua b/.vscode/factorio/runtime-api-LuaRecipePrototype.lua index d816896..68e5321 100644 --- a/.vscode/factorio/runtime-api-LuaRecipePrototype.lua +++ b/.vscode/factorio/runtime-api-LuaRecipePrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaRecipePrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaRemote.lua b/.vscode/factorio/runtime-api-LuaRemote.lua index 48a90c0..8ad3c5f 100644 --- a/.vscode/factorio/runtime-api-LuaRemote.lua +++ b/.vscode/factorio/runtime-api-LuaRemote.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaRemote -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaRendering.lua b/.vscode/factorio/runtime-api-LuaRendering.lua index e3b0a3a..cc35ca4 100644 --- a/.vscode/factorio/runtime-api-LuaRendering.lua +++ b/.vscode/factorio/runtime-api-LuaRendering.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaRendering -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaResourceCategoryPrototype.lua b/.vscode/factorio/runtime-api-LuaResourceCategoryPrototype.lua index 0301113..db06385 100644 --- a/.vscode/factorio/runtime-api-LuaResourceCategoryPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaResourceCategoryPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaResourceCategoryPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaRoboportControlBehavior.lua b/.vscode/factorio/runtime-api-LuaRoboportControlBehavior.lua index 056f586..71ce162 100644 --- a/.vscode/factorio/runtime-api-LuaRoboportControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaRoboportControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaRoboportControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaSettings.lua b/.vscode/factorio/runtime-api-LuaSettings.lua index f0776eb..bce6d2d 100644 --- a/.vscode/factorio/runtime-api-LuaSettings.lua +++ b/.vscode/factorio/runtime-api-LuaSettings.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaSettings -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaShortcutPrototype.lua b/.vscode/factorio/runtime-api-LuaShortcutPrototype.lua index feaa779..4d22ac5 100644 --- a/.vscode/factorio/runtime-api-LuaShortcutPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaShortcutPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaShortcutPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaStorageTankControlBehavior.lua b/.vscode/factorio/runtime-api-LuaStorageTankControlBehavior.lua index e7bc55c..37b278b 100644 --- a/.vscode/factorio/runtime-api-LuaStorageTankControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaStorageTankControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaStorageTankControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaStyle.lua b/.vscode/factorio/runtime-api-LuaStyle.lua index 2ac0080..5decce4 100644 --- a/.vscode/factorio/runtime-api-LuaStyle.lua +++ b/.vscode/factorio/runtime-api-LuaStyle.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaStyle -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaSurface.lua b/.vscode/factorio/runtime-api-LuaSurface.lua index 38aeb20..350053c 100644 --- a/.vscode/factorio/runtime-api-LuaSurface.lua +++ b/.vscode/factorio/runtime-api-LuaSurface.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaSurface -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaTechnology.lua b/.vscode/factorio/runtime-api-LuaTechnology.lua index 4d07562..86d5b25 100644 --- a/.vscode/factorio/runtime-api-LuaTechnology.lua +++ b/.vscode/factorio/runtime-api-LuaTechnology.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaTechnology -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaTechnologyPrototype.lua b/.vscode/factorio/runtime-api-LuaTechnologyPrototype.lua index fea2918..5c7abe4 100644 --- a/.vscode/factorio/runtime-api-LuaTechnologyPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaTechnologyPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaTechnologyPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaTile.lua b/.vscode/factorio/runtime-api-LuaTile.lua index e62c300..ec52229 100644 --- a/.vscode/factorio/runtime-api-LuaTile.lua +++ b/.vscode/factorio/runtime-api-LuaTile.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaTile -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaTilePrototype.lua b/.vscode/factorio/runtime-api-LuaTilePrototype.lua index 276b0b7..5e661ca 100644 --- a/.vscode/factorio/runtime-api-LuaTilePrototype.lua +++ b/.vscode/factorio/runtime-api-LuaTilePrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaTilePrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaTrain.lua b/.vscode/factorio/runtime-api-LuaTrain.lua index 777e639..de94ed4 100644 --- a/.vscode/factorio/runtime-api-LuaTrain.lua +++ b/.vscode/factorio/runtime-api-LuaTrain.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaTrain -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaTrainStopControlBehavior.lua b/.vscode/factorio/runtime-api-LuaTrainStopControlBehavior.lua index 690438c..fe5f8fb 100644 --- a/.vscode/factorio/runtime-api-LuaTrainStopControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaTrainStopControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaTrainStopControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaTransportBeltControlBehavior.lua b/.vscode/factorio/runtime-api-LuaTransportBeltControlBehavior.lua index 2e9932d..a69a771 100644 --- a/.vscode/factorio/runtime-api-LuaTransportBeltControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaTransportBeltControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaTransportBeltControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaTransportLine.lua b/.vscode/factorio/runtime-api-LuaTransportLine.lua index 47a342d..5ee69b0 100644 --- a/.vscode/factorio/runtime-api-LuaTransportLine.lua +++ b/.vscode/factorio/runtime-api-LuaTransportLine.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaTransportLine -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaTrivialSmokePrototype.lua b/.vscode/factorio/runtime-api-LuaTrivialSmokePrototype.lua index 9e49f79..1bb2645 100644 --- a/.vscode/factorio/runtime-api-LuaTrivialSmokePrototype.lua +++ b/.vscode/factorio/runtime-api-LuaTrivialSmokePrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaTrivialSmokePrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaUnitGroup.lua b/.vscode/factorio/runtime-api-LuaUnitGroup.lua index 9f08d91..4ac630a 100644 --- a/.vscode/factorio/runtime-api-LuaUnitGroup.lua +++ b/.vscode/factorio/runtime-api-LuaUnitGroup.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaUnitGroup -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaVirtualSignalPrototype.lua b/.vscode/factorio/runtime-api-LuaVirtualSignalPrototype.lua index 307cdab..692d4d3 100644 --- a/.vscode/factorio/runtime-api-LuaVirtualSignalPrototype.lua +++ b/.vscode/factorio/runtime-api-LuaVirtualSignalPrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaVirtualSignalPrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaVoidEnergySourcePrototype.lua b/.vscode/factorio/runtime-api-LuaVoidEnergySourcePrototype.lua index 59feb92..993b488 100644 --- a/.vscode/factorio/runtime-api-LuaVoidEnergySourcePrototype.lua +++ b/.vscode/factorio/runtime-api-LuaVoidEnergySourcePrototype.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaVoidEnergySourcePrototype -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-LuaWallControlBehavior.lua b/.vscode/factorio/runtime-api-LuaWallControlBehavior.lua index 122b046..0d50915 100644 --- a/.vscode/factorio/runtime-api-LuaWallControlBehavior.lua +++ b/.vscode/factorio/runtime-api-LuaWallControlBehavior.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section LuaWallControlBehavior -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-builtin.lua b/.vscode/factorio/runtime-api-builtin.lua index 3476613..896b078 100644 --- a/.vscode/factorio/runtime-api-builtin.lua +++ b/.vscode/factorio/runtime-api-builtin.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section builtin -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-concepts.lua b/.vscode/factorio/runtime-api-concepts.lua index 5bf19b6..758cb4e 100644 --- a/.vscode/factorio/runtime-api-concepts.lua +++ b/.vscode/factorio/runtime-api-concepts.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section concepts -- This file is automatically generated. Edits will be overwritten. @@ -1651,7 +1651,7 @@ --- ---[View documentation](https://lua-api.factorio.com/latest/Concepts.html#InfinityInventoryFilter) ---@field mode? string ----The index of this filter in the filters list. +---The index of this filter in the filters list. Not required when writing a filter. --- ---[View documentation](https://lua-api.factorio.com/latest/Concepts.html#InfinityInventoryFilter) ---@field index uint diff --git a/.vscode/factorio/runtime-api-custom.lua b/.vscode/factorio/runtime-api-custom.lua index 6f45bae..7cca405 100644 --- a/.vscode/factorio/runtime-api-custom.lua +++ b/.vscode/factorio/runtime-api-custom.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section custom -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-defines.lua b/.vscode/factorio/runtime-api-defines.lua index a01278a..d711fb2 100644 --- a/.vscode/factorio/runtime-api-defines.lua +++ b/.vscode/factorio/runtime-api-defines.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section defines -- This file is automatically generated. Edits will be overwritten. @@ -1028,6 +1028,8 @@ defines.entity_status={} ---@class defines.events.on_permission_string_imported : defines.events ---[View documentation](https://lua-api.factorio.com/latest/defines.html#defines.events.on_picked_up_item) ---@class defines.events.on_picked_up_item : defines.events +---[View documentation](https://lua-api.factorio.com/latest/defines.html#defines.events.on_player_alt_reverse_selected_area) +---@class defines.events.on_player_alt_reverse_selected_area : defines.events ---[View documentation](https://lua-api.factorio.com/latest/defines.html#defines.events.on_player_alt_selected_area) ---@class defines.events.on_player_alt_selected_area : defines.events ---[View documentation](https://lua-api.factorio.com/latest/defines.html#defines.events.on_player_ammo_inventory_changed) @@ -1323,6 +1325,7 @@ defines.entity_status={} ---@field on_permission_group_edited defines.events.on_permission_group_edited ---@field on_permission_string_imported defines.events.on_permission_string_imported ---@field on_picked_up_item defines.events.on_picked_up_item +---@field on_player_alt_reverse_selected_area defines.events.on_player_alt_reverse_selected_area ---@field on_player_alt_selected_area defines.events.on_player_alt_selected_area ---@field on_player_ammo_inventory_changed defines.events.on_player_ammo_inventory_changed ---@field on_player_armor_inventory_changed defines.events.on_player_armor_inventory_changed @@ -1573,6 +1576,8 @@ defines.gui_type={} ---@class defines.input_action.add_train_station : defines.input_action ---[View documentation](https://lua-api.factorio.com/latest/defines.html#defines.input_action.admin_action) ---@class defines.input_action.admin_action : defines.input_action +---[View documentation](https://lua-api.factorio.com/latest/defines.html#defines.input_action.alt_reverse_select_area) +---@class defines.input_action.alt_reverse_select_area : defines.input_action ---[View documentation](https://lua-api.factorio.com/latest/defines.html#defines.input_action.alt_select_area) ---@class defines.input_action.alt_select_area : defines.input_action ---[View documentation](https://lua-api.factorio.com/latest/defines.html#defines.input_action.alt_select_blueprint_entities) @@ -1969,6 +1974,7 @@ defines.gui_type={} ---@field add_permission_group defines.input_action.add_permission_group ---@field add_train_station defines.input_action.add_train_station ---@field admin_action defines.input_action.admin_action +---@field alt_reverse_select_area defines.input_action.alt_reverse_select_area ---@field alt_select_area defines.input_action.alt_select_area ---@field alt_select_blueprint_entities defines.input_action.alt_select_blueprint_entities ---@field alternative_copy defines.input_action.alternative_copy diff --git a/.vscode/factorio/runtime-api-events.lua b/.vscode/factorio/runtime-api-events.lua index b30991f..c6d5af5 100644 --- a/.vscode/factorio/runtime-api-events.lua +++ b/.vscode/factorio/runtime-api-events.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section events -- This file is automatically generated. Edits will be overwritten. @@ -1554,6 +1554,44 @@ ---[View documentation](https://lua-api.factorio.com/latest/events.html#on_picked_up_item) ---@field tick uint +---@alias on_player_alt_reverse_selected_area EventData.on_player_alt_reverse_selected_area +---Called after a player alt-reverse-selects an area with a selection-tool item. +--- +---[View documentation](https://lua-api.factorio.com/latest/events.html#on_player_alt_reverse_selected_area) +---@class EventData.on_player_alt_reverse_selected_area : EventData +---The area selected. +--- +---[View documentation](https://lua-api.factorio.com/latest/events.html#on_player_alt_reverse_selected_area) +---@field area BoundingBox +---The entities selected. +--- +---[View documentation](https://lua-api.factorio.com/latest/events.html#on_player_alt_reverse_selected_area) +---@field entities LuaEntity[] +---The item used to select the area. +--- +---[View documentation](https://lua-api.factorio.com/latest/events.html#on_player_alt_reverse_selected_area) +---@field item string +---Identifier of the event +--- +---[View documentation](https://lua-api.factorio.com/latest/events.html#on_player_alt_reverse_selected_area) +---@field name defines.events +---The player doing the selection. +--- +---[View documentation](https://lua-api.factorio.com/latest/events.html#on_player_alt_reverse_selected_area) +---@field player_index uint +---The surface selected. +--- +---[View documentation](https://lua-api.factorio.com/latest/events.html#on_player_alt_reverse_selected_area) +---@field surface LuaSurface +---Tick the event was generated. +--- +---[View documentation](https://lua-api.factorio.com/latest/events.html#on_player_alt_reverse_selected_area) +---@field tick uint +---The tiles selected. +--- +---[View documentation](https://lua-api.factorio.com/latest/events.html#on_player_alt_reverse_selected_area) +---@field tiles LuaTile[] + ---@alias on_player_alt_selected_area EventData.on_player_alt_selected_area ---Called after a player alt-selects an area with a selection-tool item. --- diff --git a/.vscode/factorio/runtime-api-global_functions.lua b/.vscode/factorio/runtime-api-global_functions.lua index 00d5115..9979baf 100644 --- a/.vscode/factorio/runtime-api-global_functions.lua +++ b/.vscode/factorio/runtime-api-global_functions.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section global_functions -- This file is automatically generated. Edits will be overwritten. diff --git a/.vscode/factorio/runtime-api-table_types.lua b/.vscode/factorio/runtime-api-table_types.lua index 2ccef3e..62a0e15 100644 --- a/.vscode/factorio/runtime-api-table_types.lua +++ b/.vscode/factorio/runtime-api-table_types.lua @@ -1,7 +1,7 @@ ---@meta ---@diagnostic disable ---$Factorio 1.1.70 +--$Factorio 1.1.72 --$Overlay 5 --$Section table_types -- This file is automatically generated. Edits will be overwritten. From e86562fb41bb29a18553b096ce9c293238cba965 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Fri, 2 Dec 2022 12:51:53 -0500 Subject: [PATCH 02/12] Fixed combinator displays --- TODO | 4 +-- cybersyn/changelog.txt | 6 ++++ cybersyn/info.json | 2 +- cybersyn/scripts/central-planning.lua | 45 ++++++++++++++---------- cybersyn/scripts/factorio-api.lua | 49 ++++++++++----------------- cybersyn/scripts/global.lua | 17 +++++----- cybersyn/scripts/main.lua | 41 +++++++++++++++------- cybersyn/scripts/migrations.lua | 18 ++++++++++ 8 files changed, 107 insertions(+), 75 deletions(-) diff --git a/TODO b/TODO index 4a5ec4a..0cd1f1f 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,5 @@ bugs: - request threshold is being bypassed somehow - wagon control combinators don't work parallel to the tracks + request threshold is being bypassed somehow (hasn't been seen in a long time) major: do hardcore testing @@ -12,4 +11,3 @@ minor: close gui when the combinator is destroyed do not play close sound when a different gui is opened gui can desync if settings are changed outside of it while it is open - go over init and make it agree with type info diff --git a/cybersyn/changelog.txt b/cybersyn/changelog.txt index f18de02..c968cc3 100644 --- a/cybersyn/changelog.txt +++ b/cybersyn/changelog.txt @@ -99,3 +99,9 @@ Version: 1.0.7 Date: 2022-12-1 Features: - Fixed a crash relating to depot bypass through space elevators +--------------------------------------------------------------------------------------------------- +Version: 1.0.8 +Date: 2022-12-1 + Features: + - Fixed a bug with combinator displays not updating correctly + - Improved combinator display performance diff --git a/cybersyn/info.json b/cybersyn/info.json index 544767c..5289cc9 100644 --- a/cybersyn/info.json +++ b/cybersyn/info.json @@ -1,6 +1,6 @@ { "name": "cybersyn", - "version": "1.0.7", + "version": "1.0.8", "title": "Project Cybersyn", "author": "Mami", "factorio_version": "1.1", diff --git a/cybersyn/scripts/central-planning.lua b/cybersyn/scripts/central-planning.lua index bf47478..8ee9b6b 100644 --- a/cybersyn/scripts/central-planning.lua +++ b/cybersyn/scripts/central-planning.lua @@ -9,8 +9,6 @@ local band = bit32.band local table_remove = table.remove local random = math.random - - ---@param map_data MapData ---@param station Station ---@param manifest Manifest @@ -24,8 +22,9 @@ function remove_manifest(map_data, station, manifest, sign) end set_comb2(map_data, station) station.deliveries_total = station.deliveries_total - 1 - if station.deliveries_total == 0 and station.entity_comb1.valid then - set_comb_operation_with_check(map_data, station.entity_comb1, OPERATION_PRIMARY_IO) + if station.deliveries_total == 0 and station.display_state >= 2 then + station.display_state = station.display_state - 2 + update_display(map_data, station) end end @@ -206,11 +205,14 @@ local function send_train_between(map_data, r_station_id, p_station_id, train_id set_comb2(map_data, p_station) set_comb2(map_data, r_station) - if p_station.entity_comb1.valid then - set_comb_operation_with_check(map_data, p_station.entity_comb1, OPERATION_PRIMARY_IO_ACTIVE) + + if p_station.display_state < 2 then + p_station.display_state = 2 + update_display(map_data, p_station) end - if r_station.entity_comb1.valid then - set_comb_operation_with_check(map_data, r_station.entity_comb1, OPERATION_PRIMARY_IO_ACTIVE) + if r_station.display_state < 2 then + r_station.display_state = 2 + update_display(map_data, r_station) end end end @@ -258,11 +260,6 @@ local function tick_poll_station(map_data, mod_settings) station_id = map_data.active_station_ids[tick_data.i] station = map_data.stations[station_id] if station then - if station.display_update then - update_combinator_display(map_data, station.entity_comb1, station.display_failed_request) - station.display_update = station.display_failed_request - station.display_failed_request = nil - end if station.network_name and station.deliveries_total < station.entity_stop.trains_limit then break end @@ -325,6 +322,9 @@ local function tick_poll_station(map_data, mod_settings) end stations[#stations + 1] = station_id station.p_count_or_r_threshold_per_item[item_name] = r_threshold + elseif station.display_state%2 == 1 then + station.display_state = station.display_state - 1 + update_display(map_data, station) end end if flag then @@ -391,9 +391,9 @@ local function tick_dispatch(map_data, mod_settings) else for i, id in ipairs(r_stations) do local station = stations[id] - if station then - station.display_failed_request = true - station.display_update = true + if station and station.display_state%2 == 0 then + station.display_state = station.display_state + 1 + update_display(map_data, station) end end end @@ -419,6 +419,13 @@ local function tick_dispatch(map_data, mod_settings) end end if not r_station_i then + for i, id in ipairs(r_stations) do + local station = stations[id] + if station and station.display_state%2 == 0 then + station.display_state = station.display_state + 1 + update_display(map_data, station) + end + end return false end @@ -464,8 +471,10 @@ local function tick_dispatch(map_data, mod_settings) if can_be_serviced then send_missing_train_alert_for_stops(r_station.entity_stop, stations[p_stations[best_i]].entity_stop) end - r_station.display_failed_request = true - r_station.display_update = true + if r_station.display_state%2 == 0 then + r_station.display_state = r_station.display_state + 1 + update_display(map_data, r_station) + end end table_remove(r_stations, r_station_i) diff --git a/cybersyn/scripts/factorio-api.lua b/cybersyn/scripts/factorio-api.lua index 6253647..79b5a70 100644 --- a/cybersyn/scripts/factorio-api.lua +++ b/cybersyn/scripts/factorio-api.lua @@ -256,7 +256,7 @@ end ---@param map_data MapData ---@param unit_number uint ---@param params ArithmeticCombinatorParameters -function has_comb_params_changed(map_data, unit_number, params) +local function has_comb_params_changed(map_data, unit_number, params) local old_params = map_data.to_comb_params[unit_number] if params.operation ~= old_params.operation then @@ -278,41 +278,26 @@ function has_comb_params_changed(map_data, unit_number, params) return false end ---@param map_data MapData ----@param comb LuaEntity ----@param op string -function set_comb_operation_with_check(map_data, comb, op) - ---@type uint - local unit_number = comb.unit_number - local control = get_comb_control(comb) - local params = control.parameters - if not has_comb_params_changed(map_data, unit_number, params) then - params.operation = op - control.parameters = params - if (op == OPERATION_PRIMARY_IO_ACTIVE or op == OPERATION_PRIMARY_IO_FAILED_REQUEST) then - params.operation = OPERATION_PRIMARY_IO - end - map_data.to_comb_params[unit_number] = params - end -end ----@param map_data MapData ----@param comb LuaEntity ----@param is_failed boolean -function update_combinator_display(map_data, comb, is_failed) - ---@type uint - local unit_number = comb.unit_number - local control = get_comb_control(comb) - local params = control.parameters - if not has_comb_params_changed(map_data, unit_number, params) then - if is_failed then - if params.operation == OPERATION_PRIMARY_IO then +---@param station Station +function update_display(map_data, station) + local comb = station.entity_comb1 + if comb.valid then + local unit_number = comb.unit_number--[[@as uint]] + local control = get_comb_control(comb) + local params = control.parameters + if not has_comb_params_changed(map_data, unit_number, params) then + if station.display_state >= 2 then + params.operation = OPERATION_PRIMARY_IO_ACTIVE + control.parameters = params + params.operation = OPERATION_PRIMARY_IO + elseif station.display_state == 1 then params.operation = OPERATION_PRIMARY_IO_FAILED_REQUEST control.parameters = params params.operation = OPERATION_PRIMARY_IO - map_data.to_comb_params[unit_number] = params + else + params.operation = OPERATION_PRIMARY_IO + control.parameters = params end - elseif params.operation == OPERATION_PRIMARY_IO_FAILED_REQUEST then - params.operation = OPERATION_PRIMARY_IO - control.parameters = params map_data.to_comb_params[unit_number] = params end end diff --git a/cybersyn/scripts/global.lua b/cybersyn/scripts/global.lua index b85347d..e5a623d 100644 --- a/cybersyn/scripts/global.lua +++ b/cybersyn/scripts/global.lua @@ -20,6 +20,9 @@ ---@field public se_tele_old_id {[any]: uint} ---@class Station +---@field public entity_stop LuaEntity +---@field public entity_comb1 LuaEntity +---@field public entity_comb2 LuaEntity? ---@field public is_p boolean ---@field public is_r boolean ---@field public allows_all_trains boolean @@ -28,19 +31,15 @@ ---@field public priority int --transient ---@field public r_threshold int >= 0 --transient ---@field public locked_slots int >= 0 --transient ----@field public entity_stop LuaEntity ----@field public entity_comb1 LuaEntity ----@field public entity_comb2 LuaEntity? ----@field public wagon_combs {[int]: LuaEntity}?--NOTE: allowed to be invalid entities or combinators with the wrong operation, these must be checked and lazy deleted when found ----@field public deliveries {[string]: int} ---@field public network_name string? ---@field public network_flag int --transient +---@field public wagon_combs {[int]: LuaEntity}?--NOTE: allowed to be invalid entities or combinators with the wrong operation, these must be checked and lazy deleted when found +---@field public deliveries {[string]: int} ---@field public accepted_layouts {[uint]: true?} ---@field public layout_pattern {[uint]: int} ---@field public tick_signals {[uint]: Signal}? --transient ---@field public p_count_or_r_threshold_per_item {[string]: int} --transient ----@field public display_failed_request true? ----@field public display_update true? +---@field public display_state 0|1|2|3 --low bit is if this station's request has failed, high bit is if a train is heading to this station ---@class Depot ---@field public entity_stop LuaEntity @@ -57,7 +56,7 @@ ---@field public r_station_id uint ---@field public manifest Manifest ---@field public last_manifest_tick int ----@field public has_filtered_wagon boolean +---@field public has_filtered_wagon true? ---@field public is_available true? ---@field public parked_at_depot_id uint? ---@field public depot_name string @@ -73,7 +72,7 @@ ---@alias cybersyn.global MapData ---@class Economy ----could contain invalid stations +---could contain invalid stations or stations with modified settings from when they were first appended ---@field public all_r_stations {[string]: uint[]} --{[network_name:item_name]: station_id} ---@field public all_p_stations {[string]: uint[]} --{[network_name:item_name]: station_id} ---@field public all_names (string|SignalID)[] diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index 1c513aa..96c78e3 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -69,11 +69,12 @@ local function add_available_train(map_data, train_id, train) end end ---@param map_data MapData +---@param mod_settings CybersynModSettings ---@param depot_id uint ---@param depot Depot ---@param train_id uint ---@param train Train -local function add_available_train_to_depot(map_data, train_id, train, depot_id, depot) +local function add_available_train_to_depot(map_data, mod_settings, train_id, train, depot_id, depot) local comb = depot.entity_comb local network_name = get_comb_network_name(comb) if network_name then @@ -133,10 +134,11 @@ end ---@param stop LuaEntity ---@param comb LuaEntity local function on_depot_built(map_data, stop, comb) + --NOTE: only place where new Depot local depot = { entity_stop = stop, entity_comb = comb, - --available_train = nil, + available_train_id = nil, } map_data.depots[stop.unit_number] = depot end @@ -159,21 +161,28 @@ end ---@param comb1 LuaEntity ---@param comb2 LuaEntity local function on_station_built(map_data, stop, comb1, comb2) + --NOTE: only place where new Station local station = { entity_stop = stop, entity_comb1 = comb1, entity_comb2 = comb2, - wagon_combs = nil, + --is_p = set_station_from_comb_state, + --is_r = set_station_from_comb_state, + --allows_all_trains = set_station_from_comb_state, deliveries_total = 0, last_delivery_tick = map_data.total_ticks, priority = 0, r_threshold = 0, locked_slots = 0, + --network_name = set_station_from_comb_state, network_flag = 0, + wagon_combs = nil, deliveries = {}, accepted_layouts = {}, layout_pattern = nil, + tick_signals = nil, p_count_or_r_threshold_per_item = {}, + display_state = 0, } set_station_from_comb_state(station) local id = stop.unit_number--[[@as uint]] @@ -367,7 +376,7 @@ function on_combinator_network_updated(map_data, comb, network_name) if train_id then local train = map_data.trains[train_id] remove_available_train(map_data, train_id, train) - add_available_train_to_depot(map_data, train_id, train, depot_id, depot) + add_available_train_to_depot(map_data, mod_settings, train_id, train, depot_id, depot) end end end @@ -611,7 +620,7 @@ local function on_train_arrives_depot(map_data, depot_id, train_entity) end if is_train_empty then remove_available_train(map_data, train_id, train) - add_available_train_to_depot(map_data, train_id, train, depot_id, map_data.depots[depot_id]) + add_available_train_to_depot(map_data, mod_settings, train_id, train, depot_id, map_data.depots[depot_id]) set_depot_schedule(train_entity, train.depot_name) else --train still has cargo @@ -620,20 +629,28 @@ local function on_train_arrives_depot(map_data, depot_id, train_entity) send_nonempty_train_in_depot_alert(train_entity) end elseif is_train_empty then + --NOTE: only place where new Train train = { - status = STATUS_D, entity = train_entity, - layout_id = 0, - item_slot_capacity = 0, - fluid_capacity = 0, + --layout_id = update_train_layout, + --item_slot_capacity = update_train_layout, + --fluid_capacity = update_train_layout, + --status = add_available_train_to_depot, p_station_id = 0, r_station_id = 0, + manifest = nil, last_manifest_tick = map_data.total_ticks, - --manifest = nil, + has_filtered_wagon = nil, + --is_available = add_available_train_to_depot, + --parked_at_depot_id = add_available_train_to_depot, + --depot_name = add_available_train_to_depot, + --network_name = add_available_train_to_depot, + --network_flag = add_available_train_to_depot, + --priority = add_available_train_to_depot, } update_train_layout(map_data, train) map_data.trains[train_id] = train - add_available_train_to_depot(map_data, train_id, train, depot_id, map_data.depots[depot_id]) + add_available_train_to_depot(map_data, mod_settings, train_id, train, depot_id, map_data.depots[depot_id]) set_depot_schedule(train_entity, train.depot_name) else @@ -691,7 +708,7 @@ local function on_train_leaves_station(map_data, mod_settings, train_id, train) set_comb1(map_data, station, nil) unset_wagon_combs(map_data, station) if train.has_filtered_wagon then - train.has_filtered_wagon = false + train.has_filtered_wagon = nil for carriage_i, carriage in ipairs(train.entity.cargo_wagons) do local inv = carriage.get_inventory(defines.inventory.cargo_wagon) if inv and inv.is_filtered() then diff --git a/cybersyn/scripts/migrations.lua b/cybersyn/scripts/migrations.lua index f713d63..b7caa98 100644 --- a/cybersyn/scripts/migrations.lua +++ b/cybersyn/scripts/migrations.lua @@ -166,6 +166,24 @@ local migrations_table = { end end end, + ["1.0.8"] = function() + ---@type MapData + local map_data = global + map_data.tick_state = STATE_INIT + map_data.tick_data = {} + for id, station in pairs(map_data.stations) do + local params = get_comb_params(station.entity_comb1) + if params.operation == OPERATION_PRIMARY_IO_FAILED_REQUEST then + station.display_state = 1 + elseif params.operation == OPERATION_PRIMARY_IO_ACTIVE then + station.display_state = 2 + else + station.display_state = 0 + end + station.display_failed_request = nil + station.update_display = nil + end + end, } ---@param data ConfigurationChangedData From ad25cb6187970997bfde76c97daef0c9d42b2d5e Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Fri, 2 Dec 2022 12:58:51 -0500 Subject: [PATCH 03/12] fixed bug and restructured --- cybersyn/scripts/central-planning.lua | 255 +++++++++++++------------- 1 file changed, 127 insertions(+), 128 deletions(-) diff --git a/cybersyn/scripts/central-planning.lua b/cybersyn/scripts/central-planning.lua index 8ee9b6b..094485e 100644 --- a/cybersyn/scripts/central-planning.lua +++ b/cybersyn/scripts/central-planning.lua @@ -217,134 +217,6 @@ local function send_train_between(map_data, r_station_id, p_station_id, train_id end end ----@param map_data MapData ----@param mod_settings CybersynModSettings -local function tick_poll_train(map_data, mod_settings) - local tick_data = map_data.tick_data - --NOTE: the following has undefined behavior if last_train is deleted, this should be ok since the following doesn't care how inconsistent our access pattern is - local train_id, train = next(map_data.trains, tick_data.last_train) - tick_data.last_train = train_id - - if train and train.manifest and not train.se_is_being_teleported and train.last_manifest_tick + mod_settings.stuck_train_time*mod_settings.tps < map_data.total_ticks then - send_stuck_train_alert(train.entity, train.depot_name) - end -end ----@param map_data MapData -local function tick_poll_comb(map_data) - local tick_data = map_data.tick_data - --NOTE: the following has undefined behavior if last_comb is deleted - local comb_id, comb = next(map_data.to_comb, tick_data.last_comb) - tick_data.last_comb = comb_id - - if comb and comb.valid then - combinator_update(map_data, comb) - end -end ----@param map_data MapData ----@param mod_settings CybersynModSettings -local function tick_poll_station(map_data, mod_settings) - local tick_data = map_data.tick_data - local all_r_stations = map_data.economy.all_r_stations - local all_p_stations = map_data.economy.all_p_stations - local all_names = map_data.economy.all_names - - local station_id - local station - while true do--choose a station - tick_data.i = (tick_data.i or 0) + 1 - if tick_data.i > #map_data.active_station_ids then - tick_data.i = nil - map_data.tick_state = STATE_DISPATCH - return true - end - station_id = map_data.active_station_ids[tick_data.i] - station = map_data.stations[station_id] - if station then - if station.network_name and station.deliveries_total < station.entity_stop.trains_limit then - break - end - else - --lazy delete removed stations - table_remove(map_data.active_station_ids, tick_data.i) - tick_data.i = tick_data.i - 1 - end - end - station.r_threshold = mod_settings.r_threshold - station.priority = 0 - station.locked_slots = 0 - station.network_flag = mod_settings.network_flag - local signals = get_signals(station) - station.tick_signals = signals - station.p_count_or_r_threshold_per_item = {} - if signals then - for k, v in pairs(signals) do - local item_name = v.signal.name - local item_count = v.count - local item_type = v.signal.type - if item_name then - if item_type == "virtual" then - if item_name == SIGNAL_PRIORITY then - station.priority = item_count - elseif item_name == REQUEST_THRESHOLD and item_count ~= 0 then - --NOTE: thresholds must be >0 or they can cause a crash - station.r_threshold = abs(item_count) - elseif item_name == LOCKED_SLOTS then - station.locked_slots = max(item_count, 0) - end - signals[k] = nil - end - if item_name == station.network_name then - station.network_flag = item_count - signals[k] = nil - end - else - signals[k] = nil - end - end - for k, v in pairs(signals) do - ---@type string - local item_name = v.signal.name - local item_count = v.count - local effective_item_count = item_count + (station.deliveries[item_name] or 0) - - local flag = true - if station.is_r then - local r_threshold = get_threshold(map_data, station, v.signal) - if -effective_item_count >= r_threshold and -item_count >= r_threshold then - flag = false - local item_network_name = station.network_name..":"..item_name - local stations = all_r_stations[item_network_name] - if stations == nil then - stations = {} - all_r_stations[item_network_name] = stations - all_names[#all_names + 1] = item_network_name - all_names[#all_names + 1] = v.signal - end - stations[#stations + 1] = station_id - station.p_count_or_r_threshold_per_item[item_name] = r_threshold - elseif station.display_state%2 == 1 then - station.display_state = station.display_state - 1 - update_display(map_data, station) - end - end - if flag then - if station.is_p and effective_item_count > 0 and item_count > 0 then - local item_network_name = station.network_name..":"..item_name - local stations = all_p_stations[item_network_name] - if stations == nil then - stations = {} - all_p_stations[item_network_name] = stations - end - stations[#stations + 1] = station_id - station.p_count_or_r_threshold_per_item[item_name] = effective_item_count - else - signals[k] = nil - end - end - end - end - return false -end ---@param map_data MapData ---@param mod_settings CybersynModSettings local function tick_dispatch(map_data, mod_settings) @@ -482,6 +354,133 @@ local function tick_dispatch(map_data, mod_settings) end ---@param map_data MapData ---@param mod_settings CybersynModSettings +local function tick_poll_station(map_data, mod_settings) + local tick_data = map_data.tick_data + local all_r_stations = map_data.economy.all_r_stations + local all_p_stations = map_data.economy.all_p_stations + local all_names = map_data.economy.all_names + + local station_id + local station + while true do--choose a station + tick_data.i = (tick_data.i or 0) + 1 + if tick_data.i > #map_data.active_station_ids then + tick_data.i = nil + map_data.tick_state = STATE_DISPATCH + return true + end + station_id = map_data.active_station_ids[tick_data.i] + station = map_data.stations[station_id] + if station then + if station.network_name and station.deliveries_total < station.entity_stop.trains_limit then + break + end + else + --lazy delete removed stations + table_remove(map_data.active_station_ids, tick_data.i) + tick_data.i = tick_data.i - 1 + end + end + station.r_threshold = mod_settings.r_threshold + station.priority = 0 + station.locked_slots = 0 + station.network_flag = mod_settings.network_flag + local signals = get_signals(station) + station.tick_signals = signals + station.p_count_or_r_threshold_per_item = {} + if signals then + for k, v in pairs(signals) do + local item_name = v.signal.name + local item_count = v.count + local item_type = v.signal.type + if item_name then + if item_type == "virtual" then + if item_name == SIGNAL_PRIORITY then + station.priority = item_count + elseif item_name == REQUEST_THRESHOLD and item_count ~= 0 then + --NOTE: thresholds must be >0 or they can cause a crash + station.r_threshold = abs(item_count) + elseif item_name == LOCKED_SLOTS then + station.locked_slots = max(item_count, 0) + end + signals[k] = nil + end + if item_name == station.network_name then + station.network_flag = item_count + signals[k] = nil + end + else + signals[k] = nil + end + end + local is_requesting_nothing = true + for k, v in pairs(signals) do + ---@type string + local item_name = v.signal.name + local item_count = v.count + local effective_item_count = item_count + (station.deliveries[item_name] or 0) + + if station.is_r then + local r_threshold = get_threshold(map_data, station, v.signal) + if -effective_item_count >= r_threshold and -item_count >= r_threshold then + is_requesting_nothing = false + local item_network_name = station.network_name..":"..item_name + local stations = all_r_stations[item_network_name] + if stations == nil then + stations = {} + all_r_stations[item_network_name] = stations + all_names[#all_names + 1] = item_network_name + all_names[#all_names + 1] = v.signal + end + stations[#stations + 1] = station_id + station.p_count_or_r_threshold_per_item[item_name] = r_threshold + end + end + if station.is_p and effective_item_count > 0 and item_count > 0 then + local item_network_name = station.network_name..":"..item_name + local stations = all_p_stations[item_network_name] + if stations == nil then + stations = {} + all_p_stations[item_network_name] = stations + end + stations[#stations + 1] = station_id + station.p_count_or_r_threshold_per_item[item_name] = effective_item_count + else + signals[k] = nil + end + end + if is_requesting_nothing and station.display_state%2 == 1 then + station.display_state = station.display_state - 1 + update_display(map_data, station) + end + end + return false +end +---@param map_data MapData +---@param mod_settings CybersynModSettings +local function tick_poll_train(map_data, mod_settings) + local tick_data = map_data.tick_data + --NOTE: the following has undefined behavior if last_train is deleted, this should be ok since the following doesn't care how inconsistent our access pattern is + local train_id, train = next(map_data.trains, tick_data.last_train) + tick_data.last_train = train_id + + if train and train.manifest and not train.se_is_being_teleported and train.last_manifest_tick + mod_settings.stuck_train_time*mod_settings.tps < map_data.total_ticks then + send_stuck_train_alert(train.entity, train.depot_name) + end +end +---@param map_data MapData +local function tick_poll_comb(map_data) + local tick_data = map_data.tick_data + --NOTE: the following has undefined behavior if last_comb is deleted + local comb_id, comb = next(map_data.to_comb, tick_data.last_comb) + tick_data.last_comb = comb_id + + if comb and comb.valid then + combinator_update(map_data, comb) + end +end +---@param map_data MapData +---@param mod_settings CybersynModSettings function tick(map_data, mod_settings) map_data.total_ticks = map_data.total_ticks + 1 if map_data.tick_state == STATE_INIT then From e168812068583ab1045e258db61adf9394bb4ed1 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Fri, 2 Dec 2022 13:13:09 -0500 Subject: [PATCH 04/12] fixed bug --- cybersyn/scripts/central-planning.lua | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/cybersyn/scripts/central-planning.lua b/cybersyn/scripts/central-planning.lua index 094485e..104ca2d 100644 --- a/cybersyn/scripts/central-planning.lua +++ b/cybersyn/scripts/central-planning.lua @@ -420,9 +420,11 @@ local function tick_poll_station(map_data, mod_settings) local item_count = v.count local effective_item_count = item_count + (station.deliveries[item_name] or 0) + local is_not_requesting = true if station.is_r then local r_threshold = get_threshold(map_data, station, v.signal) if -effective_item_count >= r_threshold and -item_count >= r_threshold then + is_not_requesting = false is_requesting_nothing = false local item_network_name = station.network_name..":"..item_name local stations = all_r_stations[item_network_name] @@ -436,17 +438,19 @@ local function tick_poll_station(map_data, mod_settings) station.p_count_or_r_threshold_per_item[item_name] = r_threshold end end - if station.is_p and effective_item_count > 0 and item_count > 0 then - local item_network_name = station.network_name..":"..item_name - local stations = all_p_stations[item_network_name] - if stations == nil then - stations = {} - all_p_stations[item_network_name] = stations + if is_not_requesting then + if station.is_p and effective_item_count > 0 and item_count > 0 then + local item_network_name = station.network_name..":"..item_name + local stations = all_p_stations[item_network_name] + if stations == nil then + stations = {} + all_p_stations[item_network_name] = stations + end + stations[#stations + 1] = station_id + station.p_count_or_r_threshold_per_item[item_name] = effective_item_count + else + signals[k] = nil end - stations[#stations + 1] = station_id - station.p_count_or_r_threshold_per_item[item_name] = effective_item_count - else - signals[k] = nil end end if is_requesting_nothing and station.display_state%2 == 1 then From aa6e7deedd1c76d4179e2710e7e83fcabd660b23 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Fri, 2 Dec 2022 13:23:37 -0500 Subject: [PATCH 05/12] removed redundant steps --- cybersyn/scripts/factorio-api.lua | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cybersyn/scripts/factorio-api.lua b/cybersyn/scripts/factorio-api.lua index 79b5a70..6285a6f 100644 --- a/cybersyn/scripts/factorio-api.lua +++ b/cybersyn/scripts/factorio-api.lua @@ -286,19 +286,16 @@ function update_display(map_data, station) local control = get_comb_control(comb) local params = control.parameters if not has_comb_params_changed(map_data, unit_number, params) then - if station.display_state >= 2 then + if station.display_state == 3 then + params.operation = OPERATION_PRIMARY_IO_ACTIVE + elseif station.display_state == 2 then params.operation = OPERATION_PRIMARY_IO_ACTIVE - control.parameters = params - params.operation = OPERATION_PRIMARY_IO elseif station.display_state == 1 then params.operation = OPERATION_PRIMARY_IO_FAILED_REQUEST - control.parameters = params - params.operation = OPERATION_PRIMARY_IO else params.operation = OPERATION_PRIMARY_IO - control.parameters = params end - map_data.to_comb_params[unit_number] = params + control.parameters = params end end end From 9c8c54c3ee7e5a427ed8abfcc56b2d246739cc11 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Fri, 2 Dec 2022 13:37:42 -0500 Subject: [PATCH 06/12] minor performance improvements --- cybersyn/scripts/factorio-api.lua | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/cybersyn/scripts/factorio-api.lua b/cybersyn/scripts/factorio-api.lua index 6285a6f..b75988a 100644 --- a/cybersyn/scripts/factorio-api.lua +++ b/cybersyn/scripts/factorio-api.lua @@ -286,9 +286,7 @@ function update_display(map_data, station) local control = get_comb_control(comb) local params = control.parameters if not has_comb_params_changed(map_data, unit_number, params) then - if station.display_state == 3 then - params.operation = OPERATION_PRIMARY_IO_ACTIVE - elseif station.display_state == 2 then + if station.display_state >= 2 then params.operation = OPERATION_PRIMARY_IO_ACTIVE elseif station.display_state == 1 then params.operation = OPERATION_PRIMARY_IO_FAILED_REQUEST @@ -346,19 +344,18 @@ function set_combinator_output(map_data, comb, signals) end end -local WORKING = defines.entity_status.working -local LOW_POWER = defines.entity_status.low_power +local DEFINES_WORKING = defines.entity_status.working +local DEFINES_LOW_POWER = defines.entity_status.low_power +local DEFINES_COMBINATOR_INPUT = defines.circuit_connector_id.combinator_input ---@param station Station function get_signals(station) + --NOTE: the combinator must be valid, but checking for valid every time is too slow local comb = station.entity_comb1 - if comb.valid then - local status = comb.status - if status == WORKING or status == LOW_POWER then - return comb.get_merged_signals(defines.circuit_connector_id.combinator_input) - end - else - return nil + local status = comb.status + if status == DEFINES_WORKING or status == DEFINES_LOW_POWER then + return comb.get_merged_signals(DEFINES_COMBINATOR_INPUT) end + return nil end ---@param map_data MapData @@ -382,7 +379,7 @@ end ---@param signal SignalID function get_threshold(map_data, station, signal) local comb2 = station.entity_comb2 - if comb2 and comb2.valid then + if comb2 then local count = comb2.get_merged_signal(signal, defines.circuit_connector_id.combinator_input) if count ~= 0 then return abs(count) From 37e4eb22fd4c650574e5207293fb0c26e0dcfc74 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Fri, 2 Dec 2022 13:58:33 -0500 Subject: [PATCH 07/12] updated todo --- TODO | 1 + cybersyn/scripts/central-planning.lua | 1 + 2 files changed, 2 insertions(+) diff --git a/TODO b/TODO index 0cd1f1f..0b17f91 100644 --- a/TODO +++ b/TODO @@ -11,3 +11,4 @@ minor: close gui when the combinator is destroyed do not play close sound when a different gui is opened gui can desync if settings are changed outside of it while it is open + give the combinators a sensible reaction to low or no power diff --git a/cybersyn/scripts/central-planning.lua b/cybersyn/scripts/central-planning.lua index 104ca2d..d2edec2 100644 --- a/cybersyn/scripts/central-planning.lua +++ b/cybersyn/scripts/central-planning.lua @@ -372,6 +372,7 @@ local function tick_poll_station(map_data, mod_settings) station_id = map_data.active_station_ids[tick_data.i] station = map_data.stations[station_id] if station then + --NOTE: polling trains_limit here is expensive and not strictly necessary but using it to early out saves more ups if station.network_name and station.deliveries_total < station.entity_stop.trains_limit then break end From 89cd588f45ca5af760e4668a0454fa624333dafc Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Fri, 2 Dec 2022 14:18:22 -0500 Subject: [PATCH 08/12] fixed date --- cybersyn/changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cybersyn/changelog.txt b/cybersyn/changelog.txt index c968cc3..5b6ed79 100644 --- a/cybersyn/changelog.txt +++ b/cybersyn/changelog.txt @@ -101,7 +101,7 @@ Date: 2022-12-1 - Fixed a crash relating to depot bypass through space elevators --------------------------------------------------------------------------------------------------- Version: 1.0.8 -Date: 2022-12-1 +Date: 2022-12-2 Features: - Fixed a bug with combinator displays not updating correctly - Improved combinator display performance From 7ef59f00ffa938fe84af21d0b3ade1af20daf524 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Sat, 3 Dec 2022 11:40:38 -0500 Subject: [PATCH 09/12] added a modding interface --- cybersyn/changelog.txt | 1 + cybersyn/control.lua | 1 + cybersyn/scripts/central-planning.lua | 15 +- cybersyn/scripts/global.lua | 2 +- cybersyn/scripts/layout.lua | 3 +- cybersyn/scripts/main.lua | 48 ++- cybersyn/scripts/remote-interface.lua | 427 ++++++++++++++++++++++++++ 7 files changed, 475 insertions(+), 22 deletions(-) create mode 100644 cybersyn/scripts/remote-interface.lua diff --git a/cybersyn/changelog.txt b/cybersyn/changelog.txt index 5b6ed79..1fa9cc0 100644 --- a/cybersyn/changelog.txt +++ b/cybersyn/changelog.txt @@ -105,3 +105,4 @@ Date: 2022-12-2 Features: - Fixed a bug with combinator displays not updating correctly - Improved combinator display performance + - Added a modding interface diff --git a/cybersyn/control.lua b/cybersyn/control.lua index 7b5da94..c1eff6c 100644 --- a/cybersyn/control.lua +++ b/cybersyn/control.lua @@ -8,3 +8,4 @@ require("scripts.layout") require("scripts.gui") require("scripts.migrations") require("scripts.main") +require("scripts.remote-interface") diff --git a/cybersyn/scripts/central-planning.lua b/cybersyn/scripts/central-planning.lua index d2edec2..cfa3422 100644 --- a/cybersyn/scripts/central-planning.lua +++ b/cybersyn/scripts/central-planning.lua @@ -12,6 +12,7 @@ local random = math.random ---@param map_data MapData ---@param station Station ---@param manifest Manifest +---@param sign -1|1 function remove_manifest(map_data, station, manifest, sign) local deliveries = station.deliveries for i, item in ipairs(manifest) do @@ -94,8 +95,8 @@ end ---@param r_station_id uint ---@param p_station_id uint ---@param train_id uint ----@param primary_item_name string -local function send_train_between(map_data, r_station_id, p_station_id, train_id, primary_item_name) +---@param primary_item_name string? +function send_train_between(map_data, r_station_id, p_station_id, train_id, primary_item_name) --trains and stations expected to be of the same network local economy = map_data.economy local r_station = map_data.stations[r_station_id] @@ -140,9 +141,6 @@ local function send_train_between(map_data, r_station_id, p_station_id, train_id local i = 1 while i <= #manifest do local item = manifest[i] - if item.count < 1000 then - local hello = true - end local keep_item = false if item.type == "fluid" then if total_liquid_left > 0 then @@ -214,6 +212,9 @@ local function send_train_between(map_data, r_station_id, p_station_id, train_id r_station.display_state = 2 update_display(map_data, r_station) end + interface_raise_train_dispatched(map_data, train_id) + else + interface_raise_train_dispatch_failed(map_data, train_id) end end @@ -471,6 +472,7 @@ local function tick_poll_train(map_data, mod_settings) if train and train.manifest and not train.se_is_being_teleported and train.last_manifest_tick + mod_settings.stuck_train_time*mod_settings.tps < map_data.total_ticks then send_stuck_train_alert(train.entity, train.depot_name) + interface_raise_train_stuck(map_data, train_id) end end ---@param map_data MapData @@ -492,7 +494,6 @@ function tick(map_data, mod_settings) map_data.economy.all_p_stations = {} map_data.economy.all_r_stations = {} map_data.economy.all_names = {} - map_data.tick_state = STATE_POLL_STATIONS for i, id in pairs(map_data.warmup_station_ids) do local station = map_data.stations[id] if station then @@ -504,6 +505,8 @@ function tick(map_data, mod_settings) map_data.warmup_station_ids[i] = nil end end + map_data.tick_state = STATE_POLL_STATIONS + interface_raise_tick_init(map_data) tick_poll_train(map_data, mod_settings) tick_poll_comb(map_data) end diff --git a/cybersyn/scripts/global.lua b/cybersyn/scripts/global.lua index e5a623d..ee78786 100644 --- a/cybersyn/scripts/global.lua +++ b/cybersyn/scripts/global.lua @@ -47,7 +47,7 @@ ---@field public available_train_id uint?--train_id ---@class Train ----@field public entity LuaTrain +---@field public entity LuaTrain --should only be invalid if se_is_being_teleported is true ---@field public layout_id uint ---@field public item_slot_capacity int ---@field public fluid_capacity int diff --git a/cybersyn/scripts/layout.lua b/cybersyn/scripts/layout.lua index 410fd5a..81dffe4 100644 --- a/cybersyn/scripts/layout.lua +++ b/cybersyn/scripts/layout.lua @@ -3,8 +3,6 @@ local area = require("__flib__.area") local abs = math.abs local floor = math.floor local ceil = math.ceil -local string_find = string.find -local string_sub = string.sub local function table_compare(t0, t1) @@ -73,6 +71,7 @@ function remove_train(map_data, train_id, train) map_data.layout_train_count[layout_id] = count - 1 end map_data.trains[train_id] = nil + interface_raise_train_removed(map_data, train_id, train) end diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index 96c78e3..6dd9760 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -25,8 +25,9 @@ local function set_comb1(map_data, station, manifest, sign) end ---@param map_data MapData +---@param train_id uint ---@param train Train -local function on_failed_delivery(map_data, train) +function on_failed_delivery(map_data, train_id, train) --NOTE: must change train status to STATUS_D or remove it from tracked trains after this call local is_p_delivery_made = train.status ~= STATUS_D_TO_P and train.status ~= STATUS_P if not is_p_delivery_made then @@ -49,6 +50,7 @@ local function on_failed_delivery(map_data, train) train.r_station_id = 0 train.p_station_id = 0 train.manifest = nil + interface_raise_train_failed_delivery(map_data, train_id, is_p_delivery_made, is_r_delivery_made) end @@ -56,7 +58,7 @@ end ---@param map_data MapData ---@param train_id uint ---@param train Train -local function add_available_train(map_data, train_id, train) +function add_available_train(map_data, train_id, train) local network_name = train.network_name if network_name then local network = map_data.available_trains[network_name] @@ -66,6 +68,7 @@ local function add_available_train(map_data, train_id, train) end network[train_id] = true train.is_available = true + interface_raise_train_available(map_data, train_id) end end ---@param map_data MapData @@ -74,7 +77,7 @@ end ---@param depot Depot ---@param train_id uint ---@param train Train -local function add_available_train_to_depot(map_data, mod_settings, train_id, train, depot_id, depot) +function add_available_train_to_depot(map_data, mod_settings, train_id, train, depot_id, depot) local comb = depot.entity_comb local network_name = get_comb_network_name(comb) if network_name then @@ -110,6 +113,7 @@ local function add_available_train_to_depot(map_data, mod_settings, train_id, tr end end end + interface_raise_train_available(map_data, train_id) end end ---@param map_data MapData @@ -134,13 +138,15 @@ end ---@param stop LuaEntity ---@param comb LuaEntity local function on_depot_built(map_data, stop, comb) - --NOTE: only place where new Depot + --NOTE: only place where new Depot local depot = { entity_stop = stop, entity_comb = comb, available_train_id = nil, } - map_data.depots[stop.unit_number] = depot + local depot_id = stop.unit_number--[[@as uint]] + map_data.depots[depot_id] = depot + interface_raise_depot_created(map_data, depot_id) end ---@param map_data MapData @@ -153,7 +159,9 @@ local function on_depot_broken(map_data, depot) send_lost_train_alert(train.entity, depot.entity_stop.backer_name) remove_train(map_data, train_id, train) end - map_data.depots[depot.entity_stop.unit_number] = nil + local depot_id = depot.entity_stop.unit_number--[[@as uint]] + map_data.depots[depot_id] = nil + interface_raise_depot_removed(map_data, depot_id, depot) end ---@param map_data MapData @@ -190,6 +198,7 @@ local function on_station_built(map_data, stop, comb1, comb2) map_data.warmup_station_ids[#map_data.warmup_station_ids + 1] = id update_station_if_auto(map_data, station, nil) + interface_raise_station_created(map_data, id) end ---@param map_data MapData ---@param station_id uint @@ -205,7 +214,7 @@ local function on_station_broken(map_data, station_id, station) local is_r_delivery_made = train.status == STATUS_R_TO_D if (is_r and not is_r_delivery_made) or (is_p and not is_p_delivery_made) then --train is attempting delivery to a stop that was destroyed, stop it - on_failed_delivery(map_data, train) + on_failed_delivery(map_data, train_id, train) if not train.se_is_being_teleported then remove_train(map_data, train_id, train) lock_train(train.entity) @@ -218,6 +227,7 @@ local function on_station_broken(map_data, station_id, station) end end map_data.stations[station_id] = nil + interface_raise_station_removed(map_data, station_id, station) end ---@param map_data MapData @@ -441,6 +451,7 @@ function combinator_update(map_data, comb) local control = get_comb_control(comb) local params = control.parameters local old_params = map_data.to_comb_params[unit_number] + local has_changed = false if params.operation ~= old_params.operation then if (old_params.operation == OPERATION_PRIMARY_IO) and (params.operation == OPERATION_PRIMARY_IO_ACTIVE or params.operation == OPERATION_PRIMARY_IO_FAILED_REQUEST) then @@ -450,6 +461,7 @@ function combinator_update(map_data, comb) --NOTE: This is rather dangerous, we may need to actually implement operation changing on_combinator_broken(map_data, comb) on_combinator_built(map_data, comb) + interface_raise_combinator_changed(map_data, comb, old_params) return end end @@ -459,7 +471,6 @@ function combinator_update(map_data, comb) local old_network = old_signal and old_signal.name or nil if new_network ~= old_network then on_combinator_network_updated(map_data, comb, new_network) - map_data.to_comb_params[unit_number] = params end if params.second_constant ~= old_params.second_constant then local stop = global.to_stop[comb.unit_number] @@ -477,7 +488,10 @@ function combinator_update(map_data, comb) end end end + end + if has_changed then map_data.to_comb_params[unit_number] = params + interface_raise_combinator_changed(map_data, comb, old_params) end end @@ -614,7 +628,7 @@ local function on_train_arrives_depot(map_data, depot_id, train_entity) train.r_station_id = 0 train.manifest = nil else - on_failed_delivery(map_data, train) + on_failed_delivery(map_data, train_id, train) send_unexpected_train_alert(train.entity) end end @@ -622,11 +636,13 @@ local function on_train_arrives_depot(map_data, depot_id, train_entity) remove_available_train(map_data, train_id, train) add_available_train_to_depot(map_data, mod_settings, train_id, train, depot_id, map_data.depots[depot_id]) set_depot_schedule(train_entity, train.depot_name) + interface_raise_train_parked_at_depot(map_data, train_id, depot_id) else --train still has cargo lock_train(train_entity) remove_train(map_data, train_id, train) send_nonempty_train_in_depot_alert(train_entity) + interface_raise_train_nonempty_in_depot(map_data, depot_id, train_entity, train_id) end elseif is_train_empty then --NOTE: only place where new Train @@ -653,9 +669,11 @@ local function on_train_arrives_depot(map_data, depot_id, train_entity) add_available_train_to_depot(map_data, mod_settings, train_id, train, depot_id, map_data.depots[depot_id]) set_depot_schedule(train_entity, train.depot_name) + interface_raise_train_created(map_data, train_id, depot_id) else lock_train(train_entity) send_nonempty_train_in_depot_alert(train_entity) + interface_raise_train_nonempty_in_depot(map_data, depot_id, train_entity) end end ---@param map_data MapData @@ -685,7 +703,7 @@ local function on_train_arrives_buffer(map_data, stop, train_id, train) elseif (train.status == STATUS_R or train.status == STATUS_R_TO_D) and train.r_station_id == station_id then --this player intervention that is considered valid else - on_failed_delivery(map_data, train) + on_failed_delivery(map_data, train_id, train) remove_train(map_data, train_id, train) lock_train(train.entity) send_lost_train_alert(train.entity, train.depot_name) @@ -719,6 +737,7 @@ local function on_train_leaves_station(map_data, mod_settings, train_id, train) end end end + interface_raise_train_completed_provide(map_data, train_id) elseif train.status == STATUS_R then train.status = STATUS_R_TO_D local station = map_data.stations[train.r_station_id] @@ -752,6 +771,7 @@ local function on_train_leaves_station(map_data, mod_settings, train_id, train) elseif fuel_fill/total_slots > mod_settings.depot_bypass_threshold then add_available_train(map_data, train_id, train) end + interface_raise_train_completed_request(map_data, train_id) end elseif train.status == STATUS_D then --The train is leaving the depot without a manifest, the player likely intervened @@ -769,7 +789,7 @@ local function on_train_broken(map_data, train_id, train) --NOTE: train.entity is only absent if the train is climbing a space elevator as of 0.5.0 if not train.se_is_being_teleported then if train.manifest then - on_failed_delivery(map_data, train) + on_failed_delivery(map_data, train_id, train) end remove_train(map_data, train_id, train) end @@ -781,7 +801,7 @@ local function on_train_modified(map_data, pre_train_id) --NOTE: train.entity is only absent if the train is climbing a space elevator as of 0.5.0 if train and not train.se_is_being_teleported then if train.manifest then - on_failed_delivery(map_data, train) + on_failed_delivery(map_data, pre_train_id, train) end remove_train(map_data, pre_train_id, train) end @@ -997,9 +1017,10 @@ local function main() local train = map_data.trains[old_id] if not train then return end - --NOTE: IMPORTANT, until se_on_train_teleport_finished_event is called map_data.trains[old_id] will reference an invalid train entity; very few of our events care about this and the ones that do should be impossible to trigger until teleportation is finished + --NOTE: IMPORTANT, until se_on_train_teleport_finished_event is called map_data.trains[old_id] will reference an invalid train entity; our events have either been set up to account for this or should be impossible to trigger until teleportation is finished train.se_is_being_teleported = true map_data.se_tele_old_id[train_unique_identifier] = old_id + interface_raise_train_teleport_started(map_data, old_id) end) flib_event.register(se_on_train_teleport_finished_event, function(event) ---@type MapData @@ -1065,6 +1086,7 @@ local function main() end train_entity.schedule = schedule end + interface_raise_train_teleported(map_data, new_id, old_id) end) end) end diff --git a/cybersyn/scripts/remote-interface.lua b/cybersyn/scripts/remote-interface.lua new file mode 100644 index 0000000..aa36f56 --- /dev/null +++ b/cybersyn/scripts/remote-interface.lua @@ -0,0 +1,427 @@ +--By Mami +local raise_event = script.raise_event +local script_generate_event_name = script.generate_event_name + +------------------------------------------------------------------ +--[[all events]] +------------------------------------------------------------------ +--NOTE: events only start to be raised when a mod has called its associated "get" function +--NOTE: if there is a useful event missing you may submit a request for it to be added on the mod portal. + +local on_combinator_changed = nil +local on_station_created = nil +local on_station_removed = nil +local on_depot_created = nil +local on_depot_removed = nil +local on_train_created = nil +local on_train_removed = nil +local on_train_available = nil +local on_train_nonempty_in_depot = nil +local on_train_dispatched = nil +local on_train_dispatch_failed = nil +local on_train_failed_delivery = nil +local on_train_completed_provide = nil +local on_train_completed_request = nil +local on_train_parked_at_depot = nil +local on_train_teleport_started = nil +local on_train_teleported = nil +local on_train_stuck = nil +local on_tick_init = nil + +---@param map_data MapData +---@param entity LuaEntity +---@param old_parameters ArithmeticCombinatorParameters +function interface_raise_combinator_changed(map_data, entity, old_parameters) + if on_combinator_changed then + raise_event(on_combinator_changed, { + map_data = map_data, + entity = entity, + old_parameters = old_parameters, + }) + end +end + +---@param map_data MapData +---@param station_id uint +function interface_raise_station_created(map_data, station_id) + if on_station_created then + raise_event(on_station_created, { + map_data = map_data, + station_id = station_id, + }) + end +end +---@param map_data MapData +---@param old_station_id uint +---@param old_station Station +function interface_raise_station_removed(map_data, old_station_id, old_station) + if on_station_removed then + raise_event(on_station_removed, { + map_data = map_data, + old_station_id = old_station_id, --this id is now invalid + old_station = old_station, --this is the data that used to be stored at the old id + }) + end +end + +---@param map_data MapData +---@param depot_id uint +function interface_raise_depot_created(map_data, depot_id) + if on_depot_created then + raise_event(on_depot_created, { + map_data = map_data, + depot_id = depot_id, + }) + end +end +---@param map_data MapData +---@param old_depot_id uint +---@param old_depot Depot +function interface_raise_depot_removed(map_data, old_depot_id, old_depot) + if on_depot_removed then + raise_event(on_depot_removed, { + map_data = map_data, + old_depot_id = old_depot_id, --this id is now invalid + old_depot = old_depot, --this is the data that used to be stored at the old id + }) + end +end + +---@param map_data MapData +---@param train_id uint +---@param depot_id uint +function interface_raise_train_created(map_data, train_id, depot_id) + if on_train_created then + raise_event(on_train_created, { + map_data = map_data, + train_id = train_id, + depot_id = depot_id, + }) + end +end +---@param map_data MapData +---@param old_train_id uint +---@param old_train Train +function interface_raise_train_removed(map_data, old_train_id, old_train) + if on_train_removed then + raise_event(on_train_removed, { + map_data = map_data, + old_train_id = old_train_id, --this id is now invalid + old_train = old_train, --this is the data that used to be stored at the old id + }) + end +end +---@param map_data MapData +---@param train_id uint +function interface_raise_train_available(map_data, train_id) + if on_train_available then + raise_event(on_train_available, { + map_data = map_data, + train_id = train_id, + }) + end +end +---@param map_data MapData +---@param depot_id uint +---@param train_entity LuaTrain +---@param train_id uint? +function interface_raise_train_nonempty_in_depot(map_data, depot_id, train_entity, train_id) + if on_train_nonempty_in_depot then + raise_event(on_train_nonempty_in_depot, { + map_data = map_data, + train_entity = train_entity, + train_id = train_id, + depot_id = depot_id, + }) + end +end + +---@param map_data MapData +---@param train_id uint +function interface_raise_train_dispatched(map_data, train_id) + if on_train_dispatched then + raise_event(on_train_dispatched, { + map_data = map_data, + train_id = train_id, + }) + end +end +---@param map_data MapData +---@param train_id uint +function interface_raise_train_dispatch_failed(map_data, train_id) + if on_train_dispatch_failed then + raise_event(on_train_dispatch_failed, { + map_data = map_data, + train_id = train_id, + }) + end +end +---@param map_data MapData +---@param train_id uint +---@param is_p_delivery_made boolean +---@param is_r_delivery_made boolean +function interface_raise_train_failed_delivery(map_data, train_id, is_p_delivery_made, is_r_delivery_made) + if on_train_failed_delivery then + raise_event(on_train_failed_delivery, { + map_data = map_data, + train_id = train_id, + is_p_delivery_made = is_p_delivery_made, + is_r_delivery_made = is_r_delivery_made, + }) + end +end +---@param map_data MapData +---@param train_id uint +function interface_raise_train_completed_provide(map_data, train_id) + if on_train_completed_provide then + raise_event(on_train_completed_provide, { + map_data = map_data, + train_id = train_id, + }) + end +end +---@param map_data MapData +---@param train_id uint +function interface_raise_train_completed_request(map_data, train_id) + if on_train_completed_request then + raise_event(on_train_completed_request, { + map_data = map_data, + train_id = train_id, + }) + end +end +---@param map_data MapData +---@param train_id uint +---@param depot_id uint +function interface_raise_train_parked_at_depot(map_data, train_id, depot_id) + if on_train_parked_at_depot then + raise_event(on_train_parked_at_depot, { + map_data = map_data, + train_id = train_id, + depot_id = depot_id, + }) + end +end +---@param map_data MapData +---@param train_id uint +function interface_raise_train_stuck(map_data, train_id) + if on_train_stuck then + raise_event(on_train_stuck, { + map_data = map_data, + train_id = train_id, + }) + end +end +---@param map_data MapData +---@param old_train_id uint +function interface_raise_train_teleport_started(map_data, old_train_id) + if on_train_teleport_started then + raise_event(on_train_teleport_started, { + map_data = map_data, + old_train_id = old_train_id,--this id is currently valid but will become valid just before on_train_teleported is raised + }) + end +end +---@param map_data MapData +---@param new_train_id uint +---@param old_train_id uint +function interface_raise_train_teleported(map_data, new_train_id, old_train_id) + if on_train_teleported then + raise_event(on_train_teleported, { + map_data = map_data, + new_train_id = new_train_id,--this id stores the train + old_train_id = old_train_id,--this id is now invalid + }) + end +end + +---@param map_data MapData +function interface_raise_tick_init(map_data) + if on_tick_init then + raise_event(on_tick_init, { + map_data = map_data, + }) + end +end + + +local interface = {} + +------------------------------------------------------------------ +--[[get event id functions]] +------------------------------------------------------------------ + +function interface.get_on_combinator_changed() + if not on_combinator_changed then on_combinator_changed = script_generate_event_name() end + return on_combinator_changed +end +function interface.get_on_station_created() + if not on_station_created then on_station_created = script_generate_event_name() end + return on_station_created +end +function interface.get_on_station_removed() + if not on_station_removed then on_station_removed = script_generate_event_name() end + return on_station_removed +end +function interface.get_on_depot_created() + if not on_depot_created then on_depot_created = script_generate_event_name() end + return on_depot_created +end +function interface.get_on_depot_removed() + if not on_depot_removed then on_depot_removed = script_generate_event_name() end + return on_depot_removed +end +function interface.get_on_train_created() + if not on_train_created then on_train_created = script_generate_event_name() end + return on_train_created +end +function interface.get_on_train_removed() + if not on_train_removed then on_train_removed = script_generate_event_name() end + return on_train_removed +end +function interface.get_on_train_available() + if not on_train_available then on_train_available = script_generate_event_name() end + return on_train_available +end +function interface.get_on_train_nonempty_in_depot() + if not on_train_nonempty_in_depot then on_train_nonempty_in_depot = script_generate_event_name() end + return on_train_nonempty_in_depot +end +function interface.get_on_train_dispatched() + if not on_train_dispatched then on_train_dispatched = script_generate_event_name() end + return on_train_dispatched +end +function interface.get_on_train_dispatch_failed() + if not on_train_dispatch_failed then on_train_dispatch_failed = script_generate_event_name() end + return on_train_dispatch_failed +end +function interface.get_on_train_failed_delivery() + if not on_train_failed_delivery then on_train_failed_delivery = script_generate_event_name() end + return on_train_failed_delivery +end +function interface.get_on_train_completed_provide() + if not on_train_completed_provide then on_train_completed_provide = script_generate_event_name() end + return on_train_completed_provide +end +function interface.get_on_train_completed_request() + if not on_train_completed_request then on_train_completed_request = script_generate_event_name() end + return on_train_completed_request +end +function interface.get_on_train_parked_at_depot() + if not on_train_parked_at_depot then on_train_parked_at_depot = script_generate_event_name() end + return on_train_parked_at_depot +end +function interface.get_on_train_stuck() + if not on_train_stuck then on_train_stuck = script_generate_event_name() end + return on_train_stuck +end +function interface.get_on_train_teleport_started() + if not on_train_teleport_started then on_train_teleport_started = script_generate_event_name() end + return on_train_teleport_started +end +function interface.get_on_train_teleported() + if not on_train_teleported then on_train_teleported = script_generate_event_name() end + return on_train_teleported +end +function interface.get_on_tick_init() + if not on_tick_init then on_tick_init = script_generate_event_name() end + return on_tick_init +end + + +------------------------------------------------------------------ +--[[internal API access]] +------------------------------------------------------------------ +--NOTE: The following, while they can be called from outside the mod safely, can cause serious longterm damage if they are given bad parameters. Extercise caution. + +---@param station_id Station +---@param manifest Manifest +---@param sign -1|1 +function interface.remove_manifest(station_id, manifest, sign) + local station = global.stations[station_id] + assert(station) + remove_manifest(global, station, manifest, sign) +end +---@param r_station_id uint +---@param p_station_id uint +---@param train_id uint +---@param primary_item_name string? +function interface.send_train_between(r_station_id, p_station_id, train_id, primary_item_name) + local train = global.trains[train_id] + assert(global.stations[r_station_id] and global.stations[p_station_id] and train and train.is_available) + send_train_between(global, r_station_id, p_station_id, train_id, primary_item_name) +end +---@param train_id uint +function interface.failed_delivery(train_id) + local train = global.trains[train_id] + assert(train) + on_failed_delivery(global, train_id, train) +end + +---@param train_id uint +function interface.add_available_train(train_id) + local train = global.trains[train_id] + assert(train) + add_available_train(global, train_id, train) +end +---@param depot_id uint +---@param train_id uint +function interface.add_available_train_to_depot(train_id, depot_id) + local train = global.trains[train_id] + local depot = global.depots[depot_id] + assert(train and depot) + add_available_train_to_depot(global, mod_settings, train_id, train, depot_id, depot) +end +---@param train_id uint +function interface.remove_available_train(train_id) + local train = global.trains[train_id] + assert(train) + remove_available_train(global, train_id, train) +end +---@param comb LuaEntity +function interface.combinator_update(comb) + combinator_update(global, comb) +end + +------------------------------------------------------------------ +--[[helper functions]] +------------------------------------------------------------------ +--NOTE: the policy of cybersyn is to give modders access to the raw data of the mod, please either treat all tables returned from the modding interface as "read only", or if you do modify them take responsibility that your modification does not result in an error occuring in cybersyn later on. +--NOTE: the follow functions are unnecessary, the are provided more as a guide how the mod api works rather than as practical functions. + +function interface.get_map_data() + return global +end +function interface.get_mod_settings() + return mod_settings +end +---@param id uint +function interface.get_station(id) + return global.stations[id] +end +---@param id uint +function interface.get_depot(id) + return global.depots[id] +end +---@param id uint +function interface.get_train(id) + return global.trains[id] +end +---@param train_entity LuaTrain +function interface.get_train_id_from_luatrain(train_entity) + return train_entity.id +end +---@param stop LuaEntity +function interface.get_station_or_depot_id_from_stop(stop) + return stop.unit_number +end +---@param comb LuaEntity +function interface.get_station_or_depot_id_from_comb(comb) + local stop = global.to_stop[comb.unit_number] + if stop then + return stop.unit_number + end +end + + +remote.add_interface("cybersyn", interface) From b3442920ff124358107b722c019d4d478660d246 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Sat, 3 Dec 2022 13:03:33 -0500 Subject: [PATCH 10/12] improved modding interface --- TODO | 2 +- cybersyn/scripts/central-planning.lua | 16 +-- cybersyn/scripts/constants.lua | 1 + cybersyn/scripts/factorio-api.lua | 2 +- cybersyn/scripts/global.lua | 18 ++- cybersyn/scripts/layout.lua | 22 +--- cybersyn/scripts/main.lua | 98 ++++++++------- cybersyn/scripts/remote-interface.lua | 166 +++++++++++++++----------- 8 files changed, 183 insertions(+), 142 deletions(-) diff --git a/TODO b/TODO index 0b17f91..216d128 100644 --- a/TODO +++ b/TODO @@ -4,7 +4,7 @@ bugs: major: do hardcore testing models & art - add a modding interface (the moment someone asks for this I will make sure it's in the next update) + add a refueling option on depots minor: railloader compat diff --git a/cybersyn/scripts/central-planning.lua b/cybersyn/scripts/central-planning.lua index cfa3422..ab3f8bf 100644 --- a/cybersyn/scripts/central-planning.lua +++ b/cybersyn/scripts/central-planning.lua @@ -212,9 +212,9 @@ function send_train_between(map_data, r_station_id, p_station_id, train_id, prim r_station.display_state = 2 update_display(map_data, r_station) end - interface_raise_train_dispatched(map_data, train_id) + interface_raise_train_dispatched(train_id) else - interface_raise_train_dispatch_failed(map_data, train_id) + interface_raise_train_dispatch_failed(train_id) end end @@ -341,8 +341,8 @@ local function tick_dispatch(map_data, mod_settings) send_train_between(map_data, r_station_id, table_remove(p_stations, best_i), best_train, item_name) return false else - if can_be_serviced then - send_missing_train_alert_for_stops(r_station.entity_stop, stations[p_stations[best_i]].entity_stop) + if can_be_serviced and mod_settings.missing_train_alert_enabled then + send_missing_train_alert(r_station.entity_stop, stations[p_stations[best_i]].entity_stop) end if r_station.display_state%2 == 0 then r_station.display_state = r_station.display_state + 1 @@ -471,8 +471,10 @@ local function tick_poll_train(map_data, mod_settings) tick_data.last_train = train_id if train and train.manifest and not train.se_is_being_teleported and train.last_manifest_tick + mod_settings.stuck_train_time*mod_settings.tps < map_data.total_ticks then - send_stuck_train_alert(train.entity, train.depot_name) - interface_raise_train_stuck(map_data, train_id) + if mod_settings.stuck_train_alert_enabled then + send_stuck_train_alert(train.entity, train.depot_name) + end + interface_raise_train_stuck(train_id) end end ---@param map_data MapData @@ -506,7 +508,7 @@ function tick(map_data, mod_settings) end end map_data.tick_state = STATE_POLL_STATIONS - interface_raise_tick_init(map_data) + interface_raise_tick_init() tick_poll_train(map_data, mod_settings) tick_poll_comb(map_data) end diff --git a/cybersyn/scripts/constants.lua b/cybersyn/scripts/constants.lua index 0881a22..3127558 100644 --- a/cybersyn/scripts/constants.lua +++ b/cybersyn/scripts/constants.lua @@ -34,6 +34,7 @@ STATUS_P = 2 STATUS_P_TO_R = 3 STATUS_R = 4 STATUS_R_TO_D = 5 +STATUS_CUSTOM = 256 --this status and any status greater than it can be used by other mods (I've reserved the lower integers for myself in case I want to add more statuses) LONGEST_INSERTER_REACH = 2 diff --git a/cybersyn/scripts/factorio-api.lua b/cybersyn/scripts/factorio-api.lua index b75988a..9a21e18 100644 --- a/cybersyn/scripts/factorio-api.lua +++ b/cybersyn/scripts/factorio-api.lua @@ -397,7 +397,7 @@ end local send_missing_train_alert_for_stop_icon = {name = MISSING_TRAIN_NAME, type = "fluid"} ---@param r_stop LuaEntity ---@param p_stop LuaEntity -function send_missing_train_alert_for_stops(r_stop, p_stop) +function send_missing_train_alert(r_stop, p_stop) for _, player in pairs(r_stop.force.players) do player.add_custom_alert( r_stop, diff --git a/cybersyn/scripts/global.lua b/cybersyn/scripts/global.lua index ee78786..fd14273 100644 --- a/cybersyn/scripts/global.lua +++ b/cybersyn/scripts/global.lua @@ -12,7 +12,7 @@ ---@field public depots {[uint]: Depot} ---@field public trains {[uint]: Train} ---@field public available_trains {[string]: {[uint]: true?}} --{[network_name]: {[train_id]: depot_id}} ----@field public layouts {[uint]: int[]} +---@field public layouts {[uint]: (0|1|2)[]} ---@field public layout_train_count {[uint]: int} ---@field public tick_state uint ---@field public tick_data {} @@ -36,7 +36,7 @@ ---@field public wagon_combs {[int]: LuaEntity}?--NOTE: allowed to be invalid entities or combinators with the wrong operation, these must be checked and lazy deleted when found ---@field public deliveries {[string]: int} ---@field public accepted_layouts {[uint]: true?} ----@field public layout_pattern {[uint]: int} +---@field public layout_pattern (0|1|2|3)[]? ---@field public tick_signals {[uint]: Signal}? --transient ---@field public p_count_or_r_threshold_per_item {[string]: int} --transient ---@field public display_state 0|1|2|3 --low bit is if this station's request has failed, high bit is if a train is heading to this station @@ -68,8 +68,11 @@ ---@field public se_awaiting_removal any? --se only ---@field public se_awaiting_rename any? --se only ----@alias Manifest {}[] ----@alias cybersyn.global MapData +---@alias Manifest ManifestEntry[] +---@class ManifestEntry +---@field public type string +---@field public name string +---@field public count uint ---@class Economy ---could contain invalid stations or stations with modified settings from when they were first appended @@ -77,6 +80,7 @@ ---@field public all_p_stations {[string]: uint[]} --{[network_name:item_name]: station_id} ---@field public all_names (string|SignalID)[] +--NOTE: any setting labeled as an interface setting can only be changed through the remote-interface, these settings are not save and have to be set at initialization ---@class CybersynModSettings ---@field public tps double ---@field public update_rate int @@ -85,7 +89,13 @@ ---@field public warmup_time double ---@field public stuck_train_time double ---@field public depot_bypass_threshold double +---@field public missing_train_alert_enabled boolean --interface setting +---@field public stuck_train_alert_enabled boolean --interface setting +---@field public react_to_nonempty_train_in_depot boolean --interface setting +---@field public react_to_train_at_incorrect_station boolean --interface setting +---@field public react_to_train_early_to_depot boolean --interface setting +---@alias cybersyn.global MapData ---@type CybersynModSettings mod_settings = {} diff --git a/cybersyn/scripts/layout.lua b/cybersyn/scripts/layout.lua index 81dffe4..9dcda1f 100644 --- a/cybersyn/scripts/layout.lua +++ b/cybersyn/scripts/layout.lua @@ -28,8 +28,9 @@ local function irpairs(a) return iterr, a, 0 end - -local function is_layout_accepted(layout_pattern, layout) +---@param layout_pattern (0|1|2|3)[] +---@param layout (0|1|2)[] +function is_layout_accepted(layout_pattern, layout) local valid = true for i, v in ipairs(layout) do local p = layout_pattern[i] or 0 @@ -59,25 +60,14 @@ function remove_train(map_data, train_id, train) depot.available_train_id = nil end remove_available_train(map_data, train_id, train) - local layout_id = train.layout_id - local count = map_data.layout_train_count[layout_id] - if count <= 1 then - map_data.layout_train_count[layout_id] = nil - map_data.layouts[layout_id] = nil - for station_id, station in pairs(map_data.stations) do - station.accepted_layouts[layout_id] = nil - end - else - map_data.layout_train_count[layout_id] = count - 1 - end map_data.trains[train_id] = nil - interface_raise_train_removed(map_data, train_id, train) + interface_raise_train_removed(train_id, train) end ---@param map_data MapData ---@param train Train -function update_train_layout(map_data, train) +function set_train_layout(map_data, train) local carriages = train.entity.carriages local layout = {} local i = 1 @@ -186,7 +176,7 @@ function set_p_wagon_combs(map_data, station, train) while item_slots_capacity > 0 do local do_inc = false if item.type == "item" then - local stack_size = game.item_prototypes[item.name].stack_size + local stack_size = get_stack_size(map_data, item.name) local item_slots = ceil(item_count/stack_size) local i = #signals + 1 local slots_to_filter diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index 6dd9760..744d3d2 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -28,9 +28,10 @@ end ---@param train_id uint ---@param train Train function on_failed_delivery(map_data, train_id, train) - --NOTE: must change train status to STATUS_D or remove it from tracked trains after this call - local is_p_delivery_made = train.status ~= STATUS_D_TO_P and train.status ~= STATUS_P - if not is_p_delivery_made then + --NOTE: must either change this train's status or remove it after this call + local is_p_in_progress = train.status == STATUS_D_TO_P or train.status == STATUS_P + local is_r_in_progress = is_p_in_progress or train.status == STATUS_P_TO_R or train.status == STATUS_R + if is_p_in_progress then local station = map_data.stations[train.p_station_id] remove_manifest(map_data, station, train.manifest, 1) if train.status == STATUS_P then @@ -38,8 +39,7 @@ function on_failed_delivery(map_data, train_id, train) unset_wagon_combs(map_data, station) end end - local is_r_delivery_made = train.status == STATUS_R_TO_D - if not is_r_delivery_made then + if is_r_in_progress then local station = map_data.stations[train.r_station_id] remove_manifest(map_data, station, train.manifest, -1) if train.status == STATUS_R then @@ -47,10 +47,10 @@ function on_failed_delivery(map_data, train_id, train) unset_wagon_combs(map_data, station) end end + interface_raise_train_failed_delivery(train_id, is_p_in_progress, is_r_in_progress) train.r_station_id = 0 train.p_station_id = 0 train.manifest = nil - interface_raise_train_failed_delivery(map_data, train_id, is_p_delivery_made, is_r_delivery_made) end @@ -68,7 +68,7 @@ function add_available_train(map_data, train_id, train) end network[train_id] = true train.is_available = true - interface_raise_train_available(map_data, train_id) + interface_raise_train_available(train_id) end end ---@param map_data MapData @@ -113,7 +113,7 @@ function add_available_train_to_depot(map_data, mod_settings, train_id, train, d end end end - interface_raise_train_available(map_data, train_id) + interface_raise_train_available(train_id) end end ---@param map_data MapData @@ -146,7 +146,7 @@ local function on_depot_built(map_data, stop, comb) } local depot_id = stop.unit_number--[[@as uint]] map_data.depots[depot_id] = depot - interface_raise_depot_created(map_data, depot_id) + interface_raise_depot_created(depot_id) end ---@param map_data MapData @@ -161,7 +161,7 @@ local function on_depot_broken(map_data, depot) end local depot_id = depot.entity_stop.unit_number--[[@as uint]] map_data.depots[depot_id] = nil - interface_raise_depot_removed(map_data, depot_id, depot) + interface_raise_depot_removed(depot_id, depot) end ---@param map_data MapData @@ -198,7 +198,7 @@ local function on_station_built(map_data, stop, comb1, comb2) map_data.warmup_station_ids[#map_data.warmup_station_ids + 1] = id update_station_if_auto(map_data, station, nil) - interface_raise_station_created(map_data, id) + interface_raise_station_created(id) end ---@param map_data MapData ---@param station_id uint @@ -210,9 +210,10 @@ local function on_station_broken(map_data, station_id, station) local is_r = train.r_station_id == station_id local is_p = train.p_station_id == station_id if is_p or is_r then - local is_p_delivery_made = train.status ~= STATUS_D_TO_P and train.status ~= STATUS_P - local is_r_delivery_made = train.status == STATUS_R_TO_D - if (is_r and not is_r_delivery_made) or (is_p and not is_p_delivery_made) then + + local is_p_in_progress = train.status == STATUS_D_TO_P or train.status == STATUS_P + local is_r_in_progress = is_p_in_progress or train.status == STATUS_P_TO_R or train.status == STATUS_R + if (is_p and is_p_in_progress) or (is_r and is_r_in_progress) then --train is attempting delivery to a stop that was destroyed, stop it on_failed_delivery(map_data, train_id, train) if not train.se_is_being_teleported then @@ -227,7 +228,7 @@ local function on_station_broken(map_data, station_id, station) end end map_data.stations[station_id] = nil - interface_raise_station_removed(map_data, station_id, station) + interface_raise_station_removed(station_id, station) end ---@param map_data MapData @@ -461,7 +462,7 @@ function combinator_update(map_data, comb) --NOTE: This is rather dangerous, we may need to actually implement operation changing on_combinator_broken(map_data, comb) on_combinator_built(map_data, comb) - interface_raise_combinator_changed(map_data, comb, old_params) + interface_raise_combinator_changed(comb, old_params) return end end @@ -491,7 +492,7 @@ function combinator_update(map_data, comb) end if has_changed then map_data.to_comb_params[unit_number] = params - interface_raise_combinator_changed(map_data, comb, old_params) + interface_raise_combinator_changed(comb, old_params) end end @@ -568,16 +569,16 @@ local function on_station_rename(map_data, stop, old_name) local is_p = train.p_station_id == station_id local is_r = train.r_station_id == station_id if is_p or is_r then - local is_p_delivery_made = train.status ~= STATUS_D_TO_P and train.status ~= STATUS_P - local is_r_delivery_made = train.status == STATUS_R_TO_D - if is_r and not is_r_delivery_made then + local is_p_in_progress = train.status == STATUS_D_TO_P or train.status == STATUS_P + local is_r_in_progress = is_p_in_progress or train.status == STATUS_P_TO_R or train.status == STATUS_R + if is_r and is_r_in_progress then local r_station = map_data.stations[train.r_station_id] if not train.se_is_being_teleported then rename_manifest_schedule(train.entity, r_station.entity_stop, old_name) else train.se_awaiting_rename = {r_station.entity_stop, old_name} end - elseif is_p and not is_p_delivery_made then + elseif is_p and is_p_in_progress then --train is attempting delivery to a stop that was renamed local p_station = map_data.stations[train.p_station_id] if not train.se_is_being_teleported then @@ -627,30 +628,34 @@ local function on_train_arrives_depot(map_data, depot_id, train_entity) train.p_station_id = 0 train.r_station_id = 0 train.manifest = nil - else + elseif mod_settings.react_to_train_early_to_depot then on_failed_delivery(map_data, train_id, train) send_unexpected_train_alert(train.entity) + else + return end end if is_train_empty then remove_available_train(map_data, train_id, train) add_available_train_to_depot(map_data, mod_settings, train_id, train, depot_id, map_data.depots[depot_id]) set_depot_schedule(train_entity, train.depot_name) - interface_raise_train_parked_at_depot(map_data, train_id, depot_id) + interface_raise_train_parked_at_depot(train_id, depot_id) else --train still has cargo - lock_train(train_entity) - remove_train(map_data, train_id, train) - send_nonempty_train_in_depot_alert(train_entity) - interface_raise_train_nonempty_in_depot(map_data, depot_id, train_entity, train_id) + if mod_settings.react_to_nonempty_train_in_depot then + lock_train(train_entity) + remove_train(map_data, train_id, train) + send_nonempty_train_in_depot_alert(train_entity) + end + interface_raise_train_nonempty_in_depot(depot_id, train_entity, train_id) end elseif is_train_empty then --NOTE: only place where new Train train = { entity = train_entity, - --layout_id = update_train_layout, - --item_slot_capacity = update_train_layout, - --fluid_capacity = update_train_layout, + --layout_id = set_train_layout, + --item_slot_capacity = set_train_layout, + --fluid_capacity = set_train_layout, --status = add_available_train_to_depot, p_station_id = 0, r_station_id = 0, @@ -664,16 +669,18 @@ local function on_train_arrives_depot(map_data, depot_id, train_entity) --network_flag = add_available_train_to_depot, --priority = add_available_train_to_depot, } - update_train_layout(map_data, train) + set_train_layout(map_data, train) map_data.trains[train_id] = train add_available_train_to_depot(map_data, mod_settings, train_id, train, depot_id, map_data.depots[depot_id]) set_depot_schedule(train_entity, train.depot_name) - interface_raise_train_created(map_data, train_id, depot_id) + interface_raise_train_created(train_id, depot_id) else - lock_train(train_entity) - send_nonempty_train_in_depot_alert(train_entity) - interface_raise_train_nonempty_in_depot(map_data, depot_id, train_entity) + if mod_settings.react_to_nonempty_train_in_depot then + lock_train(train_entity) + send_nonempty_train_in_depot_alert(train_entity) + end + interface_raise_train_nonempty_in_depot(depot_id, train_entity) end end ---@param map_data MapData @@ -702,15 +709,16 @@ local function on_train_arrives_buffer(map_data, stop, train_id, train) --this player intervention that is considered valid elseif (train.status == STATUS_R or train.status == STATUS_R_TO_D) and train.r_station_id == station_id then --this player intervention that is considered valid - else + elseif mod_settings.react_to_train_at_incorrect_station then on_failed_delivery(map_data, train_id, train) remove_train(map_data, train_id, train) lock_train(train.entity) send_lost_train_alert(train.entity, train.depot_name) end - else + elseif mod_settings.react_to_train_at_incorrect_station then --train is lost somehow, probably from player intervention remove_train(map_data, train_id, train) + send_lost_train_alert(train.entity, train.depot_name) end end ---@param map_data MapData @@ -737,7 +745,7 @@ local function on_train_leaves_station(map_data, mod_settings, train_id, train) end end end - interface_raise_train_completed_provide(map_data, train_id) + interface_raise_train_completed_provide(train_id) elseif train.status == STATUS_R then train.status = STATUS_R_TO_D local station = map_data.stations[train.r_station_id] @@ -771,13 +779,13 @@ local function on_train_leaves_station(map_data, mod_settings, train_id, train) elseif fuel_fill/total_slots > mod_settings.depot_bypass_threshold then add_available_train(map_data, train_id, train) end - interface_raise_train_completed_request(map_data, train_id) + interface_raise_train_completed_request(train_id) end elseif train.status == STATUS_D then --The train is leaving the depot without a manifest, the player likely intervened local depot = map_data.depots[train.parked_at_depot_id--[[@as uint]]] - send_lost_train_alert(train.entity, depot.entity_stop.backer_name) remove_train(map_data, train_id, train) + send_lost_train_alert(train.entity, depot.entity_stop.backer_name) end end @@ -962,6 +970,12 @@ local function main() mod_settings.warmup_time = settings.global["cybersyn-warmup-time"].value--[[@as double]] mod_settings.stuck_train_time = settings.global["cybersyn-stuck-train-time"].value--[[@as double]] + mod_settings.missing_train_alert_enabled = true + mod_settings.stuck_train_alert_enabled = true + mod_settings.react_to_nonempty_train_in_depot = true + mod_settings.react_to_train_at_incorrect_station = true + mod_settings.react_to_train_early_to_depot = true + --NOTE: There is a concern that it is possible to build or destroy important entities without one of these events being triggered, in which case the mod will have undefined behavior flib_event.register(defines.events.on_built_entity, on_built, filter_built) flib_event.register(defines.events.on_robot_built_entity, on_built, filter_built) @@ -1020,7 +1034,7 @@ local function main() --NOTE: IMPORTANT, until se_on_train_teleport_finished_event is called map_data.trains[old_id] will reference an invalid train entity; our events have either been set up to account for this or should be impossible to trigger until teleportation is finished train.se_is_being_teleported = true map_data.se_tele_old_id[train_unique_identifier] = old_id - interface_raise_train_teleport_started(map_data, old_id) + interface_raise_train_teleport_started(old_id) end) flib_event.register(se_on_train_teleport_finished_event, function(event) ---@type MapData @@ -1086,7 +1100,7 @@ local function main() end train_entity.schedule = schedule end - interface_raise_train_teleported(map_data, new_id, old_id) + interface_raise_train_teleported(new_id, old_id) end) end) end diff --git a/cybersyn/scripts/remote-interface.lua b/cybersyn/scripts/remote-interface.lua index aa36f56..60e559b 100644 --- a/cybersyn/scripts/remote-interface.lua +++ b/cybersyn/scripts/remote-interface.lua @@ -28,107 +28,89 @@ local on_train_teleported = nil local on_train_stuck = nil local on_tick_init = nil ----@param map_data MapData ---@param entity LuaEntity ---@param old_parameters ArithmeticCombinatorParameters -function interface_raise_combinator_changed(map_data, entity, old_parameters) +function interface_raise_combinator_changed(entity, old_parameters) if on_combinator_changed then raise_event(on_combinator_changed, { - map_data = map_data, entity = entity, old_parameters = old_parameters, }) end end ----@param map_data MapData ---@param station_id uint -function interface_raise_station_created(map_data, station_id) +function interface_raise_station_created(station_id) if on_station_created then raise_event(on_station_created, { - map_data = map_data, station_id = station_id, }) end end ----@param map_data MapData ---@param old_station_id uint ---@param old_station Station -function interface_raise_station_removed(map_data, old_station_id, old_station) +function interface_raise_station_removed(old_station_id, old_station) if on_station_removed then raise_event(on_station_removed, { - map_data = map_data, old_station_id = old_station_id, --this id is now invalid old_station = old_station, --this is the data that used to be stored at the old id }) end end ----@param map_data MapData ---@param depot_id uint -function interface_raise_depot_created(map_data, depot_id) +function interface_raise_depot_created(depot_id) if on_depot_created then raise_event(on_depot_created, { - map_data = map_data, depot_id = depot_id, }) end end ----@param map_data MapData ---@param old_depot_id uint ---@param old_depot Depot -function interface_raise_depot_removed(map_data, old_depot_id, old_depot) +function interface_raise_depot_removed(old_depot_id, old_depot) if on_depot_removed then raise_event(on_depot_removed, { - map_data = map_data, old_depot_id = old_depot_id, --this id is now invalid old_depot = old_depot, --this is the data that used to be stored at the old id }) end end ----@param map_data MapData ---@param train_id uint ---@param depot_id uint -function interface_raise_train_created(map_data, train_id, depot_id) +function interface_raise_train_created(train_id, depot_id) if on_train_created then raise_event(on_train_created, { - map_data = map_data, train_id = train_id, depot_id = depot_id, }) end end ----@param map_data MapData ---@param old_train_id uint ---@param old_train Train -function interface_raise_train_removed(map_data, old_train_id, old_train) +function interface_raise_train_removed(old_train_id, old_train) if on_train_removed then raise_event(on_train_removed, { - map_data = map_data, old_train_id = old_train_id, --this id is now invalid old_train = old_train, --this is the data that used to be stored at the old id }) end end ----@param map_data MapData ---@param train_id uint -function interface_raise_train_available(map_data, train_id) +function interface_raise_train_available(train_id) if on_train_available then raise_event(on_train_available, { - map_data = map_data, train_id = train_id, }) end end ----@param map_data MapData ---@param depot_id uint ---@param train_entity LuaTrain ---@param train_id uint? -function interface_raise_train_nonempty_in_depot(map_data, depot_id, train_entity, train_id) +function interface_raise_train_nonempty_in_depot(depot_id, train_entity, train_id) if on_train_nonempty_in_depot then raise_event(on_train_nonempty_in_depot, { - map_data = map_data, train_entity = train_entity, train_id = train_id, depot_id = depot_id, @@ -136,110 +118,90 @@ function interface_raise_train_nonempty_in_depot(map_data, depot_id, train_entit end end ----@param map_data MapData ---@param train_id uint -function interface_raise_train_dispatched(map_data, train_id) +function interface_raise_train_dispatched(train_id) if on_train_dispatched then raise_event(on_train_dispatched, { - map_data = map_data, train_id = train_id, }) end end ----@param map_data MapData ---@param train_id uint -function interface_raise_train_dispatch_failed(map_data, train_id) +function interface_raise_train_dispatch_failed(train_id) if on_train_dispatch_failed then raise_event(on_train_dispatch_failed, { - map_data = map_data, train_id = train_id, }) end end ----@param map_data MapData ---@param train_id uint ----@param is_p_delivery_made boolean ----@param is_r_delivery_made boolean -function interface_raise_train_failed_delivery(map_data, train_id, is_p_delivery_made, is_r_delivery_made) +---@param was_p_in_progress boolean +---@param was_r_in_progress boolean +function interface_raise_train_failed_delivery(train_id, was_p_in_progress, was_r_in_progress) if on_train_failed_delivery then raise_event(on_train_failed_delivery, { - map_data = map_data, train_id = train_id, - is_p_delivery_made = is_p_delivery_made, - is_r_delivery_made = is_r_delivery_made, + was_p_in_progress = was_p_in_progress, + was_r_in_progress = was_r_in_progress, }) end end ----@param map_data MapData ---@param train_id uint -function interface_raise_train_completed_provide(map_data, train_id) +function interface_raise_train_completed_provide(train_id) if on_train_completed_provide then raise_event(on_train_completed_provide, { - map_data = map_data, train_id = train_id, }) end end ----@param map_data MapData ---@param train_id uint -function interface_raise_train_completed_request(map_data, train_id) +function interface_raise_train_completed_request(train_id) if on_train_completed_request then raise_event(on_train_completed_request, { - map_data = map_data, train_id = train_id, }) end end ----@param map_data MapData ---@param train_id uint ---@param depot_id uint -function interface_raise_train_parked_at_depot(map_data, train_id, depot_id) +function interface_raise_train_parked_at_depot(train_id, depot_id) if on_train_parked_at_depot then raise_event(on_train_parked_at_depot, { - map_data = map_data, train_id = train_id, depot_id = depot_id, }) end end ----@param map_data MapData ---@param train_id uint -function interface_raise_train_stuck(map_data, train_id) +function interface_raise_train_stuck(train_id) if on_train_stuck then raise_event(on_train_stuck, { - map_data = map_data, train_id = train_id, }) end end ----@param map_data MapData ---@param old_train_id uint -function interface_raise_train_teleport_started(map_data, old_train_id) +function interface_raise_train_teleport_started(old_train_id) if on_train_teleport_started then raise_event(on_train_teleport_started, { - map_data = map_data, old_train_id = old_train_id,--this id is currently valid but will become valid just before on_train_teleported is raised }) end end ----@param map_data MapData ---@param new_train_id uint ---@param old_train_id uint -function interface_raise_train_teleported(map_data, new_train_id, old_train_id) +function interface_raise_train_teleported(new_train_id, old_train_id) if on_train_teleported then raise_event(on_train_teleported, { - map_data = map_data, new_train_id = new_train_id,--this id stores the train old_train_id = old_train_id,--this id is now invalid }) end end ----@param map_data MapData -function interface_raise_tick_init(map_data) +function interface_raise_tick_init() if on_tick_init then raise_event(on_tick_init, { - map_data = map_data, }) end end @@ -330,14 +292,63 @@ end ------------------------------------------------------------------ ---[[internal API access]] +--[[safe API]] ------------------------------------------------------------------ ---NOTE: The following, while they can be called from outside the mod safely, can cause serious longterm damage if they are given bad parameters. Extercise caution. +--NOTE: These functions can be called whenever however so long as their parameters have the correct types. Their ability to cause harm is extremely minimal. + +---@param comb LuaEntity +function interface.combinator_update(comb) + combinator_update(global, comb) +end + +---@param train_id uint +function interface.update_train_layout(train_id) + local train = global.trains[train_id] + assert(train) + local old_layout_id = train.layout_id + local count = global.layout_train_count[old_layout_id] + if count <= 1 then + global.layout_train_count[old_layout_id] = nil + global.layouts[old_layout_id] = nil + for station_id, station in pairs(global.stations) do + station.accepted_layouts[old_layout_id] = nil + end + else + global.layout_train_count[old_layout_id] = count - 1 + end + set_train_layout(global, train) +end +---@param layout_pattern (0|1|2|3)[] +---@param layout (0|1|2)[] +function interface.is_layout_accepted(layout_pattern, layout) + return is_layout_accepted(layout_pattern, layout) +end +---@param station_id uint +---@param forbidden_entity LuaEntity? +---@param force_update boolean? +function interface.reset_station_layout(station_id, forbidden_entity, force_update) + local station = global.stations[station_id] + assert(station) + if force_update or not station.allows_all_trains then + reset_station_layout(global, station, forbidden_entity) + end +end +---@param rail LuaEntity +---@param forbidden_entity LuaEntity? +---@param force_update boolean? +function interface.update_station_from_rail(rail, forbidden_entity, force_update) + update_station_from_rail(global, rail, forbidden_entity, force_update) +end + +------------------------------------------------------------------ +--[[unsafe API]] +------------------------------------------------------------------ +--NOTE: The following functions can cause serious longterm damage to someone's world if they are given bad parameters. Use caution. ---@param station_id Station ---@param manifest Manifest ---@param sign -1|1 -function interface.remove_manifest(station_id, manifest, sign) +function interface.remove_manifest_from_station_deliveries(station_id, manifest, sign) local station = global.stations[station_id] assert(station) remove_manifest(global, station, manifest, sign) @@ -346,17 +357,23 @@ end ---@param p_station_id uint ---@param train_id uint ---@param primary_item_name string? -function interface.send_train_between(r_station_id, p_station_id, train_id, primary_item_name) +function interface.create_new_delivery_between_stations(r_station_id, p_station_id, train_id, primary_item_name) local train = global.trains[train_id] assert(global.stations[r_station_id] and global.stations[p_station_id] and train and train.is_available) send_train_between(global, r_station_id, p_station_id, train_id, primary_item_name) end ---@param train_id uint -function interface.failed_delivery(train_id) +function interface.fail_delivery(train_id) local train = global.trains[train_id] assert(train) on_failed_delivery(global, train_id, train) end +---@param train_id uint +function interface.remove_train(train_id) + local train = global.trains[train_id] + assert(train) + remove_train(global, train_id, train) +end ---@param train_id uint function interface.add_available_train(train_id) @@ -378,16 +395,23 @@ function interface.remove_available_train(train_id) assert(train) remove_available_train(global, train_id, train) end ----@param comb LuaEntity -function interface.combinator_update(comb) - combinator_update(global, comb) -end + + +------------------------------------------------------------------ +--[[alerts]] +------------------------------------------------------------------ + +interface.send_missing_train_alert = send_missing_train_alert +interface.send_lost_train_alert = send_lost_train_alert +interface.send_unexpected_train_alert = send_unexpected_train_alert +interface.send_nonempty_train_in_depot_alert = send_nonempty_train_in_depot_alert +interface.send_stuck_train_alert = send_stuck_train_alert ------------------------------------------------------------------ --[[helper functions]] ------------------------------------------------------------------ --NOTE: the policy of cybersyn is to give modders access to the raw data of the mod, please either treat all tables returned from the modding interface as "read only", or if you do modify them take responsibility that your modification does not result in an error occuring in cybersyn later on. ---NOTE: the follow functions are unnecessary, the are provided more as a guide how the mod api works rather than as practical functions. +--NOTE: the follow functions aren't strictly necessary; they are provided more as a guide how the mod api works rather than as practical functions. function interface.get_map_data() return global From a2aa8b8c77764e3dc399bd8732ec535f4bf40aa2 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Sat, 3 Dec 2022 13:10:18 -0500 Subject: [PATCH 11/12] fixed interface --- cybersyn/scripts/main.lua | 13 ++++++++----- cybersyn/scripts/remote-interface.lua | 9 ++++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index 744d3d2..21ce8da 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -29,28 +29,31 @@ end ---@param train Train function on_failed_delivery(map_data, train_id, train) --NOTE: must either change this train's status or remove it after this call + local p_station_id = train.p_station_id + local r_station_id = train.r_station_id + local manifest = train.manifest local is_p_in_progress = train.status == STATUS_D_TO_P or train.status == STATUS_P local is_r_in_progress = is_p_in_progress or train.status == STATUS_P_TO_R or train.status == STATUS_R if is_p_in_progress then - local station = map_data.stations[train.p_station_id] - remove_manifest(map_data, station, train.manifest, 1) + local station = map_data.stations[p_station_id] + remove_manifest(map_data, station, manifest, 1) if train.status == STATUS_P then set_comb1(map_data, station, nil) unset_wagon_combs(map_data, station) end end if is_r_in_progress then - local station = map_data.stations[train.r_station_id] - remove_manifest(map_data, station, train.manifest, -1) + local station = map_data.stations[r_station_id] + remove_manifest(map_data, station, manifest, -1) if train.status == STATUS_R then set_comb1(map_data, station, nil) unset_wagon_combs(map_data, station) end end - interface_raise_train_failed_delivery(train_id, is_p_in_progress, is_r_in_progress) train.r_station_id = 0 train.p_station_id = 0 train.manifest = nil + interface_raise_train_failed_delivery(train_id, is_p_in_progress, p_station_id, is_r_in_progress, r_station_id, manifest) end diff --git a/cybersyn/scripts/remote-interface.lua b/cybersyn/scripts/remote-interface.lua index 60e559b..852cd1a 100644 --- a/cybersyn/scripts/remote-interface.lua +++ b/cybersyn/scripts/remote-interface.lua @@ -128,6 +128,7 @@ function interface_raise_train_dispatched(train_id) end ---@param train_id uint function interface_raise_train_dispatch_failed(train_id) + --this event is rare, it can only occur when a train is bypassing the depot and can't find a path to the provide station, that train is marked as unavailable but not dispatched if on_train_dispatch_failed then raise_event(on_train_dispatch_failed, { train_id = train_id, @@ -136,13 +137,19 @@ function interface_raise_train_dispatch_failed(train_id) end ---@param train_id uint ---@param was_p_in_progress boolean +---@param p_station_id uint ---@param was_r_in_progress boolean -function interface_raise_train_failed_delivery(train_id, was_p_in_progress, was_r_in_progress) +---@param r_station_id uint +---@param manifest Manifest +function interface_raise_train_failed_delivery(train_id, was_p_in_progress, p_station_id, was_r_in_progress, r_station_id, manifest) if on_train_failed_delivery then raise_event(on_train_failed_delivery, { train_id = train_id, was_p_in_progress = was_p_in_progress, + p_station_id = p_station_id, was_r_in_progress = was_r_in_progress, + r_station_id = r_station_id, + manifest = manifest, }) end end From 77ac32cf411fe2f0f40d70e5a9fbcb1a5917196d Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Sat, 3 Dec 2022 13:11:35 -0500 Subject: [PATCH 12/12] synced events --- cybersyn/scripts/remote-interface.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cybersyn/scripts/remote-interface.lua b/cybersyn/scripts/remote-interface.lua index 852cd1a..5b8b889 100644 --- a/cybersyn/scripts/remote-interface.lua +++ b/cybersyn/scripts/remote-interface.lua @@ -23,9 +23,9 @@ local on_train_failed_delivery = nil local on_train_completed_provide = nil local on_train_completed_request = nil local on_train_parked_at_depot = nil +local on_train_stuck = nil local on_train_teleport_started = nil local on_train_teleported = nil -local on_train_stuck = nil local on_tick_init = nil ---@param entity LuaEntity