Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------
- -- x3edit installer --
- -- Created by Pilix --
- -- McFine.ru --
- ----------------------
- local Error = false
- -------------
- local function InjectInEdit()
- local From = io.open("rom/programs/edit",'r')
- local To = io.open("x3edit/x3edit",'w')
- local key = true
- if From ~= nil and To ~= nil then
- local cnt = 0
- for line in From:lines() do
- To:write(line.."\n")
- cnt = cnt + 1
- if cnt == 594 then
- To:write(" x3edit_api.detect(tLines,param,param3 + scrollY)\n")
- To:write(" redrawText()\n")
- end
- end
- else
- key = false
- end
- From:close()
- To:close()
- return key
- end
- -------------
- local function InjectInStartup()
- local From = io.open("/startup",'r')
- local To = io.open("/new_startup",'w')
- if From ~= nil and To ~= nil then
- To:write("os.loadAPI(\"/x3edit/x3edit_api\")\n")
- To:write("shell.setAlias(\"x3edit\",\"/x3edit/x3edit\")\n")
- for line in From:lines() do
- To:write(line.."\n")
- end
- From:close()
- To:close()
- fs.delete("/startup")
- fs.move("/new_startup","startup")
- return true
- end
- From:close()
- To:close()
- return false
- end
- -------------
- local function CreateStartup()
- local To = io.open("/startup",'w')
- if To ~= nil then
- To:write("os.loadAPI(\"/x3edit/x3edit_api\")\n")
- To:write("shell.setAlias(\"x3edit\",\"/x3edit/x3edit\")\n")
- To:close()
- return true
- end
- return false
- end
- -------------
- local function CreateAPI()
- local From = io.open(shell.getRunningProgram(),'r')
- local To = io.open("/x3edit/x3edit_api",'w')
- local key = true
- if From ~= nil and To ~= nil then
- CopyKey = false
- for line in From:lines() do
- if line == "--[ Block #1 ]--" then
- if CopyKey then
- break
- else
- CopyKey = true
- end
- elseif CopyKey then
- To:write(line.."\n")
- end
- end
- else
- key = false
- end
- From:close()
- To:close()
- return key
- end
- --[ Block #1 ]--
- bPath = "/x3edit/x3buff"
- function detect (iTab,button,pos_y)
- if button == 1 then
- iTab.pos = pos_y
- elseif button == 2 then
- local pos1 = iTab.pos
- local cnt = pos_y - pos1 + 1
- if cnt > 0 then
- Fp = io.open(bPath,"w")
- if Fp ~= nil then
- local pos_i = 0
- while cnt > 0 do
- Fp:write(iTab[pos1 + pos_i].."\n")
- pos_i = pos_i + 1
- cnt = cnt - 1
- end
- Fp:close()
- end
- end
- elseif button == 3 then
- if fs.getSize(bPath) > 0 then
- Fp = io.open(bPath,"r")
- if Fp ~= nil then
- local pos_i = 0
- for line in Fp:lines() do
- table.insert(iTab,pos_y + pos_i,line)
- pos_i = pos_i + 1
- end
- Fp:close()
- end
- end
- end
- end
- --[ Block #1 ]--
- ----------------------------------
- shell.setDir("")
- if not fs.exists("/x3edit") then
- fs.makeDir("/x3edit")
- end
- if fs.exists("/x3edit/x3edit") then
- fs.delete("/x3edit/x3edit")
- end
- if InjectInEdit() then
- print("Inject <edit> : Ok")
- else
- print("Inject <edit> : Error -> Break...")
- Error = true
- end
- if not Error then
- if fs.exists("/startup") then
- if InjectInStartup() then
- print("Inject <startup> : Ok")
- else
- print("Inject <startup> : Error -> Break...")
- Error = true
- end
- else
- if CreateStartup() then
- print("Create <startup> : Ok")
- else
- print("Create <startup> : Error -> Break...")
- Error = true
- end
- end
- end
- if not Error then
- if CreateAPI() then
- print("Create <API> : Ok")
- else
- print("Create <API> : Error -> Break...")
- Error = true
- end
- end
- if Error then
- print("x3edit install failed...")
- else
- print("x3edit install successful!")
- end
- term.write("Reboot system... ")
- local x,y = term.getCursorPos()
- local cnt = 5
- while cnt>0 do
- term.write(tostring(cnt))
- term.setCursorPos(x,y)
- cnt = cnt - 1
- sleep(1)
- end
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement