From fd8ab52a6e7a622a46824f2b38e8e499bd471b64 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 13 Aug 2010 10:34:36 +0200 Subject: setting initial frame and rule from simpleslides paramaters. --- life.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'life.lua') diff --git a/life.lua b/life.lua index a760804..42a17bd 100644 --- a/life.lua +++ b/life.lua @@ -41,7 +41,7 @@ end -- Modified to match left and right of one separator only. function gol.helpers.split_once (s, sep) local utfchar = gol.helpers.utfchar - sep = P(sep) + sep = S(sep) local left = C((1 - sep)^0) local right = C((utfchar)^0) local p = Ct(left * sep * right) @@ -67,12 +67,13 @@ function gol.helpers.dead_row(len) return row end --- Read rules of type "B3/S23" +-- Read rules of type "B3[/.-]S23" -- => “birth” of a new cell if exactly 3 adjacent cells are “alive” -- => “staying alive” of cells with two or three adjacent “live” cells function gol.parse_rule (raw_rule) + print("HERE!!>>>>>>>>>>> "..raw_rule) local help = gol.helpers - local b_s = help.split_once (raw_rule, "/") + local b_s = help.split_once (raw_rule, "/.-") local tmp_b = help.strip(b_s[1], "B") local tmp_s = help.strip(b_s[2], "S") @@ -145,6 +146,10 @@ function gol.parse_file (fname) local tmp = {} -- return an array local len -- check for equal line length + if fname:sub(-4,-1) ~= ".gol" then -- check extension + fname = fname .. ".gol" + end + local file = assert(io.open(fname, "r"), "Not a file: " .. fname) for line in file:lines() do if not len then len = string.len(line) end -- cgit v1.2.3