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

sleep does not seem to yield

Started by dlccmind, 20 July 2013 - 07:13 AM
dlccmind #1
Posted 20 July 2013 - 09:13 AM
Title: sleep does not seem to yield

All my earlier working programs have started crasching with bios:140: Too long without yielding in newer versions of computercraft.
I have tried using sleep in the code but it only seems to delay the problem so they crasch after a few days instead.

So instead of bothering with them I made some test programs to try and find a solution. It boils down to that os.sleep() does not seem to yield, it only delays the problem.
Or I am misunderstanding something here?

If I have a while loop, how do I get it to yield? How long does the sleep have to be in order for it to always work? os.sleep(1) does crasch eventually.

I have gotten a tip about a possible solution, namely to start up an entirely new program and terminate my first one, and transfering data between them by saving on disk. Well, needless to say that is an ugly solution but right now I can't seem to find anything else that works.
Lyqyd #2
Posted 20 July 2013 - 11:12 PM
Split into new topic.

Sleep yields fine. You are doing something wrong. We can't help you fix it unless you post your code and the full error message.
dlccmind #3
Posted 21 July 2013 - 09:05 AM
Here is the code:


n = 0
while true do
   n = n + 1
   print(n)
   os.sleep(0.8)
end

I set up turtles with this program and varied the length of the sleep from 0.1 up to 1.
So far 0.3 has crasched, 0.4 has crasched, 0.7, 0.8 and 0.9 has crasched.

The error message is exactly: "bios:140: Too long without yielding"

So… well, longer sleeps sort of make it work, but not exactly. It takes longer before they crasch. So while putting sleep(1) might seem to work it really doesn't, it just takes an extra day or two before it crasches.

So you might be entirely correct, I might be doing something wrong here. Also tried setting them up as eventdriven and sure, it worked a little longer, but eventually they crasched as well.
Engineer #4
Posted 21 July 2013 - 09:28 AM
With the exact same code I cant seem to reproduce. Try to use the sleep function rather then the os.sleep function. It is very different :P/>
dlccmind #5
Posted 21 July 2013 - 10:41 AM
The more turtles that are up at the same time the greater the chance for crasching. But it can take a while, it might work well for an hour or so. Or 2 seconds. Or 2 days. But with 10 turtles chances are pretty large that at least one of them crasches fast. You say it works but if you have only tried it on one turtle, you have not tried it long enough.

But I am using the tekkit lite pack, could it be a bug with that? 2 friends have the exact same problem, different servers. I'm asking here to be certain we are not doing something wrong in the code. I'll try sleep instead of os.sleep and see if it makes any difference.
albrat #6
Posted 21 July 2013 - 03:13 PM
the sleep() function in CCraft.


function sleep( _nTime )
	local timer = os.startTimer( _nTime )
repeat
  local sEvent, param = os.pullEvent( "timer" )
until param == timer
end
os.sleep() … *laughs*

function os.sleep( _nTime )
sleep( _nTime )
end

Basically it takes the os.sleep and passes it to sleep. so using os.sleep adds a function call to the stack that it does not really need too.

I have 10 computers running at once, I have had a couple of problems with yielding.. it means you have a section of code that runs FAST… and repeatedly.
Lyqyd #7
Posted 21 July 2013 - 04:09 PM
Does tekkit lite use MCPC+?
dlccmind #8
Posted 21 July 2013 - 07:22 PM
I have ran 30+ turtles without problem earlier, almost the exact same program now crasches with 4 turtles. I have peppered the code with sleeps, every loop, every corner, function etc. to try and counter. No difference. Anyway, figures the sleep was called by os.sleep, got the same error now.

No idea if it uses MCPC+ but I'll find out and post here.
dlccmind #9
Posted 21 July 2013 - 07:35 PM
It's not stated in the mod-list in the tekkit lite package version 0.6.5 which we are using.

I saw MCPC+ has a nifty profiler, I would really love to get my hands on something like that for this problem.

But I assume that it is safe to assume that it isn't actually our code that is the problem here but rather a tekkit-lite related bug somewhere. Since the testprogram I gave above should work just fine?
albrat #10
Posted 21 July 2013 - 07:42 PM
pulled from bios.lua

it's the only occurance of coroutine.yeild()

function os.pullEventRaw( _sFilter )
return coroutine.yield( _sFilter )
end
so a pullEventRaw() should work… But the sleep() calls that too.

Can you post a copy of your coding for the turtles.

I also just thought… When you say it errors with "not yielding" do you mean just the one machine or All machines ? If it is all machines it could be another machine that has the error.

If it is a single player game, *** backup your save file. *** Then goto the save / worldname / computer / folder… and replace all your startup files with "os.shutdown()" startup files. ** now make a new computer and see if it works ok… If it works ok. load the startup files back into your save… then see if that one computer works still or crashes.
This will identify if it is a sheer computing capacity limit of CC or just a bit of buggy code.
dlccmind #11
Posted 21 July 2013 - 10:46 PM
Why paste the entire code for the turtles when the example up there doesn't work and exhibit the same behaviour? If I Take the code up there, put it on 10 turtles, wait for 24 hours. A random selection of them will have crasched with the bios:140 error. More likely on the ones with shorter sleep. If you wait long enough all of them will have crasched. At least on me and my friends machines. They seem to crasch one at a time at random.

But, should a sleep(1) be enough? Maybe I need sleep(5)? Anyone know what is reasonable here? I tend to find 1 second quite an eternity when it comes to programming but then again Lua is not my language, I come from Asm and C.

Thank you for your tip about several computers. I think I will do this, destroy all the computers utterly from the server. Make a new one, single computer, only computer in the game world. Run the script above and see if it crasches eventually.

It is a multiplayer linuxserver running ubuntu and tekkit-lite. Fairly powerful, lots of ram and no lag, just 3 players on them and the problem was there from the start so no one had put up any funky machinery at the time either. Two of my friends also has a server running the same version of tekkit-lite, one on windows and the other on Linux, they have the same problem. (One of them resorted to some scheme of the program starting itself up again and terminating the original one over and over, transfering data using a file.)

So, not all machines crasch at once. I can't imagine someone never noticed this before so I think it might be confined to tekkit-lite for some reason, or maybe people just never run turtles for extended periods of time? Don't know.

Thank you for your help anyway, time for some more experiments :)/>
Lyqyd #12
Posted 21 July 2013 - 11:19 PM
Why paste the entire code for the turtles when the example up there doesn't work and exhibit the same behaviour?

Because, as I told you at the beginning, I can't help you debug code I haven't seen. Either you're doing something wrong, or you're working with a version of MC that doesn't work correctly (like MCPC+). If we eliminate the code, we can be sure that it's a problem with Tekkit. You see, I haven't had any problems with long-running programs failing to yield over time. There's nothing in the ComputerCraft code that would cause such problems, so the problem is either Tekkit or your code, which we still haven't seen.
dlccmind #13
Posted 22 July 2013 - 12:45 AM
The code I posted up there, I tried that EXACT code, and it didn't work longer than a couple of hours.
albrat #14
Posted 22 July 2013 - 05:42 AM
I looked in the bios.lua file at lines 138 - 142


function write( sText )
local w,h = term.getSize() 
local x,y = term.getCursorPos()

you are crashing on the local w,h = term.getSize()
in bios.lua according to that. (could you try and find your computercraft folder on the server, normally in %APPDATA%/.techniclauncher/tekkit-lite/mods/Computercraft/lua/bios.lua )

could you paste the contents of your bios.lua here , as my CC bios.lua is different to my tekkit bios.lua (in tekkit the bios.lua line 140 is blank but bang in the middle of "char" and "key" pull events )

knowing the bios.lua contents will help us identify the point of the error.
LBPHacker #15
Posted 22 July 2013 - 05:59 AM
-snip-
When you get a "too long without yielding" error, the line number doesn't tell you anything. The error occured because LuaJ though the coroutine haven't been yielded for too long, not because the line in the error message thrown an error. In case of a TLWY, the line number is irrelevant.
EDIT: Well, it tells you that the line in the error message was the last line executed before the error occured.
dlccmind #16
Posted 22 July 2013 - 07:32 AM
This is my servers bios.lua

And if more code than the example above REALLY is necessary then the excavateprogram that comes along with Computercraft crasches the same way. Tried starting up 4 of those, 1 managed to actually finish.


--[[
-- Install safe versions of various library functions
-- These will not put cfunctions on the stack, so don't break serialisation
xpcall = function( _fn, _fnErrorHandler )
local typeT = type( _fn )
assert( typeT == "function", "bad argument #1 to xpcall (function expected, got "..typeT..")" )
local co = coroutine.create( _fn )
local tResults = { coroutine.resume( co ) }
while coroutine.status( co ) ~= "dead" do
  tResults = { coroutine.resume( co, coroutine.yield() ) }
end
if tResults[1] == true then
  return true, unpack( tResults, 2 )
else
  return false, _fnErrorHandler( tResults[2] )
end
end
pcall = function( _fn, ... )
local typeT = type( _fn )
assert( typeT == "function", "bad argument #1 to pcall (function expected, got "..typeT..")" )
local tArgs = { ... }
return xpcall(
  function()
   return _fn( unpack( tArgs ) )
  end,
  function( _error )
   return _error
  end
)
end
function pairs( _t )
local typeT = type( _t )
if typeT ~= "table" then
  error( "bad argument #1 to pairs (table expected, got "..typeT..")", 2 )
end
return next, _t, nil
end
function ipairs( _t )
local typeT = type( _t )
if typeT ~= "table" then
  error( "bad argument #1 to ipairs (table expected, got "..typeT..")", 2 )
end
return function( t, var )
  var = var + 1
  local value = t[var]
  if value == nil then
   return
  end
  return var, value
end, _t, 0
end
function coroutine.wrap( _fn )
local typeT = type( _fn )
if typeT ~= "function" then
  error( "bad argument #1 to coroutine.wrap (function expected, got "..typeT..")", 2 )
end
local co = coroutine.create( _fn )
return function( ... )
  local tResults = { coroutine.resume( co, ... ) }
  if tResults[1] then
   return unpack( tResults, 2 )
  else
   error( tResults[2], 2 )
  end
end
end
function string.gmatch( _s, _pattern )
local type1 = type( _s )
if type1 ~= "string" then
  error( "bad argument #1 to string.gmatch (string expected, got "..type1..")", 2 )
end
local type2 = type( _pattern )
if type2 ~= "string" then
  error( "bad argument #2 to string.gmatch (string expected, got "..type2..")", 2 )
end

local nPos = 1
return function()
  local nFirst, nLast = string.find( _s, _pattern, nPos )
  if nFirst == nil then
   return
  end
  nPos = nLast + 1
  return string.match( _s, _pattern, nFirst )
end
end
]]

local nativesetmetatable = setmetatable
function setmetatable( _o, _t )
if _t and type(_t) == "table" then
  local idx = rawget( _t, "__index" )
  if idx and type( idx ) == "table" then
   rawset( _t, "__index", function( t, k ) return idx[k] end )
  end
  local newidx = rawget( _t, "__newindex" )
  if newidx and type( newidx ) == "table" then
   rawset( _t, "__newindex", function( t, k, v ) newidx[k] = v end )
  end
end
return nativesetmetatable( _o, _t )
end
-- Install lua parts of the os api
function os.version()
if turtle then
  return "TurtleOS 1.5"
end
return "CraftOS 1.5"
end
function os.pullEventRaw( _sFilter )
return coroutine.yield( _sFilter )
end
function os.pullEvent( _sFilter )
local eventData = { os.pullEventRaw( _sFilter ) }
if eventData[1] == "terminate" then
  error( "Terminated", 0 )
end
return unpack( eventData )
end
-- Install globals
function sleep( _nTime )
	local timer = os.startTimer( _nTime )
repeat
  local sEvent, param = os.pullEvent( "timer" )
until param == timer
end
function write( sText )
local w,h = term.getSize()
local x,y = term.getCursorPos()

local nLinesPrinted = 0
local function newLine()
  if y + 1 <= h then
   term.setCursorPos(1, y + 1)
  else
   term.setCursorPos(1, h)
   term.scroll(1)
  end
  x, y = term.getCursorPos()
  nLinesPrinted = nLinesPrinted + 1
end

-- Print the line with proper word wrapping
while string.len(sText) > 0 do
  local whitespace = string.match( sText, "^[ \t]+" )
  if whitespace then
   -- Print whitespace
   term.write( whitespace )
   x,y = term.getCursorPos()
   sText = string.sub( sText, string.len(whitespace) + 1 )
  end

  local newline = string.match( sText, "^\n" )
  if newline then
   -- Print newlines
   newLine()
   sText = string.sub( sText, 2 )
  end

  local text = string.match( sText, "^[^ \t\n]+" )
  if text then
   sText = string.sub( sText, string.len(text) + 1 )
   if string.len(text) > w then
	-- Print a multiline word  
	while string.len( text ) > 0 do
	 if x > w then
	  newLine()
	 end
	 term.write( text )
	 text = string.sub( text, (w-x) + 2 )
	 x,y = term.getCursorPos()
	end
   else
	-- Print a word normally
	if x + string.len(text) - 1 > w then
	 newLine()
	end
	term.write( text )
	x,y = term.getCursorPos()
   end
  end
end

return nLinesPrinted
end
function print( ... )
local nLinesPrinted = 0
for n,v in ipairs( { ... } ) do
  nLinesPrinted = nLinesPrinted + write( tostring( v ) )
end
nLinesPrinted = nLinesPrinted + write( "\n" )
return nLinesPrinted
end
function printError( ... )
if term.isColour() then
  term.setTextColour( colours.red )
end
print( ... )
term.setTextColour( colours.white )
end
function read( _sReplaceChar, _tHistory )
term.setCursorBlink( true )
	local sLine = ""
local nHistoryPos = nil
local nPos = 0
	if _sReplaceChar then
  _sReplaceChar = string.sub( _sReplaceChar, 1, 1 )
end

local w, h = term.getSize()
local sx, sy = term.getCursorPos()

local function redraw( _sCustomReplaceChar )
  local nScroll = 0
  if sx + nPos >= w then
   nScroll = (sx + nPos) - w
  end
  
  term.setCursorPos( sx, sy )
  local sReplace = _sCustomReplaceChar or _sReplaceChar
  if sReplace then
   term.write( string.rep(sReplace, string.len(sLine) - nScroll) )
  else
   term.write( string.sub( sLine, nScroll + 1 ) )
  end
  term.setCursorPos( sx + nPos - nScroll, sy )
end

while true do
  local sEvent, param = os.pullEvent()
  if sEvent == "char" then
   sLine = string.sub( sLine, 1, nPos ) .. param .. string.sub( sLine, nPos + 1 )
   nPos = nPos + 1
   redraw()
  
  elseif sEvent == "key" then
	  if param == keys.enter then
	-- Enter
	break
  
   elseif param == keys.left then
	-- Left
	if nPos > 0 then
	 nPos = nPos - 1
	 redraw()
	end
  
   elseif param == keys.right then
	-- Right  
	if nPos < string.len(sLine) then
	 nPos = nPos + 1
	 redraw()
	end
  
   elseif param == keys.up or param == keys.down then
				-- Up or down
	if _tHistory then
	 redraw(" ");
	 if param == keys.up then
	  -- Up
	  if nHistoryPos == nil then
	   if #_tHistory > 0 then
		nHistoryPos = #_tHistory
	   end
	  elseif nHistoryPos > 1 then
	   nHistoryPos = nHistoryPos - 1
	  end
	 else
	  -- Down
	  if nHistoryPos == #_tHistory then
	   nHistoryPos = nil
	  elseif nHistoryPos ~= nil then
	   nHistoryPos = nHistoryPos + 1
	  end	
	 end
	
	 if nHistoryPos then
					 sLine = _tHistory[nHistoryPos]
					 nPos = string.len( sLine )
					else
	  sLine = ""
	  nPos = 0
	 end
	 redraw()
				end
   elseif param == keys.backspace then
	-- Backspace
	if nPos > 0 then
	 redraw(" ");
	 sLine = string.sub( sLine, 1, nPos - 1 ) .. string.sub( sLine, nPos + 1 )
	 nPos = nPos - 1	
	 redraw()
	end
   elseif param == keys.home then
	-- Home
	nPos = 0
	redraw()
   elseif param == keys.delete then
	if nPos < string.len(sLine) then
	 redraw(" ");
	 sLine = string.sub( sLine, 1, nPos ) .. string.sub( sLine, nPos + 2 )  
	 redraw()
	end
   elseif param == keys["end"] then
	-- End
	nPos = string.len(sLine)
	redraw()
   end
  end
end

term.setCursorBlink( false )
term.setCursorPos( w + 1, sy )
print()

return sLine
end
loadfile = function( _sFile )
local file = fs.open( _sFile, "r" )
if file then
  local func, err = loadstring( file.readAll(), fs.getName( _sFile ) )
  file.close()
  return func, err
end
return nil, "File not found"
end
dofile = function( _sFile )
local fnFile, e = loadfile( _sFile )
if fnFile then
  setfenv( fnFile, getfenv(2) )
  return fnFile()
else
  error( e, 2 )
end
end
-- Install the rest of the OS api
function os.run( _tEnv, _sPath, ... )
	local tArgs = { ... }
	local fnFile, err = loadfile( _sPath )
	if fnFile then
		local tEnv = _tEnv
		--setmetatable( tEnv, { __index = function(t,k) return _G[k] end } )
  setmetatable( tEnv, { __index = _G } )
		setfenv( fnFile, tEnv )
		local ok, err = pcall( function()
		 fnFile( unpack( tArgs ) )
		end )
		if not ok then
		 if err and err ~= "" then
		  printError( err )
		 end
		 return false
		end
		return true
	end
	if err and err ~= "" then
  printError( err )
end
	return false
end
local nativegetmetatable = getmetatable
local nativetype = type
local nativeerror = error
function getmetatable( _t )
if nativetype( _t ) == "string" then
  nativeerror( "Attempt to access string metatable", 2 )
  return nil
end
return nativegetmetatable( _t )
end
local tAPIsLoading = {}
function os.loadAPI( _sPath )
local sName = fs.getName( _sPath )
if tAPIsLoading[sName] == true then
  printError( "API "..sName.." is already being loaded" )
  return false
end
tAPIsLoading[sName] = true

local tEnv = {}
setmetatable( tEnv, { __index = _G } )
local fnAPI, err = loadfile( _sPath )
if fnAPI then
  setfenv( fnAPI, tEnv )
  fnAPI()
else
  printError( err )
		tAPIsLoading[sName] = nil
  return false
end

local tAPI = {}
for k,v in pairs( tEnv ) do
  tAPI[k] =  v
end

_G[sName] = tAPI
tAPIsLoading[sName] = nil
return true
end
function os.unloadAPI( _sName )
if _sName ~= "_G" and type(_G[_sName]) == "table" then
  _G[_sName] = nil
end
end
function os.sleep( _nTime )
sleep( _nTime )
end
local nativeShutdown = os.shutdown
function os.shutdown()
nativeShutdown()
while true do
  coroutine.yield()
end
end
local nativeReboot = os.reboot
function os.reboot()
nativeReboot()
while true do
  coroutine.yield()
end
end
-- Install the lua part of the HTTP api (if enabled)
if http then
local function wrapRequest( _url, _post )
  local requestID = http.request( _url, _post )
  while true do
   local event, param1, param2 = os.pullEvent()
   if event == "http_success" and param1 == _url then
	return param2
   elseif event == "http_failure" and param1 == _url then
	return nil
   end
  end
end

http.get = function( _url )
  return wrapRequest( _url, nil )
end
http.post = function( _url, _post )
  return wrapRequest( _url, _post or "" )
end
end
-- Install the lua part of the peripheral api
peripheral.wrap = function( _sSide )
if peripheral.isPresent( _sSide ) then
  local tMethods = peripheral.getMethods( _sSide )
  local tResult = {}
  for n,sMethod in ipairs( tMethods ) do
   tResult[sMethod] = function( ... )
	return peripheral.call( _sSide, sMethod, ... )
   end
  end
  return tResult
end
return nil
end
  
-- Load APIs
local tApis = fs.list( "rom/apis" )
for n,sFile in ipairs( tApis ) do
if string.sub( sFile, 1, 1 ) ~= "." then
  local sPath = fs.combine( "rom/apis", sFile )
  if not fs.isDir( sPath ) then
   os.loadAPI( sPath )
  end
end
end
if turtle then
local tApis = fs.list( "rom/apis/turtle" )
for n,sFile in ipairs( tApis ) do
  if string.sub( sFile, 1, 1 ) ~= "." then
   local sPath = fs.combine( "rom/apis/turtle", sFile )
   if not fs.isDir( sPath ) then
	os.loadAPI( sPath )
   end
  end
end
end
-- Run the shell
local ok, err = pcall( function()
parallel.waitForAny(
  function()
   os.run( {}, "rom/programs/shell" )
  end,
  function()
   rednet.run()
  end )
end )
-- If the shell errored, let the user read it.
if not ok then
printError( err )
end
pcall( function()
term.setCursorBlink( false )
print( "Press any key to continue" )
os.pullEvent( "key" )
end )
os.shutdown()

albrat #17
Posted 22 July 2013 - 07:45 AM
I have 18 computers running this program


while true do
sleep(0.1)
end
plus all my normal computers running. (CC os ver 1.4) admittedly my memory usage is flying up to 1.5 gb and back down to 800 Mb alot, processor is running at 45% for the java process.
(been running since my last post without stopping). about 2 hours. real time.

none have crashed out.
dlccmind #18
Posted 22 July 2013 - 07:47 AM
This is one of my warehouse managers that crasches eventually but works for some days:


--- Warehouse in version 1.3
rednet.open("top")
whaccID = 0
repeat
   rednet.broadcast("whin")
   SenderID, mess, dist = rednet.receive(10)
   if mess == "whacc" then
	  whaccID = SenderID
   end
until mess == "whacc"
repeat
   rednet.send(whaccID,"OK")
   SenderID, mess, dist = rednet.receive(1)
until (mess == "OK") and (SenderID == whaccID)  
print("connected")
oldBottom = rs.getBundledInput("bottom")
oldBack = rs.getBundledInput("back")
oldRight = rs.getBundledInput("right")
oldLeft = rs.getBundledInput("left")
while true do
   event, p1, p2 = os.pullEvent()
   if event == "redstone" then
	  cBottom = rs.getBundledInput("bottom")
	  cBack = rs.getBundledInput("back")
	  cRight = rs.getBundledInput("right")
	  cLeft = rs.getBundledInput("left")			  
	  if cBottom ~= oldBottom then		
		 col = 1
		 for n=1,16 do
		    if (colors.test(cBottom, col) == true) and (colors.test(oldBottom, col) == false) then
			   --- Pinne n har ny signal
			   --- print("Pinne ",n)
			   rednet.send(whaccID, tostring(n))
		    end
		    col = col * 2
		 end
		 oldBottom = cBottom
	  end
	  if cBack ~= oldBack then
		 col = 1
		 for n=1,16 do
		    if (colors.test(cBack, col) == true) and (colors.test(oldBack, col) == false) then
			   --- Pinne n har ny signal
			   --- print("Pinne ",n+16)
			   rednet.send(whaccID, tostring(n+16))
		    end
		    col = col * 2
		 end
		 oldBack = cBack
	  end
	  if cRight ~= oldRight then
		 col = 1
		 for n=1,16 do
		    if (colors.test(cRight, col) == true) and (colors.test(oldRight, col) == false) then
			   --- Pinne n har ny signal
			   --- print("Pinne ",n+48)
			   rednet.send(whaccID, tostring(n+48))
		    end
		    col = col * 2
		 end
		 oldRight = cRight
	  end
	  if cLeft ~= oldLeft then
		 col = 1
		 for n=1,16 do
		    if (colors.test(cLeft, col) == true) and (colors.test(oldLeft, col) == false) then
			   --- Pinne n har ny signal
			   --- print("Pinne ",n+32)
			   rednet.send(whaccID, tostring(n+32))
		    end
		    col = col * 2
		 end
		 oldLeft = cLeft
	  end
   end
end


And the account program for it


--- Warehouse account version 1.3
rednet.open("top")
whinID = 0
itemnames = {}
amounts = {}
maxamount = 2322432
totalamount = 0
local f1 = io.open("files/itemnames","r")
local sLine = f1:read()
while sLine do
   table.insert(itemnames,sLine)
   sLine = f1:read()  
end
f1:close()
local f2 = io.open("files/amounts","r")
local sLine = f2:read()
while sLine do
   table.insert(amounts,tonumber(sLine))
   sLine = f2:read()
end
f2:close()
function saveamounts()
   local f3 = io.open("files/amounts", "w")
   for n=1,64 do
	  f3:write(tostring(amounts[n]) .. "\n")
   end
   f3:close()
end
repeat
   SenderID, mess, dist = rednet.receive(10)
   if mess == "whin" then
	  whinID = SenderID
   end
until mess == "whin"
repeat
   rednet.send(whinID, "whacc")
   SenderID, mess, dist = rednet.receive(2)
   if mess == "OK" then
	  rednet.send(whinID, "OK")
   end
until mess == "OK"
print("connected")
--- print("Starting timer")
local longwait = os.startTimer(60)
local shortwait
while true do
   local event, p1, p2, p3, p4 = os.pullEvent()
   if event == "rednet_message" then
	  if p1 == whinID then
		 local n = tonumber(p2)
		 amounts[n] = amounts[n] + 1
		 --- print(itemnames[n], " ", amounts[n])
	  end
   end
   if event == "timer" then
	  if p1 == longwait then
		 --- print("Longwait")
		 rs.setOutput("bottom", true)
		 longwait = os.startTimer(60)
		 shortwait = os.startTimer(5)
	  elseif p1 == shortwait then
		 --- print("Shortwait")
		 print("Saving")
		 saveamounts()
		 totalamount = 0
		 for n=1,64 do
		    totalamount = totalamount + amounts[n]
		 end
		 print(totalamount, " of ", maxamount, " filled. ",math.floor((totalamount/maxamount)*100),"% full.")
		 rs.setOutput("bottom", false)
	  end
   end
   if event == "char" then
	  if p1 == "q" then
		 for n=1,16 do
		    print(amounts[n], " ", itemnames[n])
		 end
	  elseif p1 == "w" then
		 for n=17,32 do
		    print(amounts[n], " ", itemnames[n])
		 end
	  elseif p1 == "e" then
		 for n=33,48 do
		    print(amounts[n], " ", itemnames[n])
		 end
	  elseif p1 == "r" then
		 for n=49,64 do
		    print(amounts[n], " ", itemnames[n])
		 end
	  end
   end
end

Here is a watermill towerbuilder I made that crasched the same way sometimes:


function putmill()
   if turtle.getItemCount(2) < 1 then
	  turtle.select(3)
   else
	  turtle.select(2)
   end
   sleep(0.5)
   turtle.place()
end
function putmills()
   putmill()
   turtle.turnRight()
   putmill()
   turtle.turnRight()
   putmill()
   turtle.turnRight()
   putmill()
   turtle.turnRight()
end
--while turtle.getFuelLevel() < 80 do
--   turtle.select(5)
--   turtle.refuel()
--   sleep(0.5)
--end
for n=1,39 do
   turtle.down()
   sleep(0.5)
end
turtle.select(2)
turtle.placeDown()
for n=1,19 do
   putmills()
   turtle.up()
   turtle.select(1)
   turtle.placeDown()
   turtle.up()
   turtle.select(1)
   turtle.placeDown()
   sleep(0.5)
end
turtle.up()
turtle.select(4)
turtle.placeDown()


Is more examples required?
dlccmind #19
Posted 22 July 2013 - 07:48 AM
Thank you albrat, I am convinced this is a tekkit bug somewhere. It really should work. That program crasches on average way faster than 2 hours for me, and with 18 of them almost instantly.
dlccmind #20
Posted 22 July 2013 - 10:37 AM
If no one has any more suggestions I think this thread might as well be locked. I will keep trying to find the solution to this but more in the way of checking updates for tekkit-lite, mod compatibility and so on. I'm not sure if anyone else has this problem but I could post a solution somewhere on the forum if I find a way to get this working short of throwing out tekkit-lite, it might help someone. An update is coming soon so I just hope that will fix it.

Thank you all for your help!
Regards / Mikael
dlccmind #21
Posted 29 July 2013 - 05:29 PM
Well, I never found out exactly why this bug appeared, but ditching tekkit-lite and putting together a new modpack myself sure helped. No problem what so ever with newest computercraft and 1.6.2 minecraft and other various mods that support 1.6.2. Same server, same computers, same programs. Works flawlessly now so I can not conclude other than that tekkit-lite somehow is to blame. Thats all folks.
Cozzimoto #22
Posted 30 July 2013 - 09:16 AM
and as for a new modpack, go with FTB, forge has been updated where you no longer have to mess with the minecraft jar file anymore and makes adding mods to minecraft that much easier
Edited by