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

For general discussion about Conway's Game of Life.
Post Reply
allanwindmill
Posts: 3
Joined: March 13th, 2024, 12:07 pm

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

Post by allanwindmill » March 13th, 2024, 12:10 pm

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!

User avatar
azulavoir
Posts: 116
Joined: September 20th, 2023, 10:28 am

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

Post by azulavoir » March 13th, 2024, 3:11 pm

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.
Image

User avatar
Andrew
Moderator
Posts: 935
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

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

Post by Andrew » March 13th, 2024, 6:36 pm

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.")
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

allanwindmill
Posts: 3
Joined: March 13th, 2024, 12:07 pm

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

Post by allanwindmill » March 13th, 2024, 9:58 pm

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

Haycat2009
Posts: 783
Joined: April 26th, 2023, 5:47 am
Location: Bahar Junction, Zumaland

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

Post by Haycat2009 » March 15th, 2024, 11:11 pm

What about in lifeviewer?
~ Haycat Durnak, a hard-working editor
Also, support Conway and Friends story mode!
I mean no harm to those who have tested me. But do not take this for granted.

Post Reply