Difference between revisions of "User:Saka/Gemini Pages/Tut:FPS"

From LifeWiki
Jump to navigation Jump to search
m
Line 5: Line 5:
 
Wait! You need to pack some stuff for the trip. You need:
 
Wait! You need to pack some stuff for the trip. You need:
 
*[[Golly]]
 
*[[Golly]]
*Python 2.7+ (But NOT Python 3)
+
*Python 2.7+ (But not Python 3, since Golly doesn't support Python 3 as of now...)
 
*Computer
 
*Computer
 
*Keyboard
 
*Keyboard
 
*Mouse (Optional)
 
*Mouse (Optional)
If you are on a Mac, Python should already be installed (But alas, I don't have a mac. Andrew told me.). Once you have packed your stuff you can start your Pythoning adventure!
+
If you are on a Mac, Python should already be installed (But alas, the author of this article doesn't have a "Mac", so the author is relying on information from others.). Once you have packed your stuff and prepared you can start your Pythoning adventure!
 
 
  
 
== What are we Going to Make? ==
 
== What are we Going to Make? ==

Revision as of 13:11, 20 May 2020

Ah! You wants to Pythoning? Well, young lad, look no further than your computer. Here you will learn the basics of Python-scripting in Golly™.


Things to Install

Wait! You need to pack some stuff for the trip. You need:

  • Golly
  • Python 2.7+ (But not Python 3, since Golly doesn't support Python 3 as of now...)
  • Computer
  • Keyboard
  • Mouse (Optional)

If you are on a Mac, Python should already be installed (But alas, the author of this article doesn't have a "Mac", so the author is relying on information from others.). Once you have packed your stuff and prepared you can start your Pythoning adventure!

What are we Going to Make?

For this tutorial we are going to make a very simple script that detects the period of the object on screen. Golly already has a built-in script for this exact thing (See oscar.py)but we are going to make it anyway because why not. For this script, it will only detect the period of an oscillator, not a spaceship, because that's too complicated for a simple person like me. But who am I? And where is I?


The Idea

The idea of this script is to take a the pattern and run it until it either repeats or crosses the set border of time. You'll understand later (hopefully) once we get into making the script. Let's draw an outline of our program in a flow chart (Note: I have no idea how to draw a flow chart):
Flow1.png
So there, we have the flow our program is going to go in. Now we just need to translate Ingleesh to Pythonese. To start, open a new Python IDLE window.

Let's get making!

Horray! It's fun time!

Step 1: Setting things up

Let's set things up.

Believe it or not, Golly has it's own Python module! It is used to make scripting easier and contains other useful non-Golly features such as easy dialog boxes without the need of the bulky tkinter commands. To import the Golly module, simply type

import golly as g

The 'as g' is not needed, but will make it easier. Commands in that are packed into the Golly module can be found in Golly's help files.

Step 2: Is there a pattern?

There is a very simple way to test if the pattern is empty in Golly. If you read the Golly help files, you probably have found it already. If you haven't, it's

g.empty()

The g.empty() command returns a simple true or false. It will return true if the pattern is empty and false otherwise...