From dd735cc4f02f3b3246c687b38c8ca1e9a6ba7192 Mon Sep 17 00:00:00 2001 From: Tyler Etters Date: Sat, 31 Oct 2020 06:47:01 -0500 Subject: [PATCH] bug fixes --- arcologies.lua | 2 +- lib/_arc.lua | 10 +++++----- lib/_grid.lua | 46 +++++++++++++++++++++++----------------------- lib/config.lua | 2 +- lib/functions.lua | 1 + lib/saveload.lua | 1 + 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/arcologies.lua b/arcologies.lua index 69d3712..e133a5b 100644 --- a/arcologies.lua +++ b/arcologies.lua @@ -6,7 +6,7 @@ -- k2: play k3: delete -- -- --- v1.2.4 +-- v1.2.5 include("arcologies/lib/includes") diff --git a/lib/_arc.lua b/lib/_arc.lua index 41332cc..6b08fa0 100644 --- a/lib/_arc.lua +++ b/lib/_arc.lua @@ -1,5 +1,5 @@ _arc = {} -_arc.device = arc.connect() +a = arc.connect() function _arc.init() _arc.orientation = 0 @@ -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 @@ -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 @@ -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) @@ -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 diff --git a/lib/_grid.lua b/lib/_grid.lua index 5224dd3..40fb092 100644 --- a/lib/_grid.lua +++ b/lib/_grid.lua @@ -1,5 +1,5 @@ _grid = {} -_grid.device = grid.connect() +g = grid.connect() function _grid.init() _grid.counter = {} @@ -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 @@ -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) @@ -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 @@ -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() @@ -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) @@ -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 @@ -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 @@ -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 @@ -217,7 +217,7 @@ 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 @@ -225,7 +225,7 @@ 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 @@ -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() @@ -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 @@ -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 @@ -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.") @@ -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) diff --git a/lib/config.lua b/lib/config.lua index 8ec8551..6acbb8c 100644 --- a/lib/config.lua +++ b/lib/config.lua @@ -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, diff --git a/lib/functions.lua b/lib/functions.lua index 2c7df03..9b001ea 100644 --- a/lib/functions.lua +++ b/lib/functions.lua @@ -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) diff --git a/lib/saveload.lua b/lib/saveload.lua index 8d7a819..94f4554 100644 --- a/lib/saveload.lua +++ b/lib/saveload.lua @@ -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)