From 1afac80c0d8f87098ca727daa1590f8fc5e28d8f Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Sat, 23 Sep 2023 21:23:23 +0900 Subject: [PATCH 1/5] 2nd cmd of personal logistics. also for spidertron --- modules/data/personal-logistic.lua | 63 ++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/modules/data/personal-logistic.lua b/modules/data/personal-logistic.lua index 2ea28e95..a1159e69 100644 --- a/modules/data/personal-logistic.lua +++ b/modules/data/personal-logistic.lua @@ -1,30 +1,40 @@ local Commands = require 'expcore.commands' --- @dep expcore.commands local config = require 'config.personal_logistic' --- @dep config.personal-logistic ---[[ -Command 2: -add filter based of inventory +local function pl(type, target, amount) + local c + local s -Command 3: -add filter of those not in inventory: all 0 -game.item_prototypes + if type == 'p' then + c = target.clear_personal_logistic_slot + s = target.set_personal_logistic_slot -Command 4: -Spidertron request -]] + elseif type == 's' then + c = target.clear_vehicle_logistic_slot + s = target.set_vehicle_logistic_slot -local function pl(player, amount) - local c = player.clear_personal_logistic_slot + elseif type == 'c' then + c = target.clear_personal_logistic_slot + s = target.set_personal_logistic_slot - for k, v in pairs(config.request) do + for k, v in pairs(config.request) do + c(config.start + v.key) + s(config.start + v.key, {name=k, min=0, max=0}) + end + + return + else + return + end + + for _, v in pairs(config.request) do c(config.start + v.key) end if (amount == 0) then return else - local stats = player.force.item_production_statistics - local s = player.set_personal_logistic_slot + local stats = target.force.item_production_statistics for k, v in pairs(config.request) do local v_min = math.ceil(v.min * amount) @@ -63,12 +73,33 @@ local function pl(player, amount) end end -Commands.new_command('personal-logistic', 'Set Personal Logistic (0 to cancel all)') +Commands.new_command('personal-logistic', 'Set Personal Logistic (0 to cancel all) (Select spidertron to edit spidertron)') :add_param('amount', 'integer-range', 0, 10) :add_alias('pl') :register(function(player, amount) if player.force.technologies['logistic-robotics'].researched then - pl(player, amount / 10) + if player.selected ~= nil then + if player.selected.name ~= nil then + if player.selected.name == 'spidertron' then + pl('s', player.selected, amount / 10) + return Commands.success + end + end + else + pl('p', player, amount / 10) + return Commands.success + end + else + player.print('Player logistic not researched') + end +end) + + +Commands.new_command('personal-logistic-empty', 'Set Personal Logistic to All 0') +:add_alias('ple') +:register(function(player, amount) + if player.force.technologies['logistic-robotics'].researched then + pl('c', player, 0) return Commands.success else player.print('Player logistic not researched') From 6d85a2bf6710882268f8d4e172464103d750e052 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Sat, 23 Sep 2023 21:24:58 +0900 Subject: [PATCH 2/5] role --- config/expcore/roles.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/config/expcore/roles.lua b/config/expcore/roles.lua index 2c320fc5..00f849f9 100644 --- a/config/expcore/roles.lua +++ b/config/expcore/roles.lua @@ -229,6 +229,7 @@ Roles.new_role('Member','Mem') 'command/save-quickbar', 'gui/vlayer-edit', 'command/personal-logistic', + 'command/personal-logistic-empty', 'command/auto-research', 'command/manual-train', 'command/lawnmower' From d170c9eee8946d327e1ed8dcd58e389dbb8618e7 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Sat, 23 Sep 2023 23:07:12 +0900 Subject: [PATCH 3/5] remove parameter of ple --- modules/data/personal-logistic.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/data/personal-logistic.lua b/modules/data/personal-logistic.lua index a1159e69..f3825109 100644 --- a/modules/data/personal-logistic.lua +++ b/modules/data/personal-logistic.lua @@ -97,7 +97,7 @@ end) Commands.new_command('personal-logistic-empty', 'Set Personal Logistic to All 0') :add_alias('ple') -:register(function(player, amount) +:register(function(player) if player.force.technologies['logistic-robotics'].researched then pl('c', player, 0) return Commands.success From 2e06198dcfe6497230e9f8c91e95b828d7b7daca Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Sat, 23 Sep 2023 23:07:35 +0900 Subject: [PATCH 4/5] . --- modules/data/personal-logistic.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/data/personal-logistic.lua b/modules/data/personal-logistic.lua index f3825109..e1b89711 100644 --- a/modules/data/personal-logistic.lua +++ b/modules/data/personal-logistic.lua @@ -94,7 +94,6 @@ Commands.new_command('personal-logistic', 'Set Personal Logistic (0 to cancel al end end) - Commands.new_command('personal-logistic-empty', 'Set Personal Logistic to All 0') :add_alias('ple') :register(function(player) From 75b3618be36de4a4bd334c6496e29c763ebb8aec Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Sun, 24 Sep 2023 02:46:50 +0900 Subject: [PATCH 5/5] fix --- config/expcore/roles.lua | 1 - modules/data/personal-logistic.lua | 29 +++-------------------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/config/expcore/roles.lua b/config/expcore/roles.lua index 00f849f9..2c320fc5 100644 --- a/config/expcore/roles.lua +++ b/config/expcore/roles.lua @@ -229,7 +229,6 @@ Roles.new_role('Member','Mem') 'command/save-quickbar', 'gui/vlayer-edit', 'command/personal-logistic', - 'command/personal-logistic-empty', 'command/auto-research', 'command/manual-train', 'command/lawnmower' diff --git a/modules/data/personal-logistic.lua b/modules/data/personal-logistic.lua index e1b89711..cfe95314 100644 --- a/modules/data/personal-logistic.lua +++ b/modules/data/personal-logistic.lua @@ -13,16 +13,6 @@ local function pl(type, target, amount) c = target.clear_vehicle_logistic_slot s = target.set_vehicle_logistic_slot - elseif type == 'c' then - c = target.clear_personal_logistic_slot - s = target.set_personal_logistic_slot - - for k, v in pairs(config.request) do - c(config.start + v.key) - s(config.start + v.key, {name=k, min=0, max=0}) - end - - return else return end @@ -79,11 +69,9 @@ Commands.new_command('personal-logistic', 'Set Personal Logistic (0 to cancel al :register(function(player, amount) if player.force.technologies['logistic-robotics'].researched then if player.selected ~= nil then - if player.selected.name ~= nil then - if player.selected.name == 'spidertron' then - pl('s', player.selected, amount / 10) - return Commands.success - end + if player.selected.name == 'spidertron' then + pl('s', player.selected, amount / 10) + return Commands.success end else pl('p', player, amount / 10) @@ -93,14 +81,3 @@ Commands.new_command('personal-logistic', 'Set Personal Logistic (0 to cancel al player.print('Player logistic not researched') end end) - -Commands.new_command('personal-logistic-empty', 'Set Personal Logistic to All 0') -:add_alias('ple') -:register(function(player) - if player.force.technologies['logistic-robotics'].researched then - pl('c', player, 0) - return Commands.success - else - player.print('Player logistic not researched') - end -end)