Posted 28 June 2013 - 10:14 PM
I am trying to write an updater script for my program but when I run it i get "shell:80: expected string, got nil" can anyone help me?
client="Update Client"
server="Update Server"
self="Update Self"
clientsel="* Update Client *"
serversel="* Update Server *"
selfsel="* Update Self *"
uptx="Checking for update..."
futx="Found Update! Press Y to update or N to cancel"
lvtx="Script already at latest version!"
cutx="Updating..."
catx="Canceled!"
cuctx="Updated!"
clientcode="g7AmTvM8"
servercode="43NXRhFi"
selfcode="6UwqyDkP"
selected=1
shell.run("clear")
screenx,screeny=term.getSize()
function draw()
shell.run("clear")
if selected==1 then
term.setCursorPos((screenx/2)-(string.len(clientsel)/2),screeny/3-3)
write(clientsel)
term.setCursorPos((screenx/2)-(string.len(server)/2),screeny/3*2-3)
write(server)
term.setCursorPos((screenx/2)-(string.len(self)/2),screeny/3*3-3)
write(self)
else if selected==2 then
term.setCursorPos((screenx/2)-(string.len(client)/2),screeny/3-3)
write(client)
term.setCursorPos((screenx/2)-(string.len(serversel)/2),screeny/3*2-3)
write(serversel)
term.setCursorPos((screenx/2)-(string.len(self)/2),screeny/3*3-3)
write(self)
else if selected==3 then
term.setCursorPos((screenx/2)-(string.len(client)/2),screeny/3-3)
write(client)
term.setCursorPos((screenx/2)-(string.len(server)/2),screeny/3*2-3)
write(server)
term.setCursorPos((screenx/2)-(string.len(selfsel)/2),screeny/3*3-3)
write(selfsel)
end
end
end
end
draw()
function localv()
shell.resolve()
end
function checkForUpdate(pbcode,scname)
atf=false
if fs.exists(localv().."/"..scname) then
h=http.get("http://pastebin.com/raw.php?i="..pbcode)
hsc=h.readAll()
c=fs.open(localv(scname),"a")
csc=c.readAll()
if hsc==csc then atf=false else atf=true end
h.close()
c.close()
return atf
else
return true
end
end
function updateclient()
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(uptx)/2),screeny/2)
write(uptx)
if checkForUpdate(clientcode,chat) then
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(futx)/2),screeny/2)
write(futx)
while slup==nil do
e,par1=os.pullEvent()
if e == "key" then
if tostring(par1) == "21" then
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(cutx)/2),screeny/2)
write(cutx)
h=http.get("http://pastebin.com/raw.php?i=g7AmTvM8")
hsc=h.readAll()
c=fs.open(localv("chat"),"w")
c.write(hsc)
h.close()
c.close()
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(cuctx)/2),screeny/2)
write(cuctx)
sleep(2.5)
return
else if tostring(par1) == "49" then
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(catx)/2),screeny/2)
write(catx)
sleep(2.5)
return
end
end
end
end
else
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(lvtx)/2),screeny/2)
write(lvtx)
end
end
function updateserver()
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(uptx)/2),screeny/2)
write(uptx)
if checkForUpdate(servercode,server) then
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(futx)/2),screeny/2)
write(futx)
while slup==nil do
e,par1=os.pullEvent()
if e == "key" then
if tostring(par1) == "21" then
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(cutx)/2),screeny/2)
write(cutx)
h=http.get("http://pastebin.com/raw.php?i=43NXRhFi")
hsc=h.readAll()
c=fs.open(localv("server"),"w")
c.write(hsc)
h.close()
c.close()
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(cuctx)/2),screeny/2)
write(cuctx)
sleep(2.5)
return
else if tostring(par1) == "49" then
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(catx)/2),screeny/2)
write(catx)
sleep(2.5)
return
end
end
end
end
else
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(lvtx)/2),screeny/2)
write(lvtx)
end
end
function updateself()
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(uptx)/2),screeny/2)
write(uptx)
if checkForUpdate(selfcode,chat) then
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(futx)/2),screeny/2)
write(futx)
while slup==nil do
e,par1=os.pullEvent()
if e == "key" then
if tostring(par1) == "21" then
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(cutx)/2),screeny/2)
write(cutx)
h=http.get("http://pastebin.com/raw.php?i=6UwqyDkP")
hsc=h.readAll()
c=fs.open(localv("updater"),"w")
c.write(hsc)
h.close()
c.close()
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(cuctx)/2),screeny/2)
write(cuctx)
sleep(2.5)
return
else if tostring(par1) == "49" then
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(catx)/2),screeny/2)
write(catx)
sleep(2.5)
return
end
end
end
end
else
shell.run("clear")
term.setCursorPos((screenx/2)-(string.len(lvtx)/2),screeny/2)
write(lvtx)
end
end
while true do
e,par1=os.pullEvent()
if e=="key" then
if tostring(par1)=="205" or tostring(par1)=="208" then
if selected==3 then
selected=1
else
selected=selected+1
end
end
if tostring(par1)=="200" or tostring(par1)=="203" then
if selected==1 then
selected=3
else
selected=selected-1
end
end
if tostring(par1)=="28" then
if selected==1 then
updateclient()
else if selected==2 then
updateserver()
else if selected==3 then
updateself()
end
end
end
draw()
sleep(0.25)
end
end
end