This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
CrazyTech13's profile picture

Function Not Ending...

Started by CrazyTech13, 09 October 2013 - 12:54 PM
CrazyTech13 #1
Posted 09 October 2013 - 02:54 PM
Topic: Function Not Ending…

I'm making a desktop program that has a login and a menu and you scroll through it, but the function that doesn't close is the one that prints the scrolling arrow. I am a novice at this sort of stuff so I would love any help you could give me.

P.S. I'm not sure if I was supposed to post the whole argument here; I'm new :P/>
jamd315 #2
Posted 09 October 2013 - 04:39 PM
First, you should post your code. No one is going to steal it.
Next,
  1. Do you have an os.pullEvent() hung up somewhere?
  2. Is there a loop not working correctly?
  3. If you have a loop dependent on a variable, is the variable functioning properly?
Seriously though, post some code. ;)/>
Engineer #3
Posted 09 October 2013 - 05:29 PM
You can wait for multiple events. Check this tutorial out. And let us know if you get stuck again ;)/>

By the way, posting your code is a good habit if you have a question about your code :P/>
CrazyTech13 #4
Posted 09 October 2013 - 05:33 PM
Lol, well here's my code :P/>

function checkScroll6()

if Scroll == 6 then
term.setBackgroundColor(RColor)
term.setCursorPos(12,12)
term.write(">")
term.setBackgroundColor(colors.red)
term.setCursorPos(13,12)
term.write(" ")

else
term.setBackgroundColor(RColor)
term.setCursorPos(12,12)
term.write(" ")
term.setBackgroundColor(colors.green)
term.setCursorPos(13,12)
term.write(" ")

end

RColor is defined as black. So I have a function that waits for the player input and defines the Scroll variable. The function then goes through a series of functions just like this one, after a player input. This is the last of that series and it goes back to that function I mentioned earlier: Select(). I tried some other things such as putting an end after both the if and the else, I tried putting only one end after both, I tried elseif Scroll ~= 6 then instead of else, and as a last resort I tried spamming ends at the end of the function :P/>

Anyways, my point is that the function won't end, and I would appreciate help. :)/>
nobody1717 #5
Posted 09 October 2013 - 05:37 PM
you only have one end, and that end is ending the 'if scroll == 6'
you also have to have an end for the function, or else it won't close, as you have experienced.
CrazyTech13 #6
Posted 10 October 2013 - 05:48 AM
Wow, thanks. :3 It's just I tried that already and it didn't work, but the other functions didn't close and I didn't sop to read the error, I assumed it was for that one function, then I got confused, and yeah. So all my functions close now, and thank you so much! :D/>