From 7ad9a559fbd9ac46336d9e0689c0df4cc87e5eb9 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 15 Aug 2010 21:53:12 +0200 Subject: adjusted example rcs. added README --- misc/run.lua | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'misc/run.lua') diff --git a/misc/run.lua b/misc/run.lua index 0fcc030..b90f90d 100644 --- a/misc/run.lua +++ b/misc/run.lua @@ -25,7 +25,11 @@ GOTO http://www.luatex.org/ return 1 end -require "life" +mplife = {} +mplife.setup = {} + +require "automata-life" +require "automata-eca" local C, Cs, Ct, P, R, S, match = lpeg.C, lpeg.Cs, lpeg.Ct, lpeg.P, lpeg.R, lpeg.S, lpeg.match @@ -102,15 +106,8 @@ function life (current) return 0 end -function eca(current) - local eca = require "eca" - -- how many lines to draw - current.n = tonumber(current.kv_args.n) or 30 - current.aspect = tonumber(current.kv_args.aspect) or 3/4 - current.rule = eca.gen_rule(tonumber(current.kv_args.rule) or 110) - current.from = eca.parse_file(current.kv_args.file) - current.framesize = math.floor(current.aspect * current.from:len()) - +function elem(current) + print (current.n, type(current.n)) for n=1,current.n,1 do gol.pre_section(current.from:len(), n) eca.successive(current) @@ -121,14 +118,30 @@ end function main () local current = {} current.kv_args = get_args() - current.file = current.kv_args.file or "10x10_glider.gol" + current.file = current.kv_args.file local p_suf = P"." * (1-P".")^3 * -P(1) local p_fn = (1-p_suf)^1 * C(p_suf) local suffix = p_fn:match(current.file) or ".gol" -- assume .gol format as default if suffix == ".eca" then - return eca(current) + require "automatarc-eca" + for i,j in pairs(mplife.setup.rc) do + current[i] = mplife.setup.rc[i] + end + current.aspect = tonumber(current.kv_args.aspect) or 3/4 + current.rule = eca.gen_rule(tonumber(current.kv_args.rule) or 110) + current.from = eca.parse_file(current.kv_args.file) + current.framesize = math.floor(current.aspect * current.from:len()) + + current.n = tonumber(current.kv_args.n) + end + + current.n = tonumber(current.kv_args.n) + + if suffix == ".eca" then + mplife.setup.current = current + return elem(current) else return life(current) end -- cgit v1.2.3