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

"Menue" Error: "Too long without Yielding

Started by vali11, 19 March 2013 - 04:57 AM
vali11 #1
Posted 19 March 2013 - 05:57 AM
I get this Error when i use this Code: "Too long without Yielding".

function Menue()
local Angabe1 = "1.Stock"
local Angabe2 = "2.Stock"
local Message1 = "Der Aufzug wird nun in den 1. Stock fahren"
local Message2 = "der Aufzug wird nun in den 2.Stock fahren"
local l = 1
 while true do
 if l == 1 then
 shell.run(clear)
 term.setCursorPos(1,2)
 print("[",Angabe1,"]")
 term.setCursorPos(1, 4)
 print(Angabe2)
 else
  shell.run(clear)
  term.setCursorPos(1, 2)
  print(Angabe1)
  term.setCursorPos(1, 4)
  print("[",Angabe2,"]")
  end
 end


a, b = os.pullevent()
 while a ~= "key" do
 sleep(0.1)
 a, b = os.pullevent()
 end
 if b == 208 and l == 1 then l = 2 end
 if b == 200 and l == 2 then l = 1 end
 if b == 28 then print() end
 if l == 1 then
 shell.run(clear)
  term.setCursorPos(1,1)
  print(Message1)
  end
 if l == 2 then
  shell.run(clear)
  term.setCursorPos(1,1)
  print(Message2)
  end
end

shell.run(clear)
Menue()
 
Lyqyd #2
Posted 19 March 2013 - 07:39 AM
Split into new topic.
Engineer #3
Posted 19 March 2013 - 08:35 AM
Check this tutorial out:
Too long without yielding
vali11 #4
Posted 20 March 2013 - 02:51 AM
oke, thanks. Now there is nor Error, but the programm doesnt work yet. :/ any tips? Code is now:
shell.run("clear")
Angabe1 = "1.Stock"
Angabe2 = "2.Stock"
Message1 = "Der Aufzug wird nun in den 1. Stock fahren"
Message2 = "der Aufzug wird nun in den 2.Stock fahren"
l = "1"
 while true do
 sleep(0)
 if l == "1" then
 shell.run(clear)
 term.setCursorPos(1,2)
 print("[",Angabe1,"]")
 term.setCursorPos(1, 4)
 print(Angabe2)
 sleep(0)
 else
  shell.run(clear)
  term.setCursorPos(1, 2)
  print(Angabe1)
  term.setCursorPos(1, 4)
  print("[",Angabe2,"]")
  sleep(0)
  end
 end
 

a, b = os.pullevent()
 while a ~= "key" do
 sleep(0)
 a, b = os.pullevent()
 end
 if b == "208" and l == "1" then l = "2" end
 if b == "200" and l == "2" then l = "1" end
 if b == "28" then print() end
 if l == "1" then
 shell.run(clear)
  term.setCursorPos(1,1)
  print(Message1)
  sleep(0)
  end
 if l == "2" then
  shell.run(clear)
  term.setCursorPos(1,1)
  print(Message2)
  sleep(0)
  end
PixelToast #5
Posted 20 March 2013 - 03:16 AM
error messages would have been nice

shell.run("clear")
local Angabe1 = "1.Stock"
local Angabe2 = "2.Stock"
local Message1 = "Der Aufzug wird nun in den 1. Stock fahren"
local Message2 = "der Aufzug wird nun in den 2.Stock fahren"
local l = "1"
while true do
    if l == "1" then
        shell.run("clear")
        term.setCursorPos(1,2)
        write("[",Angabe1,"]")
        term.setCursorPos(1, 4)
        print(Angabe2)
    else
        shell.run("clear")
        term.setCursorPos(1, 2)
        write(Angabe1)
        term.setCursorPos(1, 4)
        write("["..Angabe2.."]")
    end
    local a, b = os.pullevent("key")
    if b == "208" and l == "1" then l = "2" end
    if b == "200" and l == "2" then l = "1" end
    if b == "28" then print() end
    if l == "1" then
        shell.run("clear")
        term.setCursorPos(1,1)
        write(Message1)
    end
    if l == "2" then
        shell.run(clear)
        term.setCursorPos(1,1)
        write(Message2)
    end
    a=os.pullEvent("key")
    while a~=28 then -- press enter
        a=os.pullEvent("key")
    end
end
this still problably wont do what you want