The purpose of this forum thread is to collect (links to) Golly scripts written in Lua, and for ontopic discussion about such scripts.
search.php?keywords=lua+port
search.php?keywords=lua+porting
viewtopic.php?f=9&t=6418 safeopenclip.lua
viewtopic.php?f=9&t=3404 3D.lua
Other threads
For non-Lua scripts, post instead in one of the following threads:
viewtopic.php?f=9&t=3915 Thread for your script-related questions
viewtopic.php?f=9&t=2032 Script request thread
viewtopic.php?f=9&t=45 Golly scripts
---
Assuming I understand how the pattern is formatted and what are restrictions in this case, below is a Golly script (Lua) to convert any of those neighbourhoods into a Golly-supported weighted neighbourhood ("NW") definition. This may be useful for those people who are interested in actually finding some reactions/patterns in cellular automata defined using some of these neighbourhoods (rather than inventing notations).R2INT wrote: March 26th, 2025, 1:45 pm [...] Here is an updated list of additional neighborhoods:Here, I am actually 'forgetting' an infinite number of neighborhoods. These neighborhoods can be arbitrarily defined by manipulating the position of the knight neighbors and the position of the edge and corner neighbors. Obviously, I cannot include infinitely many patterns in this post, so I chose the simplest and smallest neighborhoods.Code: Select all
#C White represents the center cell in the neighborhood, while #C Cyan represents the corner cells and blue represents the knight cells. # [[ COLOR ALIVE 255 255 255 COLOR DYING 0 255 255 COLOR DYINGRAMP 0 0 255 ]] x = 72, y = 38, rule = 012345678//4 26.C.C10.C.C9.C3.C9.C3.C$3.C.C9.C.C32.C5.C7.C5.C$2.CB.BC7.C.B.C5.C.B. B.C6.C2.B2.C8.B.B12.B$4.A10.BAB9.A11.BAB11.A12.BAB$2.CB.BC7.C.B.C5.C. B.B.C6.C2.B2.C8.B.B12.B$3.C.C9.C.C32.C5.C7.C5.C$26.C.C10.C.C9.C3.C9.C 3.C3$26.C.C10.C.C9.C3.C9.C3.C$2.BC.CB8.CBC7.B3.B10.B9.CB3.BC7.C2.B2.C $2.C3.C7.C3.C5.C5.C6.C5.C$4.A9.B.A.B8.A10.B.A.B10.A11.B.A.B$2.C3.C7.C 3.C5.C5.C6.C5.C$2.BC.CB8.CBC7.B3.B10.B9.CB3.BC7.C2.B2.C$26.C.C10.C.C9. C3.C9.C3.C4$.B5.B8.B7.B.C.C.B8.CBC8.BC3.CB8.C.B.C$3.C.C9.C.C32.C5.C7. C5.C$2.C3.C7.C3.C5.C5.C6.C5.C$4.A8.B2.A2.B7.A9.B2.A2.B9.A10.B2.A2.B$2. C3.C7.C3.C5.C5.C6.C5.C$3.C.C9.C.C32.C5.C7.C5.C$.B5.B8.B7.B.C.C.B8.CBC 8.BC3.CB8.C.B.C4$B7.B7.B6.B7.B8.B8.B7.B9.B$26.C.C10.C.C9.C3.C9.C3.C$3. C.C9.C.C32.C5.C7.C5.C$2.C3.C7.C3.C5.C5.C6.C5.C$4.A7.B3.A3.B6.A8.B3.A3. B8.A9.B3.A3.B$2.C3.C7.C3.C5.C5.C6.C5.C$3.C.C9.C.C32.C5.C7.C5.C$26.C.C 10.C.C9.C3.C9.C3.C$B7.B7.B6.B7.B8.B8.B7.B9.B!
[...]
To use the script, open the above pattern in Golly, select one of neighbourhoods (and nothing else), and run the script.
Code: Select all
local g = golly()
local r = g.getselrect()
if r and (#r == 4) and (r[3] == r[4]) and (r[3] % 2 == 1) then
local n = r[3] // 2
local x = r[1] + n
local y = r[2] + n
local w = ''
for dy = -n, n do
for dx = -n, n do
local c = g.getcell(x + dx, y + dy)
if c == 2 then
w = w .. '1'
elseif c == 3 then
w = w .. '5'
else
w = w .. '0'
end
end
end
local s = string.format('R%q,C0,S,B1,5,NW%s', n, w)
g.setrule(s)
else
g.show('Please select the neighbourhood (an odd-by-odd square) and nothing else.')
end