This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
"end" expected at line 88
Started by pieiscool32, 10 March 2012 - 09:50 PMPosted 10 March 2012 - 10:50 PM
the code keeps saying that i need to put "end" at line 88, the code, find it here.
Posted 10 March 2012 - 10:55 PM
i think i know what's wrong. The syntax is:
if expression then code else code end
not
if expression then code end else code end
Posted 10 March 2012 - 11:08 PM
Where? Because i have a loop on that line to tries to connect and won't stop until it connects to the client and gets a message back.
Posted 10 March 2012 - 11:11 PM
when i collapsed your code in notepad++ i got 3 loose 'end's. I think that you are giving an 'end' before each 'else' instruction. I may be wrong though, I didnt look very close
Posted 10 March 2012 - 11:50 PM
Could you give it a look? because i can't seem to pin-point the problem.
EDIT: still nothing….
EDIT: still nothing….
Posted 11 March 2012 - 01:49 AM
Allot of end errors in the code.
Liraal is right about the syntax errors in the script.
Here is one of your while loops:
Should be something more like:
This error is made all through out the code. Some of the ends are probably not needed too, there are atleast 3 extra ends in the code somewhere, both of the ones in the example look like they may not be needed.
I'm currently not able to run or test the code or would dig deeper, just go through and clean it up some and you should find the extra's.
Okay I put this in notepad++ and started to indent the code. I highly recommend doing this.
I found the initial if statement and 2 elseif statements with what appears to be extra ends in them or they may be missing "while true do" at the start of them as you have this in the rest of elseif statements.
You will either need to remove the end or add a while loop into the if/elseif statements at lines: 79, 158, 173
In my editing the line numbers have probably differed from yours. These are the lines.
Spoiler
while true do
print("Connecting To Reactor")
rednet.send(3,"stop")
local id, message = rednet.recieve(10)
if message == "stop" then
else print("Viper Connection Non Existent, Retrying")
break
end
sleep(0.5)
print("Reactor Shutdown Trigger Has Been Sent")
sleep(2)
shell.run "Nuke"
end
elseif enteredKey == water then
Should be something more like:
while true do
print("Connecting To Reactor")
rednet.send(3,"stop")
local id, message = rednet.recieve(10)
if message == "stop" then
else print("Viper Connection Non Existent, Retrying")
break
sleep(0.5)
print("Reactor Shutdown Trigger Has Been Sent")
sleep(2)
shell.run "Nuke"
elseif enteredKey == water then
end
end
This error is made all through out the code. Some of the ends are probably not needed too, there are atleast 3 extra ends in the code somewhere, both of the ones in the example look like they may not be needed.
I'm currently not able to run or test the code or would dig deeper, just go through and clean it up some and you should find the extra's.
Okay I put this in notepad++ and started to indent the code. I highly recommend doing this.
I found the initial if statement and 2 elseif statements with what appears to be extra ends in them or they may be missing "while true do" at the start of them as you have this in the rest of elseif statements.
You will either need to remove the end or add a while loop into the if/elseif statements at lines: 79, 158, 173
In my editing the line numbers have probably differed from yours. These are the lines.
if enteredKey == online then
elseif enteredKey == lights then
elseif enteredKey == slights then
Edited on 11 March 2012 - 01:22 AM
Posted 11 March 2012 - 02:06 PM
Are you forget brackets?88: shell.run "Nuke"
Posted 11 March 2012 - 05:36 PM
no, that's how it is suppose to be…
Posted 11 March 2012 - 10:58 PM
I finally got to where I can test it, the changes I suggested should fix it.
Also fix the typo on line 23 rednet.recieve to rednet.receive
Also fix the typo on line 23 rednet.recieve to rednet.receive
Posted 12 March 2012 - 12:47 AM
Ok, i kinda tried to fix it but there are some looping errors.
Posted 12 March 2012 - 01:11 AM
It looks like you may be using break in the wrong locations.
This one for sure needs to be removed, hard to tell on the rest with out being able to fully test the software package.
I can make it all the way into the menu. there are 8 more places you need to change recieve to receive.
The menu is broke from what I can tell. It doesn't seem to do anything when I try to enter an option.
It pretty much does nothing, it just loops the menu over and over every 2 seconds without prompting for an entry.
change:
to something like:
Your probably going to have to re-write some of the code to get this to work properly. I suggest that when you do that you also split the code out into functions. It should not let me get as far as it did without connecting to the host. Loops inside of loops inside of loops can get messy. Using functions will allow you to break each loop before moving on to the next easier.
For example
while true do
rednet.send(3,"ping")
sleep(0.5)
local id, message = rednet.receive(10)
if message == "ping" then
print("Connection Established")
else
print("Connection Failed, Retrying")
break <----- this ends the while loop and does not allow it to retry
end
This one for sure needs to be removed, hard to tell on the rest with out being able to fully test the software package.
I can make it all the way into the menu. there are 8 more places you need to change recieve to receive.
The menu is broke from what I can tell. It doesn't seem to do anything when I try to enter an option.
It pretty much does nothing, it just loops the menu over and over every 2 seconds without prompting for an entry.
change:
Spoiler
while true do
sleep(2)
term.clear()
term.setCursorPos(1,1)
print(" Welcome To The Remote Reactor Control Unit")
print("Please Select The Option That Corresponds To You")
print("Start Reactor = 1")
print("Stop Reactor = 2")
print("Start Water = 3")
print("Stop Water = 4")
print("All Stop = 5")
print("Auto Run/Stop = 6")
print("Lights On = 7")
print("Lights Off = 8 ")
print("Check All Reactor Statuses = 9")
print("Back To Mission Control = quit")
sleep(2)
end
to something like:
while true do
sleep(2)
term.clear()
term.setCursorPos(1,1)
print(" Welcome To The Remote Reactor Control Unit")
print("Please Select The Option That Corresponds To You")
print("Start Reactor = 1")
print("Stop Reactor = 2")
print("Start Water = 3")
print("Stop Water = 4")
print("All Stop = 5")
print("Auto Run/Stop = 6")
print("Lights On = 7")
print("Lights Off = 8 ")
print("Check All Reactor Statuses = 9")
print("Back To Mission Control = quit")
local event, k1 = os.pullEvent("key")
if k1 == 2 or k1 == 79 then
option 1 was selected
elseif ......... repeat for each option
else
print ("Invalid Option")
end
end
Your probably going to have to re-write some of the code to get this to work properly. I suggest that when you do that you also split the code out into functions. It should not let me get as far as it did without connecting to the host. Loops inside of loops inside of loops can get messy. Using functions will allow you to break each loop before moving on to the next easier.
For example
Spoiler
function connect()
while true do
rednet.send(3,"ping")
sleep(0.5)
local id, message = rednet.receive(10)
if message == "ping" then
print("Connection Established")
checkreactor()
break
else
print("Connection Failed, Retrying")
end
end
function checkreactor()
code here
end
function mainmenu()
code here
end
Edited on 12 March 2012 - 12:33 AM
Posted 12 March 2012 - 07:01 PM
Ok, thanks I'm trying to get red power to work on my server, but when i finish that then ill fix it, so thank you, and keep looking here every-so-often because i might have more questions.