New version after 9 days
Lua Carousel » Devlog
The good news is the last version lasted 9 days. The bad news is carousel-az-safe.love was catastrophically broken for all 9 of those days. So much for "safe" :( I'm going to try harder to use both versions that I put out.
Other updates in this version:
- We do a little better about saving settings across restart. Saving settings is still unreliable on mobile platforms. In particular, Carousel will unfortunately forget your list of open screens every time you update to a new version. Please report if it forgets your open screens any other time. The _contents_ of screens that have been saved to file should never, ever be lost.
- Bug: scripts changing the font would mess up the UI. Carousel should now isolate font changes in your scripts from its UI.
- Bug: Errors were being prepended to the output buffer. Now they're appended.
- 2 new abbreviations in the abbreviation screen for math.floor and math.ceil.
As recompense for this issue, a humble program for your consideration, where populations of cell duke it out in an epic battle on the infinite (toroidal) surface of the Game of Life:
math.randomseed(os.time()) N = 6 W, H = ceil(Safe_width/N), ceil(Safe_height/N) running = false curr_color = {rand(), rand(), rand()} curr, new = {}, {} for x=1,W do table.insert(curr, {}) table.insert(new, {}) for y=1,H do table.insert(curr[x], {v=0, c={0,0,0}}) table.insert(new[x], {v=0, c={0,0,0}}) end end function car.draw() for x=1,W do for y=1,H do if curr[x][y].v > 0 then color(unpack(curr[x][y].c)) rect('fill', x*N, y*N, N-1,N-1) end end end if not running then local w = App.width('run') color(0,0,1,0.4) rect('fill', 60, 35, w+10,Line_height+10) color(0,0,0) rect('line', 60, 35, w+10,Line_height+10) g.print('run', 65, 40) color(unpack(curr_color)) rect('fill', Safe_width-100, 35, 60,Line_height+10) color(0,0,0) rect('line', Safe_width-100, 35, 60, Line_height+10) end end function car.mousepressed(x,y) if running then return end if y > 30 and y < 35+Line_height+10 then if x < 200 then running = true elseif x > Safe_width-100 then curr_color = {rand(), rand(), rand()} end end end function car.update(dt) if running then step() elseif not Show_code and App.mouse_down(1) then local x,y = love.mouse.getPosition() set(floor((x-1)/N)%W+1, floor((y-1)/N)%H+1) end end function set(x,y) curr[x][y].v = 1 local s, d = curr_color, curr[x][y].c d[1], d[2], d[3] = s[1], s[2], s[3] end function step() for x=1,W do for y=1,H do local n = nghs(x,y) if n < 2 or n > 3 then new[x][y].v = 0 elseif n == 2 or n == 3 and curr[x][y].v > 0 then cpy(x,y) else -- n=3, birth new[x][y].v = 1 -- copy some random live neighbor's color over local oldc = random_color(x,y) local c = new[x][y].c c[1], c[2], c[3] = oldc[1], oldc[2], oldc[3] end end end curr, new = new, curr end function nghs(x,y) return v(x-1,y-1) + v(x,y-1) + v(x+1,y-1) + v(x-1,y) + v(x+1,y) + v(x-1,y+1) + v(x,y+1) + v(x+1,y+1) end function v(x,y) return curr[(x-1)%W+1][(y-1)%H+1].v end function cpy(x,y) new[x][y].v = curr[x][y].v local c, oldc = new[x][y].c, curr[x][y].c c[1], c[2], c[3] = oldc[1], oldc[2], oldc[3] end function random_color(x,y) local rgbs = {} maybe_append_color(x-1, y-1, rgbs) maybe_append_color(x-1, y, rgbs) maybe_append_color(x-1, y+1, rgbs) maybe_append_color(x, y-1, rgbs) maybe_append_color(x, y+1, rgbs) maybe_append_color(x+1, y-1, rgbs) maybe_append_color(x+1, y, rgbs) maybe_append_color(x+1, y+1, rgbs) return rgbs[rand(#rgbs)] end function maybe_append_color(x,y, out) x,y = (x-1)%W+1, (y-1)%H+1 if curr[x][y].v > 0 then table.insert(out, curr[x][y].c) end end
If you try pasting this program into Lua Carousel, remember to first run the abbreviations on one of the example screens. Or if you've deleted that screen, here are the abbreviations this program uses:
g = love.graphics rect = g.rectangle color = g.setColor rand = math.random floor, ceil = math.floor, math.ceil
Files
carousel-ba.love 109 kB
Dec 16, 2023
carousel-ba-safe.love 109 kB
Dec 16, 2023
Get Lua Carousel
Lua Carousel
Write programs on desktop and mobile
Status | In development |
Category | Tool |
Author | Kartik Agaram |
Tags | LÖVE |
More posts
- New version after 3 days16 days ago
- New version after 40 days19 days ago
- Turn your phone or tablet into a chess clock33 days ago
- Guest program: bouncing balls49 days ago
- New version after 3 months, and turtle graphics60 days ago
- Interactively zooming in to the Mandelbrot set on a touchscreen79 days ago
- A little timer app80 days ago
- New version after 4 monthsJun 28, 2024
- Visualizing the digits of πMay 04, 2024
- A little recursion problemApr 15, 2024
Leave a comment
Log in with itch.io to leave a comment.