X3ME, on 20 November 2014 - 09:37 PM, said:
So far everyone has just been speculating as to what the problem could be, please tell us
exactly what is 'not working' so that we can further assist you. Is there an error message, or does it just not behave as expected? if it's an error, what is the full error message? if it's not running as expected, what do you expect it to do, and what does it actually do? we need more information to assist you better.
valithor, on 20 November 2014 - 10:35 PM, said:
The first thing that stands out to me is where you define the rsevent() function on line 11. This function is defined in the middle of a while loop which is something you should not/ can not do. This function should be defined above the while true do loop.
this is possible to do within Lua, can you assign variables inside a while loop? yes you can. So why would assigning a function to a variable suddenly be something you cannot do. The following code works perfectly fine!
while true do
function a()
print("hi")
end
a()
sleep(0)
end
yes it's not exactly efficient, you're recreating the function each time the loop runs, but it is still perfectly valid code.
Dog, on 20 November 2014 - 11:01 PM, said:
3. I also noticed that you are calling rsevent() from within rsevent() - this can cause the program to keep spawning more and more instances of rsevent() until the computer crashes (I don't know if there's a recursive or memory limit in CC).
Yes there is a recursive limit in ComputerCraft, that's the cause of the stack overflow error.
valithor, on 26 November 2014 - 12:05 AM, said:
Don't know if this one is only in CC
No,
a stack overflow isn't exclusive to ComputerCraft.