Tutorials/Scripts: Difference between revisions

From LifeWiki
Jump to navigation Jump to search
m →Getting scripts: AutoWikiBrowser, replaced: http://www.conwaylife → https://www.conwaylife
Confocal (talk | contribs)
m link
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{stub}}
Here you will learn how to use Golly scripts.
Here you will learn how to use scripts.


== What are scripts? ==
== What are scripts? ==
Scripts are code that allows you to easily do something that is normally tedious to do ''automatically'', like finding the period of an oscillator or generating large patterns. There are also scripts that search for patterns ("objects"). A script can be written in Python, Perl, or Lua, at least for Golly scripts. For larger scripts doing more complicated things (e.g. finding a spaceship), it is better to write in C than Python. A lot of scripts have been written for Golly, from drawing a line to generating massive objects.
Scripts are code that allows you to easily do something that is normally tedious to do ''automatically'', like finding the period of an oscillator or generating large patterns. There are also scripts that search for [[object]]s. A script can be written in Python, Perl, or [[Lua]], at least for Golly scripts. For larger scripts doing more complicated things (e.g. finding a spaceship), it is better to write in C than Python. A lot of scripts have been written for Golly, from drawing a line to generating massive objects.
 
== Getting scripts ==
To get a script, go to the conwaylife forums and then look around, an example of a script on the forum is the [https://www.conwaylife.com/forums/viewtopic.php?f=9&t=2413 Neighborhood Simplifier]. Copy this script:


== Sample script ==
Copy this script:
<pre>
<pre>
import golly as g
import golly as g
Line 14: Line 12:
cool.put(1, 2)
cool.put(1, 2)
</pre>
</pre>
To run it, go to Golly, click the File menu and then click '''Run clipboard'''. You should see a message. That's how to run clipboard scripts.


Now, to run it, go to Golly, click the File menu and then click "Run clipboard". You should see a special message. That's how to run clipboard scripts. If the script's output is in a file, check C:\Users\Administrator\AppData\Roaming\Golly.
(If a script's output is in a file, check C:\Users\Administrator\AppData\Roaming\Golly).


== Saving scripts ==
== Saving scripts ==
To save a script on your computer, open your favorite text editor, paste the script in, and then save as .py in your scripts folder. To run it, go to File > Run script...
To save a script on your computer, open your favorite text editor, paste the script into it, then save it as a .py file in your Golly scripts folder. Click '''File > Run script...''' to run it.
 
== Getting scripts ==
You can find sample scripts at the [https://conwaylife.com/forums/viewtopic.php?f=9&t=45 '''Golly scripts''' forum thread] and in the Golly scripts folder on your computer.


== Next ==
== Next ==
You can now learn about:
You can now learn about:


*[[Tutorials/Overlays|Overlays, another type of script]]
*[[Tutorials/Software|Software for searching stuff]]
*[[Tutorials/Software|Software for searching stuff]]
*[[Tutorials/Your First Python Script|Creating your very own Python script]]
*[[Tutorials/Your first Python script|Creating your very own Python script]]
 
{{Tutorial}}
{{Tutorial}}
{{GollyNavbox}}

Latest revision as of 10:19, 6 August 2023

Here you will learn how to use Golly scripts.

What are scripts?

Scripts are code that allows you to easily do something that is normally tedious to do automatically, like finding the period of an oscillator or generating large patterns. There are also scripts that search for objects. A script can be written in Python, Perl, or Lua, at least for Golly scripts. For larger scripts doing more complicated things (e.g. finding a spaceship), it is better to write in C than Python. A lot of scripts have been written for Golly, from drawing a line to generating massive objects.

Sample script

Copy this script:

import golly as g
from glife import *
cool = pattern("bo3bo$2bobo2b3o2bo2bo$3bo3bobo2bo2bo$3bo3bobo2bobo$3bo3b3o2b2o$3bo3$3o2bob3o3bob4obo$ob2obobob2o2bo3bo2bo$o2bobobo2bo2bo3bo2bo$o2bobobo2bo2bo3bo$4obo2b3o2bo3bo2bo!")
cool.put(1, 2)

To run it, go to Golly, click the File menu and then click Run clipboard. You should see a message. That's how to run clipboard scripts.

(If a script's output is in a file, check C:\Users\Administrator\AppData\Roaming\Golly).

Saving scripts

To save a script on your computer, open your favorite text editor, paste the script into it, then save it as a .py file in your Golly scripts folder. Click File > Run script... to run it.

Getting scripts

You can find sample scripts at the Golly scripts forum thread and in the Golly scripts folder on your computer.

Next

You can now learn about: