Skip to content

Commit

Permalink
fix pole entity not being placed if it's the last one in cargo
Browse files Browse the repository at this point in the history
don't floor a 0.x value
removed math.randomseed, has no effect in factorio
no more ipairs
  • Loading branch information
Choumiko committed May 26, 2016
1 parent ded1fd6 commit 192c0ab
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
7 changes: 3 additions & 4 deletions FARL.lua
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,8 @@ FARL = {
local rounded_probability = 1
local rounded_random = 1
if v.probability < 1 then --determine whether or not we are adding this item to inventory based on it's drop probability
math.randomseed( game.tick + random( 1, 100 ) )
rounded_probability = floor( round( v.probability, 2 ) )
rounded_random = floor( round( random(), 2 ) )
rounded_random = round( random(), 2 )
end
if rounded_probability >= rounded_random then
amount = floor( random( v.amount_min, v.amount_max ) )
Expand Down Expand Up @@ -1623,7 +1622,7 @@ FARL = {
end
if mainRail then
local lamps = {}
for _, l in ipairs(offsets.poleEntities) do
for _, l in pairs(offsets.poleEntities) do
if l.name ~= "wooden-chest" then
table.insert(lamps, {name=l.name, position=subPos(l.position, offsets.pole.position), direction = l.direction})
end
Expand Down Expand Up @@ -2149,7 +2148,7 @@ FARL = {
local rad = diff * (math.pi/4)
if type(poleEntities) == "table" then
for i=1,#poleEntities do
if self:getCargoCount(poleEntities[i].name) > 1 then
if self:getCargoCount(poleEntities[i].name) > 0 then
local offset = poleEntities[i].position
offset = rotate(offset, rad)
if self.settings.flipPoles then
Expand Down
4 changes: 2 additions & 2 deletions GUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ GUI = {
local blueprints = GUI.findBlueprintsInHotbar(player)
if blueprints ~= nil then
local ret = {}
for i, blueprint in ipairs(blueprints) do
for i, blueprint in pairs(blueprints) do
if blueprint.is_blueprint_setup() then
table.insert(ret, blueprint)
end
Expand Down Expand Up @@ -423,7 +423,7 @@ GUI = {
local blueprints = GUI.findBlueprintsInHotbar(player)
local bp = false
if blueprints ~= nil then
for i, blueprint in ipairs(blueprints) do
for i, blueprint in pairs(blueprints) do
if not blueprint.is_blueprint_setup() then
bp = blueprint
break
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PACKAGE_NAME := FARL
VERSION_STRING := 0.5.25
VERSION_STRING := 0.5.26

OUTPUT_NAME := $(PACKAGE_NAME)_$(VERSION_STRING)
OUTPUT_DIR := build/$(OUTPUT_NAME)
Expand Down
6 changes: 3 additions & 3 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ end

function debugDump(var, force)
if false or force then
for i,player in ipairs(game.players) do
for i,player in pairs(game.players) do
local msg
if type(var) == "string" then
msg = var
Expand All @@ -337,7 +337,7 @@ end
function debugLog(var, prepend)
if not global.debug_log then return end
local str = prepend or ""
for i,player in ipairs(game.players) do
for i,player in pairs(game.players) do
local msg
if type(var) == "string" then
msg = var
Expand Down Expand Up @@ -421,7 +421,7 @@ remote.add_interface("farl",
if game.forces.player.technologies["rail-signals"].researched then
game.forces.player.recipes["farl"].enabled = true
end
for i,p in ipairs(game.players) do
for i,p in pairs(game.players) do
if p.gui.left.farl then p.gui.left.farl.destroy() end
if p.gui.top.farl then p.gui.top.farl.destroy() end
end
Expand Down

0 comments on commit 192c0ab

Please sign in to comment.