Posted 28 November 2013 - 10:09 AM
Long time ago i asked here how to make an "auto installer", now i want to make a complete update system…
I wrote the code and didn't got it working properly, so i decided to ask a pro again.
So I hope anyone can help me and tell me what i made wrong
The computer that broadcasts the update:
problems i recognized:
menu() function does not work for some reason :o/>/> (Look at the "test" message that just won't apear)
there're some problems with the file.readLine() part at the ending, checked it like a thousend times but I don't get whats wrong :(/>
Im sure there are tons of beginner mistakes, i'm sorry for that :$
Code for receiver
Here i'm completly helpless, this doesn't work at all. The computer just sais "bios:337: expected string, string"
And here too, sorry for some beginner mistekas :D/>
At this point i'll just thank everyone who took the time to read this, and at the people who understood it or even know what i made wrong: I'll be even more thankfull when you write a comment :D/>
I wrote the code and didn't got it working properly, so i decided to ask a pro again.
So I hope anyone can help me and tell me what i made wrong
The computer that broadcasts the update:
shell.run("clear")
local function drawmenu()
--print("test")
--sleep(3)
local x = 1
while x > 5 do
print("")
x = x + 1
end
print(" Is the update for turtles or computer?")
print("")
print("")
print("")
if choose == "up" then
print(" >turtle<")
print("")
print(" computer")
forwhat = "turtle"
elseif choose == "down" then
print(" turtle")
print("")
print(" >computer<")
forwhat = "computer"
else
print(" >turtle<")
print("")
print(" computer")
forwhat = "turtle"
end
end
local function menu()
while pressed == false do
local e,key = os.pullEvent( "key" )
if key == key.up then
local choose = "up"
elseif key == key.down then
local choose = "down"
end
drawmenu()
local e,enterkey = os.pullEvent( "key" )
if enterkey == key.enter then
local pressed = true
end
end
end
local function update()
shell.run("clear")
local x = 1
while x > 5 do
print("")
x = x + 1
end
print(" Whats the name of your update?:")
print("")
write(" ")
local readFrom = read()
local file = fs.open(readFrom, "r")
local lines = file.readLine()
local program = {lines}
for lines in file.readLine do
table.insert(program, lines)
end
file.close()
local data = textutils.serialize(program, lines)
rednet.broadcast(forwhat, data)
end
menu()
update()
problems i recognized:
menu() function does not work for some reason :o/>/> (Look at the "test" message that just won't apear)
there're some problems with the file.readLine() part at the ending, checked it like a thousend times but I don't get whats wrong :(/>
Im sure there are tons of beginner mistakes, i'm sorry for that :$
Code for receiver
function testupdate()
if turtle then
event, id, update, data = os.pullEvent()
if event == "rednet_message" then
if update == "turtle" then
local writeTo = "myos"
local system = textutils.unserialize(data)
local file = fs.open(writeTo, "w")
for i = 1,#system do
file.writeLine(data[i])
end
print("installing update...")
sleep(5)
file.close()
end
end
else
event, id, update, data = os.pullEvent()
if event == "rednet_message" then
if update == "computer" then
local writeTo = "myos"
local system = textutils.unserialize(data)
local file = fs.open(writeTo, "w")
for i = 1,#system do
file.writeLine(data[i])
end
print("installing update...")
sleep(5)
file.close()
end
end
end
end
os.run("clear")
for n,m in ipairs(rs.getSides()) do rednet.open(m) end
testupdate()
Here i'm completly helpless, this doesn't work at all. The computer just sais "bios:337: expected string, string"
And here too, sorry for some beginner mistekas :D/>
At this point i'll just thank everyone who took the time to read this, and at the people who understood it or even know what i made wrong: I'll be even more thankfull when you write a comment :D/>
Edited on 28 November 2013 - 09:35 AM