135 posts
Posted 25 June 2015 - 10:40 PM
rednet.open("back")
term.setBackgroundColor(colors.blue)
term.clear()
term.setCursorPos(1,1);
print("Please Insert Disk")
InsertGUI = true;
--]] Draw GUI [[--
function update()
if(fs.isDir("disk"))then
error("h")
end
end
function menuLoop()
while InsertGUI do
update()
end
end
menuLoop()
run and screens black then says too long without yelding then prints the screen?
3790 posts
Location
Lincoln, Nebraska
Posted 25 June 2015 - 10:51 PM
Moved to Ask a Pro
135 posts
Posted 25 June 2015 - 10:53 PM
im done with cc too many frustrating glitches, im just done cc has changed my life for the worst, goodbye
2427 posts
Location
UK
Posted 25 June 2015 - 11:01 PM
too long without yielding
Yield protection is a ComputerCraft-specific issue, due to the nature of the Java side handling of the Lua environment for the computers. This message means that your program has run for ten seconds without yielding, which usually means you have an infinite loop that is constantly running. You can fix this simply by adding a sleep(0), but it's better to determine how often your code actually needs to run and use an os.pullEvent() to wait for the events it needs. For instance, a loop which looks at changes in redstone state could include an os.pullEvent("redstone") to wait for changes in redstone state before iterating through the loop again.
http://www.computerc...king-questions/im done with cc too many frustrating glitches, im just done cc has changed my life for the worst, goodbye
Slow down, are you sure that these "glitches" are not protection features? For example, this issue is caused by the prevention of monopolization of the lua VM.
Edited on 25 June 2015 - 09:05 PM
1220 posts
Location
Earth orbit
Posted 25 June 2015 - 11:33 PM
I second Lupus590's suggestion - slow down before you give up. Programming in any language can be a persnickety thing…patience is key. Understanding the problem is an important step in figuring out how to correct it; Lupus590 has your back on that. So just slow down a bit and take another whack at it with some input here in Ask A Pro.
My first question to you is, what exactly are you expecting the program to do as it appears in the OP? I can guess based on the code, but I'd like to know what *you* expect from it first.
For future reference I suggest reading through
this thread - don't forget the sections labeled 'Posting a Good Question' and 'Getting Help Faster' near the bottom - those really help us help you.
135 posts
Posted 25 June 2015 - 11:50 PM
too long without yielding
Yield protection is a ComputerCraft-specific issue, due to the nature of the Java side handling of the Lua environment for the computers. This message means that your program has run for ten seconds without yielding, which usually means you have an infinite loop that is constantly running. You can fix this simply by adding a sleep(0), but it's better to determine how often your code actually needs to run and use an os.pullEvent() to wait for the events it needs. For instance, a loop which looks at changes in redstone state could include an os.pullEvent("redstone") to wait for changes in redstone state before iterating through the loop again.
http://www.computerc...king-questions/im done with cc too many frustrating glitches, im just done cc has changed my life for the worst, goodbye
Slow down, are you sure that these "glitches" are not protection features? For example, this issue is caused by the prevention of monopolization of the lua VM.
eh, i fixed the issue. frustrating enough to make me rq though been trying to fix for atleast a whole hour. haven't coded in lua in a while so im a little rusty
I second Lupus590's suggestion - slow down before you give up. Programming in any language can be a persnickety thing…patience is key. Understanding the problem is an important step in figuring out how to correct it; Lupus590 has your back on that. So just slow down a bit and take another whack at it with some input here in Ask A Pro.
My first question to you is, what exactly are you expecting the program to do as it appears in the OP? I can guess based on the code, but I'd like to know what *you* expect from it first.
For future reference I suggest reading through
this thread - don't forget the sections labeled 'Posting a Good Question' and 'Getting Help Faster' near the bottom - those really help us help you.
code adapted to
rednet.open("back")
term.setBackgroundColor(colors.black)
term.clear()
term.setCursorPos(1,1)
print("[Disk Registration] - Waiting For Disk..")
function genKey()
ownKey = math.random(1000000,9999999)
end
while true do
local ev, side = os.pullEvent()
if(ev == "disk" or fs.isDir("disk") )then
genKey()
rednet.send(2, "check")
rednet.send(2, ownKey)
sid, cd = rednet.receive(2)
if(cd)then
if(not fs.exists("disk/.regkey"))then
f = fs.open("disk/.regkey", "w")
f.writeLine(ownKey)
f.close()
rednet.send(2, "Register")
rednet.send(2, ownKey)
print("Created Reg Disk!")
end
elseif(cd == nil)then
print("Connection to server failed!")
disk.eject("top")
else
genKey();
end
end
end
basically i was trying to make a keycard - server side system