mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 03:25:23 +09:00
Personal Logistic (#287)
* Update personal-logistic.lua * Update personal-logistic.lua
This commit is contained in:
@@ -21,50 +21,58 @@ local function pl(type, target, amount)
|
|||||||
c(config.start + v.key)
|
c(config.start + v.key)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (amount == 0) then
|
if (amount < 0) then
|
||||||
return
|
return
|
||||||
else
|
end
|
||||||
local stats = target.force.item_production_statistics
|
|
||||||
|
|
||||||
for k, v in pairs(config.request) do
|
local stats = target.force.item_production_statistics
|
||||||
local v_min = math.ceil(v.min * amount)
|
|
||||||
local v_max = math.ceil(v.max * amount)
|
|
||||||
|
|
||||||
if v.stack ~= nil and v.stack ~= 1 and v.type ~= 'weapon' then
|
for k, v in pairs(config.request) do
|
||||||
v_min = math.floor(v_min / v.stack) * v.stack
|
local v_min = math.ceil(v.min * amount)
|
||||||
v_max = math.ceil(v_max / v.stack) * v.stack
|
local v_max = math.ceil(v.max * amount)
|
||||||
end
|
|
||||||
|
|
||||||
if v.upgrade_of == nil then
|
if v.stack ~= nil and v.stack ~= 1 and v.type ~= 'weapon' then
|
||||||
if v.type ~= nil then
|
v_min = math.floor(v_min / v.stack) * v.stack
|
||||||
if stats.get_input_count(k) < config.production_required[v.type] then
|
v_max = math.ceil(v_max / v.stack) * v.stack
|
||||||
|
end
|
||||||
|
|
||||||
|
if v.upgrade_of == nil then
|
||||||
|
if v.type ~= nil then
|
||||||
|
if stats.get_input_count(k) < config.production_required[v.type] then
|
||||||
|
if v_min > 0 then
|
||||||
|
if v_min == v_max then
|
||||||
|
v_min = math.floor((v_max * 0.5) / v.stack) * v.stack
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
v_min = 0
|
v_min = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
s(config.start + v.key, {name=k, min=v_min, max=v_max})
|
s(config.start + v.key, {name=k, min=v_min, max=v_max})
|
||||||
|
|
||||||
else
|
else
|
||||||
if v.type ~= nil then
|
if v.type ~= nil then
|
||||||
if stats.get_input_count(k) >= config.production_required[v.type] then
|
if stats.get_input_count(k) >= config.production_required[v.type] then
|
||||||
s(config.start + v.key, {name=k, min=v_min, max=v_max})
|
s(config.start + v.key, {name=k, min=v_min, max=v_max})
|
||||||
local vuo = v.upgrade_of
|
local vuo = v.upgrade_of
|
||||||
|
|
||||||
while (vuo ~= nil) do
|
while (vuo ~= nil) do
|
||||||
s(config.start + config.request[vuo].key, {name=vuo, min=0, max=0})
|
s(config.start + config.request[vuo].key, {name=vuo, min=0, max=0})
|
||||||
vuo = config.request[vuo].upgrade_of
|
vuo = config.request[vuo].upgrade_of
|
||||||
end
|
|
||||||
else
|
|
||||||
s(config.start + v.key, {name=k, min=0, max=v_max})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
s(config.start + v.key, {name=k, min=0, max=v_max})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Commands.new_command('personal-logistic', 'Set Personal Logistic (0 to cancel all) (Select spidertron to edit spidertron)')
|
Commands.new_command('personal-logistic', 'Set Personal Logistic (-1 to cancel all) (Select spidertron to edit spidertron)')
|
||||||
:add_param('amount', 'integer-range', 0, 10)
|
:add_param('amount', 'integer-range', -1, 10)
|
||||||
:add_alias('pl')
|
:add_alias('pl')
|
||||||
:register(function(player, amount)
|
:register(function(player, amount)
|
||||||
if player.force.technologies['logistic-robotics'].researched then
|
if player.force.technologies['logistic-robotics'].researched then
|
||||||
@@ -73,11 +81,13 @@ Commands.new_command('personal-logistic', 'Set Personal Logistic (0 to cancel al
|
|||||||
pl('s', player.selected, amount / 10)
|
pl('s', player.selected, amount / 10)
|
||||||
return Commands.success
|
return Commands.success
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
pl('p', player, amount / 10)
|
pl('p', player, amount / 10)
|
||||||
return Commands.success
|
return Commands.success
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
player.print('Player logistic not researched')
|
player.print('Personal Logistic not researched')
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user