Skip to content

Commit

Permalink
Update for belt physics changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Peppe-KSP committed Jul 8, 2016
1 parent 4bd538c commit ef7eb25
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
35 changes: 31 additions & 4 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ local SOUTH = defines.direction.south
local WEST = defines.direction.west

-- Optimal places on a belt to place item
local beltPositions = {.159, .44, .72, 1}
--local beltPositions = {0, .28, .56, .841}
--local beltPositions = {.56, .841}
local beltPositions = {0, .182, .463, .744}
local splitterPositions = {0, .28}

-- Adjacent tiles
Expand Down Expand Up @@ -506,20 +504,49 @@ function chestToBelt(belt, laneNumber, chest, power)
positions = splitterPositions
end
if belt.get_transport_line(laneNumber).can_insert_at(positions[1]) then




local inventory = chest.get_output_inventory()
local contents = inventory.get_contents()
local item = next(contents)
local size = contents[item]
local itemstack = {name=item, count=1}



if size then

--[[
--Find Positions 0 to 1
for i=0, 1000 do
if belt.get_transport_line(laneNumber).insert_at(i/1000, itemstack) then
debugPrint("Inserted: " .. i/1000 .. " tick: " .. game.tick)
power.energy = power.energy - energy_per_action
inventory.remove({name=item, count=1})
end
end
--Find Positions 1 to 0
for i=1, 1000 do
if belt.get_transport_line(laneNumber).insert_at((1001-i)/1000, itemstack) then
debugPrint("Inserted: " .. (1001-i)/1000 .. " tick: " .. game.tick)
power.energy = power.energy - energy_per_action
inventory.remove({name=item, count=1})
end
end
]]--

local toTransfer = math.min(#positions, size)
for i=1, toTransfer do
if belt.get_transport_line(laneNumber).insert_at(positions[i], itemstack) then
--debugPrint("Inserted: " .. positions[i] .. " tick: " .. game.tick)
power.energy = power.energy - energy_per_action
inventory.remove({name=item, count=1})
end
end
inventory.remove({name=item, count=toTransfer})

end
end
end
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "InterfaceChest",
"version": "1.13.1",
"version": "1.13.2",
"factorio_version": "0.13",
"dependencies": ["base >= 0.13"],
"title": "Interface Chest",
Expand Down

0 comments on commit ef7eb25

Please sign in to comment.