Jump to content




[question][error] - yielding


  • You cannot reply to this topic
2 replies to this topic

#1 tesla1889

  • Members
  • 351 posts
  • LocationSt. Petersburg

Posted 01 July 2012 - 08:59 PM

is there a way to force a yield? no matter what i do with this code segment, i always end up with a bios:25: too long without yielding

i4 = 0
for i3 = 1,1398 do
for i1 = (i4 + 1),(i4 + 6000) do
  local t1 = bit.tobits(i1)
  while #t1 < 32 do
  table.insert(t1,0)
  end
  s1 = ""
  s2 = ""
  for i2 = 1,32 do
   s1 = s1..t1[i2]
   s2 = s2.."0"
  end
  t1 = {}
  table.insert(t1,s1)
  table.insert(t1,s2)
  table.insert(mem,t1)
end
i4 = i4 + 6000
sleep(0.01)
end
sleep(0.01)
for i1 = (i4 + 1),(i4 + 608) do
local t1 = bit.tobits(i1)
while #t1 < 32 do
table.insert(t1,0)
end
s1 = ""
s2 = ""
for i2 = 1,32 do
  s1 = s1..t1[i2]
  s2 = s2.."0"
end
t1 = {}
table.insert(t1,s1)
table.insert(t1,s2)
table.insert(mem,t1)
end

Edit: solved. it didn't like the 32 bits for some reason, so i changed it to 16 and scaled back the process to 16-bit and it worked.

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 01 July 2012 - 09:55 PM

Yeah, somewhere in your ridiculously-many-iterations loops, put a sleep(0) call. Might need to be sleep(0.1), but the first should work.

#3 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 01 July 2012 - 10:04 PM

I don't know what you'r trying to do, but the simplest way would be to use a function like:
local function yield()
  os.queueEvent("fake")
  os.pullEvent("fake")
end
That way, it will yield but won't wait for an event.

EDIT:
lol, didn't even think about using sleep :P/>.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users