Getting RLE in Golly

For general discussion about Conway's Game of Life.
Post Reply
User avatar
Nathaniel
Site Admin
Posts: 862
Joined: December 10th, 2008, 3:48 pm
Location: New Brunswick, Canada
Contact:

Getting RLE in Golly

Post by Nathaniel » June 21st, 2009, 1:47 pm

I'm probably just being dense here or somehow completely missing a command in the documentation, but I want to be able to manipulate a pattern's RLE string in a Golly Python script, and I can't seem to find a way to retrieve the current pattern's RLE string in any less of a roundabout way than calling golly.store() to save the RLE string as a file on the harddrive, and then having Python read in the RLE string from that file. Thoughts?

User avatar
calcyman
Moderator
Posts: 2938
Joined: June 1st, 2009, 4:32 pm

Re: Getting RLE in Golly

Post by calcyman » June 21st, 2009, 2:21 pm

Can you copy it into the clipboard and retrieve it from there?
What do you do with ill crystallographers? Take them to the mono-clinic!

User avatar
Nathaniel
Site Admin
Posts: 862
Joined: December 10th, 2008, 3:48 pm
Location: New Brunswick, Canada
Contact:

Re: Getting RLE in Golly

Post by Nathaniel » June 21st, 2009, 2:33 pm

calcyman wrote:Can you copy it into the clipboard and retrieve it from there?
There seems to be a Python library that lets you retrieve clipboard data on Windows machines, but I haven't come across a cross-platform way of doing it.

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

Re: Getting RLE in Golly

Post by Andrew » June 21st, 2009, 6:38 pm

What you're doing is probably the best (only?) way in 2.0. In 2.1 Dave Greene has added a getclipstr() command which makes it very easy:

import golly as g
g.select(g.getrect())
g.copy()
rle = g.getclipstr()

There's also a setclipstr(string) command for putting arbitrary text into the clipboard. Golly 2.1b4 should be available in a couple of days.
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

User avatar
Nathaniel
Site Admin
Posts: 862
Joined: December 10th, 2008, 3:48 pm
Location: New Brunswick, Canada
Contact:

Re: Getting RLE in Golly

Post by Nathaniel » June 21st, 2009, 7:10 pm

Andrew wrote:What you're doing is probably the best (only?) way in 2.0. In 2.1 Dave Greene has added a getclipstr() command which makes it very easy:

import golly as g
g.select(g.getrect())
g.copy()
rle = g.getclipstr()

There's also a setclipstr(string) command for putting arbitrary text into the clipboard. Golly 2.1b4 should be available in a couple of days.
Awesome, thanks Andrew. As if I needed another reason to want 2.1

Also (this is more of a curiosity than anything) is there a way in a script to determine which version of Golly the user is running?

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

Re: Getting RLE in Golly

Post by Andrew » June 21st, 2009, 7:27 pm

Nathaniel wrote:Also (this is more of a curiosity than anything) is there a way in a script to determine which version of Golly the user is running?
You can do things like this:

Code: Select all

import golly as g
try:
   rle = g.getclipstr()
   # if we get here then we're using Golly 2.1 or later
   ...
except:
   # we're using Golly 2.0 or older
   ...
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

Post Reply