Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. print("This should only run once...")
  2. print("And this twice")
  3. local fso=fs.open
  4. local lf=loadfile
  5. local done=false
  6. local function chopLines(s,n)
  7.     local w=n
  8.     local res=""
  9.     for i=1,#s do
  10.         if w==0 then res=res..s:sub(i,i) end
  11.         if s:sub(i,i)=="\n" and w>0 then w=w-1 end
  12.     end
  13.     return res
  14. end
  15. fs.open=function(f,m)
  16.     local file=fso(f,m)
  17.     local fro=file.readAll
  18.     --if done or shell.getRunningProgram()~="test.lua" then return file end
  19.     --done=true
  20.     file.readLine() --skips first line
  21.     file.readAll=function()
  22.         return chopLines(fro(),1) --yes, removing the first line
  23.     end
  24.     return file
  25. end
  26. loadfile=function(f,e)
  27.     local tmp=fs.open
  28.     fs.open=fso
  29.     local res,res2=lf(f,e)
  30.     fs.open=tmp
  31.     return res,res2
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement