#!/bin/lua io.write("Welcome to the Lia installer, first edition.\nI will now try and check if you have curl installed; you probably do.\n") dler = "curl " pray=os.execute("curl --version") if not pray then io.write("\nWell, you don't seem to have curl... maybe wget?\n") prayharder=os.execute("wget --version") if not prayharder then io.write("Okay, you're out of luck. I might write a last try with luarocks later; for now, go get curl or wget and run this again.\nThat said, it's possible that you already have either installed, but they just aren't in your path; look up how to add commands to your path , do it for wget or curl, and run me again.") end io.write("\nOkay, got wget. We're game.") dler = "wget " end io.write("\nAlright, I got a download command, let me just roll my own base64 decoder now...\n") b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' function base64(data) data = string.gsub(data, '[^'..b..'=]', '') return (data:gsub('.', function(x) if (x == '=') then return '' end local r,f='',(b:find(x)-1) for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end return r; end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x) if (#x ~= 8) then return '' end local c=0 for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end return string.char(c) end)) end io.write("\nEverything's in place. Alright, what version do you want to use? (Leave blank and just press enter if latest/recommended.)\n") xinp = io.read() if xinp == "" then io.write("\nGetting latest/recommended version: downloading latest/recommended version name...\n") suc,errx,errs = os.execute(dler.." -O https://lia-lang.neocities.org/dl/latest.txt") if not suc then io.write("Something went wrong!",suc,errx,errs) error("Exiting after fatal error.") end io.write("\nReading location...\n") filestuff = io.lines("latest.txt") filename = filestuff() io.write("\nVersion to download is:",filename,"\nAdditional notes:\n",filestuff() or "None!","\nEnd of additional notes.\nNow fetching microarchive!") suc,errx,errs = os.execute(dler.."https://lia-lang.neocities.org"..filename.. " -o lia.microarchive") if not suc then io.write("Something went wrong!",suc,errx,errs) error("Exiting after fatal error.") end io.write("\nMicroarchive downloaded!\nDecomposing microarchive...\n") --there must be 3 lines only in the microarchive: --melia.lua in base64 --a separator line --repl.lua in base64 itere = io.lines("lia.microarchive") curfile=io.open("melia.lua","w") io.output(curfile) io.write(base64(itere())) io.write("\n") io.close(curfile) print(itere()) --separator curfile=io.open("repl.lua","w") io.output(curfile) io.write(base64(itere())) io.write("\n") io.close(curfile) print("Done,you may delete latest.txt and lia.microarchive now.\nHave fun! (Just run repl.lua to get started.)") else print("oops") end