Page 1 of 1

How to Copy Cells in "..OO" Pattern Format?

Posted: March 13th, 2024, 12:10 pm
by allanwindmill
Hi all! I have a question regarding Golly.

I know you can Ctrl+C to copy as RLE, but is there a way to copy cells directly as the formats shown in Life Lexicon?

E.g.

Code: Select all

....OO......OO....
...O.O......O.O...
...O..........O...
OO.O..........O.OO
OO.O.O..OO..O.O.OO
...O.O.O..O.O.O...
...O.O.O..O.O.O...
OO.O.O..OO..O.O.OO
OO.O..........O.OO
...O..........O...
...O.O......O.O...
....OO......OO....
I tried to search it online but I don't even know what's the name for this format, and all the information I can find is about RLE or other Golly specific formats.

Thanks!

Re: How to Copy Cells in "..OO" Pattern Format?

Posted: March 13th, 2024, 3:11 pm
by azulavoir
I don't currently think there's a way to copy patterns in plaintext, but if someone does know one, feel free to correct me.

Re: How to Copy Cells in "..OO" Pattern Format?

Posted: March 13th, 2024, 6:36 pm
by Andrew
allanwindmill wrote: March 13th, 2024, 12:10 pm I know you can Ctrl+C to copy as RLE, but is there a way to copy cells directly as the formats shown in Life Lexicon?
Save the following as copy-plaintext.lua then use Preferences > Keyboard to assign a key combination like Alt+C to run that script (use the "Choose File" button to select the script).

Code: Select all

-- Copy the current selection as plaintext.
-- Author: Andrew Trevorrow (andrew@trevorrow.com), Mar 2024.
local g = golly()
local gp = require "gplus"
local r = gp.rect(g.getselrect())
if r.empty then g.exit("There is no selection.") end
if g.numstates() > 2 then g.exit("Plaintext is only for two-state rules.") end
local text = ""
for row = r.top, r.bottom do
    for col = r.left, r.right do
        if g.getcell(col, row) > 0 then
            text = text.."O"
        else
            text = text.."."
        end
    end
    text = text.."\n"
end
g.setclipstr(text)
g.show("Clipboard contains plaintext version of selection.")

Re: How to Copy Cells in "..OO" Pattern Format?

Posted: March 13th, 2024, 9:58 pm
by allanwindmill
Thanks for both replies! Good to know Golly doesn't have this out of the box and it's not that I am missing something; And @Andrew your lua script is magic! Works very well!

Thanks! :D

Re: How to Copy Cells in "..OO" Pattern Format?

Posted: March 15th, 2024, 11:11 pm
by Haycat2009
What about in lifeviewer?