ConwayLife.com - A community for Conway's Game of Life and related cellular automata
Home  •  LifeWiki  •  Forums  •  Download Golly

MCell-like selections for Golly

For scripts to aid with computation or simulation in cellular automata.

MCell-like selections for Golly

Postby Andrew » February 15th, 2019, 8:43 am

The script attached below implements an MCell-like editing mode for Golly. In particular, selections float above the current pattern and can be dragged around. You can also run the current pattern without changing the selection.

Some notes on usage:

* When the script starts up it will convert an existing Golly selection into a floating selection. When the script ends, a floating selection will be converted back to a Golly selection.

* The script switches to select mode when it starts up. If you don't want it to do that then remove the g.setcursor("Select") call in ConvertGollySelection(). Note that you can switch cursor mode at any time by clicking in the usual buttons in the edit bar. For example, you might want to switch to the pencil cursor and draw/erase cells. Unlike Golly, the script lets you draw at any scales up to 2^5:1.

* The script supports undo/redo via Golly's usual keyboard commands.

* Hit the H key at any time to get a dialog with help info.

* If a selection exists you can ctrl-click or right-click anywhere in the viewport to get a pop-up menu with various selection actions (cut, copy, clear, flip, rotate, etc).

* While the script is running you can use most of your usual mouse actions and keyboard shortcuts to pan, zoom in/out, switch cursors, etc.

* Live cells in the selection are always displayed in non-icon mode.
(A future version of Golly might provide an overlay command to get icon images.)

The script illustrates how the overlay can be used to enhance or completely replace Golly's usual behavior, so feel free to modify it to suit your own needs. It would also be a useful starting point for a script that allowed more sophisticated selection modes (eg. a lasso mode, or disjoint selections, or circular/diamond shaped selections).
Attachments
mcell-selection.lua.zip
MCell selections for Golly
(7.66 KiB) Downloaded 96 times
User avatar
Andrew
Moderator
 
Posts: 746
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia

Re: MCell-like selections for Golly

Postby wildmyron » February 28th, 2019, 5:51 am

Thanks for creating and posting this script Andrew.

I think it's worth mentioning that the overlay functionality used requires Golly 3.2, I had errors when trying to run it with earlier versions.

For some reason it wasn't clear to me how to paste the selection into the current pattern. I figured out that after copying the selection I could left click outside the selection (with Golly is in select mode) to drop a copy of the pattern in the selection into the current layer. Then use ctrl-v to paste what is on the clipboard into a new floating selection.
The latest version of the 5S Project contains over 150,000 spaceships. Tabulated pages up to period 160 are available on the LifeWiki.
wildmyron
 
Posts: 1159
Joined: August 9th, 2013, 12:45 am

Re: MCell-like selections for Golly

Postby Andrew » February 28th, 2019, 12:28 pm

wildmyron wrote:For some reason it wasn't clear to me how to paste the selection into the current pattern. I figured out that after copying the selection I could left click outside the selection (with Golly is in select mode) to drop a copy of the pattern in the selection into the current layer.

Yeah, that's just the way MCell works (I assumed that only people familiar with MCell would want to use the script). Feel free to make changes. For example, you could add a "Drop Selection" item to the top of the pop-up menu that simply calls the DropSelection function.

Another thing that really irritated me is the way MCell erases the pattern under a newly created selection. If you don't want the script to do that then just remove or comment out this line in FinishSelection:
        g.putcells(selcells, 0, 0, 1, 0, 0, 1, "xor")
User avatar
Andrew
Moderator
 
Posts: 746
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia

Re: MCell-like selections for Golly

Postby wildmyron » February 28th, 2019, 12:40 pm

Andrew wrote:
wildmyron wrote:For some reason it wasn't clear to me how to paste the selection into the current pattern. I figured out that after copying the selection I could left click outside the selection (with Golly is in select mode) to drop a copy of the pattern in the selection into the current layer.

Yeah, that's just the way MCell works (I assumed that only people familiar with MCell would want to use the script). Feel free to make changes. For example, you could add a "Drop Selection" item to the top of the pop-up menu that simply calls the DropSelection function.

Thanks for the response. I am familiar with floating selections from Java Square Cell which is based on MCell. It does have the same behaviour now that I read the instructions again, but it also has a copy mode which leaves the cells in the pattern when the selection is moved - and I only mentioned it because it wasn't obvious to me how it should work from reading the help.
The latest version of the 5S Project contains over 150,000 spaceships. Tabulated pages up to period 160 are available on the LifeWiki.
wildmyron
 
Posts: 1159
Joined: August 9th, 2013, 12:45 am


Return to Scripts

Who is online

Users browsing this forum: No registered users and 3 guests