Golly crash

A forum for topics that don't fit elsewhere. Introduce yourselves to other members of the forums, discuss how your name evolves when written out in the Game of Life, or just tell us how you found it. Forum rules still apply.
Locked
User avatar
lifeisawesome
Posts: 86
Joined: April 22nd, 2016, 1:55 pm
Location: poland

Golly crash

Post by lifeisawesome »

This is the code I'm using:

Code: Select all

import time, golly as g
x = int(g.getstring("Enter generation delay (in milliseconds):"))/1000
if x <= 0:
  g.show("Invalid number.")
  exit()

while True:
  g.run(1)
  time.sleep(x)
When I run this script on Golly 3.0, it exits.
--Szymon Bartosiewicz
favorite pattern:

Code: Select all

x = 2, y = 2, rule = B25/S3a
2o$2o!
User avatar
rowett
Moderator
Posts: 4597
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

Re: Golly crash

Post by rowett »

The int needs to be a float or x becomes 0 for any input less than 1000 at which point you call exit().

Also don't call exit() because it will exit the process. Perhaps use an else: for the while clause.

Oh and you'll need a call to g.update() after g.run(1) to refresh the display.
User avatar
lifeisawesome
Posts: 86
Joined: April 22nd, 2016, 1:55 pm
Location: poland

Re: Golly crash

Post by lifeisawesome »

Oh, exit() was the problem.
--Szymon Bartosiewicz
favorite pattern:

Code: Select all

x = 2, y = 2, rule = B25/S3a
2o$2o!
Locked