MultiServer: allow multiple, ordered operations

MultiServer: rename "data" on Get, Retrieved and SetNotify to "keys"
MultiServer: add some more operators
SniClient: some pep8 cleanup
This commit is contained in:
Fabian Dill
2022-03-04 21:36:18 +01:00
parent 2c3e3f0d43
commit 7ca6f24e6c
3 changed files with 78 additions and 54 deletions

View File

@@ -169,8 +169,9 @@ async def game_watcher(ctx: FactorioContext):
# attempt to refill
ctx.last_deplete = time.time()
asyncio.create_task(ctx.send_msgs([{
"cmd": "Set", "key": "EnergyLink", "operation": "deplete",
"value": -ctx.energy_link_increment * in_world_bridges,
"cmd": "Set", "key": "EnergyLink", "operations":
[{"operation": "add", "value": -ctx.energy_link_increment * in_world_bridges},
{"operation": "max", "value": 0}],
"last_deplete": ctx.last_deplete
}]))
# Above Capacity - (len(Bridges) * ENERGY_INCREMENT)
@@ -178,8 +179,8 @@ async def game_watcher(ctx: FactorioContext):
ctx.energy_link_increment*in_world_bridges:
value = ctx.energy_link_increment * in_world_bridges
asyncio.create_task(ctx.send_msgs([{
"cmd": "Set", "key": "EnergyLink", "operation": "add",
"value": value
"cmd": "Set", "key": "EnergyLink", "operations":
[{"operation": "add", "value": value}]
}]))
ctx.rcon_client.send_command(
f"/ap-energylink -{value}")