Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleretters committed Oct 31, 2020
1 parent 3b0fe51 commit dd735cc
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion arcologies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-- k2: play k3: delete
--
--
-- v1.2.4
-- v1.2.5

include("arcologies/lib/includes")

Expand Down
10 changes: 5 additions & 5 deletions lib/_arc.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_arc = {}
_arc.device = arc.connect()
a = arc.connect()

function _arc.init()
_arc.orientation = 0
Expand Down Expand Up @@ -34,7 +34,7 @@ function _arc.arc_redraw_clock()
if fn.dirty_arc() then
_arc:refresh_values()
_arc:arc_redraw()
_arc.device:refresh()
a:refresh()
-- fn.dirty_arc(false) -- disabled for the sparkly animations
_arc:increment_frames()
end
Expand Down Expand Up @@ -222,7 +222,7 @@ function _arc:draw_segment(n, segment, level)
if segment.valid then
local adjusted_from = self:get_orientation_adjusted_radian(segment.from)
local adjusted_to = self:get_orientation_adjusted_radian(segment.to)
self.device:segment(n, adjusted_from, adjusted_to, 15)
a:segment(n, adjusted_from, adjusted_to, 15)
end
end

Expand All @@ -231,7 +231,7 @@ function _arc:get_orientation_adjusted_radian(value)
end

function _arc:draw_led(n, led, level)
self.device:led(n, self:get_orientation_adjusted_led(led), level)
a:led(n, self:get_orientation_adjusted_led(led), level)
end

function _arc:get_orientation_adjusted_led(value)
Expand All @@ -245,7 +245,7 @@ end


function _arc:clear_ring(n)
for i = 1, 64 do _arc.device:led(n, i, 0) end
for i = 1, 64 do a:led(n, i, 0) end
end


Expand Down
46 changes: 23 additions & 23 deletions lib/_grid.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_grid = {}
_grid.device = grid.connect()
g = grid.connect()

function _grid.init()
_grid.counter = {}
Expand All @@ -15,8 +15,8 @@ function _grid.init()
_grid.is_pasting = false
_grid.paste_counter = 15
_grid.disconnect_dismissed = true
_grid.last_known_width = _grid.device.cols
_grid.last_known_height = _grid.device.rows
_grid.last_known_width = g.cols
_grid.last_known_height = g.rows
for x = 1, _grid.last_known_width do
_grid.counter[x] = {}
for y = 1, _grid.last_known_height do
Expand All @@ -25,9 +25,9 @@ function _grid.init()
end
end

-- grid redefined, _grid ~= grid
-- little g

function grid.key(x, y, z)
function g.key(x, y, z)
fn.break_splash(true)
if z == 1 then
_grid.counter[x][y] = clock.run(_grid.grid_long_press, g, x, y)
Expand All @@ -47,11 +47,11 @@ function grid.key(x, y, z)
end
end

function grid.remove()
function g.remove()
_grid:alert_disconnect()
end

-- _grid proper
-- big _grid

function _grid:alert_disconnect()
self.disconnect_dismissed = false
Expand All @@ -78,7 +78,7 @@ function _grid.grid_redraw_clock()
end

function _grid:grid_redraw()
self.device:all(0)
g:all(0)
self:led_leylines()
self:led_territories()
self:led_cells()
Expand All @@ -90,7 +90,7 @@ function _grid:grid_redraw()
self:led_cell_ports()
self:led_cell_analysis()
self:led_paste_animation()
self.device:refresh()
g:refresh()
end

function _grid:short_press(x, y)
Expand Down Expand Up @@ -158,7 +158,7 @@ function _grid:led_signals()
local level = page.active_page == 3 and menu.selected_item == 1 and 10 or 2
for k,v in pairs(keeper.signals) do
if v.generation <= counters.music_generation then
self.device:led(v.x, v.y, level)
g:led(v.x, v.y, level)
end
end
end
Expand All @@ -177,7 +177,7 @@ function _grid:led_signal_deaths()
if v.level == 0 or v.generation + 2 < counters.music_generation then
table.remove(self.signal_deaths, k)
else
self.device:led(v.x, v.y, v.level)
g:led(v.x, v.y, v.level)
v.level = v.level - 1
end
end
Expand All @@ -197,7 +197,7 @@ function _grid:led_flickers()
if v.level == 0 or v.generation + 2 < counters.music_generation then
table.remove(self.flickers, k)
else
self.device:led(v.x, v.y, v.level)
g:led(v.x, v.y, v.level)
v.level = v.level - 1
end
end
Expand All @@ -217,15 +217,15 @@ function _grid:led_signal_and_cell_collision()
if v.level == 0 or v.generation + 2 < counters.music_generation then
table.remove(self.signal_and_cell_collisions, k)
else
self.device:led(v.x, v.y, v.level)
g:led(v.x, v.y, v.level)
v.level = v.level - 1
end
end
end

function _grid:led_cells()
for k,v in pairs(keeper.cells) do
self.device:led(v.x, v.y, 5)
g:led(v.x, v.y, 5)
end
end

Expand All @@ -247,7 +247,7 @@ function _grid:led_selected_cell()
end

function _grid:highlight_cell(cell)
self.device:led(cell.x, cell.y, util.clamp(counters.grid_frame() % 15, 5, 15))
g:led(cell.x, cell.y, util.clamp(counters.grid_frame() % 15, 5, 15))
end

function _grid:led_paste_animation()
Expand All @@ -258,7 +258,7 @@ function _grid:led_paste_animation()
self.paste_y = nil
end
if self.is_pasting then
self.device:led(self.paste_x, self.paste_y, self.paste_counter)
g:led(self.paste_x, self.paste_y, self.paste_counter)
self.paste_counter = self.paste_counter - 1
end
end
Expand All @@ -270,16 +270,16 @@ function _grid:led_cell_ports()
local high = util.clamp(counters.grid_frame() % 15, 10, 15)
local low = 2
if fn.in_bounds(x, y - 1) then
self.device:led(x, y - 1, keeper.selected_cell:is_port_open("n") and high or low)
g:led(x, y - 1, keeper.selected_cell:is_port_open("n") and high or low)
end
if fn.in_bounds(x + 1, y) then
self.device:led(x + 1, y, keeper.selected_cell:is_port_open("e") and high or low)
g:led(x + 1, y, keeper.selected_cell:is_port_open("e") and high or low)
end
if fn.in_bounds(x, y + 1) then
self.device:led(x, y + 1, keeper.selected_cell:is_port_open("s") and high or low)
g:led(x, y + 1, keeper.selected_cell:is_port_open("s") and high or low)
end
if fn.in_bounds(x - 1 , y) then
self.device:led(x - 1, y, keeper.selected_cell:is_port_open("w") and high or low)
g:led(x - 1, y, keeper.selected_cell:is_port_open("w") and high or low)
end
end

Expand Down Expand Up @@ -368,11 +368,11 @@ end
function _grid:draw_leyline(start_x, start_y, end_x, end_y)
if start_x == end_x then -- vertical
for i = math.min(start_y, end_y), math.max(start_y, end_y) do
if fn.in_bounds(start_x, i) then self.device:led(start_x, i, 1) end
if fn.in_bounds(start_x, i) then g:led(start_x, i, 1) end
end
elseif start_y == end_y then -- horizontal
for i = math.min(start_x, end_x), math.max(start_x, end_x) do
if fn.in_bounds(i, start_y) then self.device:led(i, start_y, 1) end
if fn.in_bounds(i, start_y) then g:led(i, start_y, 1) end
end
else
print("Error: leylines must be perpendicular.")
Expand All @@ -386,7 +386,7 @@ function _grid:led_territories()
for x = c.x1, c.x2 do
for y = c.y1, c.y2 do
local l = math.ceil(util.linlin(0, 15, 0, 3, counters.grid_frame() % 15))
if fn.in_bounds(x, y) then self.device:led(x, y, l) end
if fn.in_bounds(x, y) then g:led(x, y, l) end
end
end
fn.dirty_grid(true)
Expand Down
2 changes: 1 addition & 1 deletion lib/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ config = {}
config["settings"] = {
["version_major"] = 1,
["version_minor"] = 2,
["version_patch"] = 4,
["version_patch"] = 5,
["playback"] = 0,
["length"] = 16,
["root"] = 0,
Expand Down
1 change: 1 addition & 0 deletions lib/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ end
function fn.cleanup()
crow.ii.jf.mode(0)
_midi:all_off()
g.cleanup()
clock.cancel(music_clock_id)
clock.cancel(redraw_clock_id)
clock.cancel(grid_clock_id)
Expand Down
1 change: 1 addition & 0 deletions lib/saveload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function saveload:load_cells(data)
-- cells from older arcologies don't have newer attributes, so:
tmp[v] = load_cell[v] or tmp[v]
end
tmp:change_checks()
tmp:set_available_ports()
tmp:set_er()
table.insert(keeper.cells, tmp)
Expand Down

0 comments on commit dd735cc

Please sign in to comment.