Skip to content

Commit

Permalink
Merge pull request #1 from narc0tiq/factorio-0.12.11
Browse files Browse the repository at this point in the history
Factorio 0.12.11+ update.
  • Loading branch information
Will Thomas committed Jan 29, 2016
2 parents 340b75e + aca8fb2 commit 20c8cd6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 36 deletions.
71 changes: 38 additions & 33 deletions control.lua
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
require("defines")

local function flip_v(player_index)
local cursor= game.players[player_index].cursor_stack
if cursor.valid_for_read and cursor.name=="blueprint" and cursor.is_blueprint_setup() then
local ents=cursor.get_blueprint_entities()
for i=1,#ents do
local dir=ents[i].direction or 0
if ents[i].name=="curved-rail" then
ents[i].direction=(13-dir)%8
else
ents[i].direction=(12-dir)%8
end
ents[i].position.y=-ents[i].position.y
end
cursor.set_blueprint_entities(ents)
end
local cursor= game.players[player_index].cursor_stack
if cursor.valid_for_read and cursor.name=="blueprint" and cursor.is_blueprint_setup() then
local ents=cursor.get_blueprint_entities()
for i=1,#ents do
local dir=ents[i].direction or 0
if ents[i].name=="curved-rail" then
ents[i].direction=(13-dir)%8
else
ents[i].direction=(12-dir)%8
end
ents[i].position.y=-ents[i].position.y
end
cursor.set_blueprint_entities(ents)
end
end

local function flip_h(player_index)
local cursor= game.players[player_index].cursor_stack
if cursor.valid_for_read and cursor.name=="blueprint" and cursor.is_blueprint_setup() then
local ents=cursor.get_blueprint_entities()
for i=1,#ents do
local dir=ents[i].direction or 0
if ents[i].name=="curved-rail" then
ents[i].direction=(9-dir)%8
else
ents[i].direction=(16-dir)%8
end
ents[i].position.x=-ents[i].position.x
end
cursor.set_blueprint_entities(ents)
end
local cursor= game.players[player_index].cursor_stack
if cursor.valid_for_read and cursor.name=="blueprint" and cursor.is_blueprint_setup() then
local ents=cursor.get_blueprint_entities()
for i=1,#ents do
local dir=ents[i].direction or 0
if ents[i].name=="curved-rail" then
ents[i].direction=(9-dir)%8
else
ents[i].direction=(16-dir)%8
end
ents[i].position.x=-ents[i].position.x
end
cursor.set_blueprint_entities(ents)
end
end

local function doButtons(player_index)
Expand All @@ -42,10 +42,15 @@ local function doButtons(player_index)
end
end

game.on_load(function() for i=1,#game.players do doButtons(i) end end)
game.on_event(defines.events.on_gui_click,function(event) if event.element.name=="blueprint_flip" then flip_h(event.player_index) elseif event.element.name=="blueprint_flop" then flip_v(event.player_index) end end)
script.on_event(defines.events.on_gui_click,function(event)
if event.element.name=="blueprint_flip" then
flip_h(event.player_index)
elseif event.element.name=="blueprint_flop" then
flip_v(event.player_index)
end
end)

game.on_event(defines.events.on_player_created,function(event) doButtons(event.player_index) end)
script.on_event(defines.events.on_player_created,function(event) doButtons(event.player_index) end)

game.on_load(function() for i=1,#game.players do doButtons(i) end end)
game.on_init(function() for i=1,#game.players do doButtons(i) end end)
script.on_configuration_changed(function(data) for i=1,#game.players do doButtons(i) end end)
script.on_init(function() for i=1,#game.players do doButtons(i) end end)
6 changes: 3 additions & 3 deletions info.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "blueprint_flipper",
"version": "0.1.0",
"version": "0.1.1",
"title": "Blueprint Flipper",
"author": "GopherAtl",
"homepage": "",
"contact": "[email protected]",
"description": "adds buttons for mirroring a held blueprint",
"dependencies": ["base >= 0.12.0"]
}
"dependencies": ["base >= 0.12.11"]
}

0 comments on commit 20c8cd6

Please sign in to comment.