SHOW:
|
|
- or go back to the newest paste.
| 1 | - | function Evolve( cell ) |
| 1 | + | print("Downloading latest version from github...")
|
| 2 | - | local m = #cell |
| 2 | + | fh=http.get("https://raw.github.com/Sxw1212/cclife/master/life.lua")
|
| 3 | - | local cell2 = {}
|
| 3 | + | if fh then |
| 4 | - | for i = 1, m do |
| 4 | + | code=fh.readAll() |
| 5 | - | cell2[i] = {}
|
| 5 | + | fh.close() |
| 6 | - | for j = 1, m do |
| 6 | + | print("Launching...")
|
| 7 | - | cell2[i][j] = cell[i][j] |
| 7 | + | for k,v in pairs(rs.getSides()) do |
| 8 | - | end |
| 8 | + | if peripheral.getType(v)=="monitor" then |
| 9 | - | end |
| 9 | + | print("Monitor found...")
|
| 10 | - | |
| 10 | + | monitor=true |
| 11 | - | for i = 1, m do |
| 11 | + | monitorc=v |
| 12 | - | for j = 1, m do |
| 12 | + | |
| 13 | - | local count |
| 13 | + | |
| 14 | - | if cell2[i][j] == 0 then count = 0 else count = -1 end |
| 14 | + | |
| 15 | - | for x = -1, 1 do |
| 15 | + | |
| 16 | - | for y = -1, 1 do |
| 16 | + | print("Please choose a save file.")
|
| 17 | - | if i+x >= 1 and i+x <= m and j+y >= 1 and j+y <= m and cell2[i+x][j+y] == 1 then count = count + 1 end |
| 17 | + | write("File:")
|
| 18 | - | end |
| 18 | + | file=read() |
| 19 | - | end |
| 19 | + | if monitor then |
| 20 | - | if count < 2 or count > 3 then cell[i][j] = 0 end |
| 20 | + | |
| 21 | - | if count == 3 then cell[i][j] = 1 end |
| 21 | + | |
| 22 | - | end |
| 22 | + | print("Monitor detected. Enable?")
|
| 23 | - | end |
| 23 | + | write("yes/no[yes]:")
|
| 24 | - | |
| 24 | + | local ans=read() |
| 25 | - | return cell |
| 25 | + | if ans=="yes" or ans=="" then |
| 26 | print("Monitor enabled!")
| |
| 27 | - | |
| 27 | + | mon=peripheral.wrap(monitorc) |
| 28 | - | function clear() |
| 28 | + | term.redirect(mon) |
| 29 | pcall(loadstring(code), file) | |
| 30 | term.restore() | |
| 31 | else | |
| 32 | - | clear() |
| 32 | + | pcall(loadstring(code), file) |
| 33 | - | print "Welcome to Sxw's Game of Life!" |
| 33 | + | |
| 34 | - | x,y=term.getSize() |
| 34 | + | |
| 35 | - | size=0 |
| 35 | + | pcall(loadstring(code), file) |
| 36 | - | if x > y then |
| 36 | + | |
| 37 | - | size=y-1 |
| 37 | + | print("Exited")
|
| 38 | - | elseif x < y then |
| 38 | + | |
| 39 | - | size=x |
| 39 | + | print("Failed to download new version")
|
| 40 | end |