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

Computer pulls errors after running loops for a while

Started by cowman001, 20 September 2012 - 11:29 PM
cowman001 #1
Posted 21 September 2012 - 01:29 AM
See attached picture for error.
i have a computer running a loop to show my rules at spawn, ive even placed a world anchor next to it, it runs fine if someone is near it but if you leave it like pulls these errors, heres my code.

Startup

shell.run("monitor", "top", "rules")

rules

os.pullEvent = os.pullEventRaw
term.clear()
term.setCursorPos(1,1)

print("Welcome to IndusCraft!\nRules:\n1.Griefing is allowed\n2.Stealing is allowed\n3.Their will be no rollbacks!\n4.Respect the staff and they will respect you. Sept, for\n  Waterman he's a dick.")
sleep(10)
term.clear()
term.setCursorPos(1,1)
print("\nIf you have a specialty in a specific mod in tekkit, you\n can let the owner\n or admin know of the mod you specialize in and we may\n give you a tag relating to that mod.\nThen sometime in the future you may help a player with\n that mod.\nYou must now build/make something in you'r mod that you\n are good at to prove that you deserve the spot.")
sleep(10)
term.clear()
term.setCursorPos(1,1)
print("\nWe also recommend that you use Sphax texture pack for\n tekkit.\nIf you have a slow computer, get Sphax 64/32 bit.")
sleep(5)
term.clear()
term.setCursorPos(1,1)
print("\nBanned items:\n Tnt can not be placed.\n Nukes can not be crafted.\n Nova Catalysts can't be made.\n Dynamite can not be made/used. \n World Anchors can not be made/placed.\n Energy Collectors,\n Red morningstars,\n Red katars,\n Automatic Crafting tables,\n and teleport tubes can not be crafted.\n\n ENERGY CONDENSERS ARE NOT BANNED.")
sleep(15)
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("\nRebooting")
sleep(3)
shell.run "startup"
MysticT #2
Posted 21 September 2012 - 01:31 AM
That's because you're not making a loop (well, it's a loop, but not the correct way to do it), you're running your program over and over, wich overflows the stack.
Try using a real loop:

while true do
  -- print rules here
end
cowman001 #3
Posted 21 September 2012 - 02:01 AM
how do i reset the stack? for future reference?
cowman001 #4
Posted 21 September 2012 - 02:15 AM
this is the new code but it says right where the first mon.print is its pulling an error, attempt to call nil..


local mon = peripheral.wrap("top")
while true do
mon.print("Welcome to IndusCraft!nRules:n1.Griefing is allowedn2.Stealing is allowedn3.Their will be no rollbacks!n4.Respect the staff and they will respect you. Sept, forn  Waterman he's a dick.")
sleep(10)
mon.clear()
mon.setCursorPos(1,1)
mon.print("nIf you have a specialty in a specific mod in tekkit, youn can let the ownern or admin know of the mod you specialize in and we mayn give you a tag relating to that mod.nThen sometime in the future you may help a player withn that mod.nYou must now build/make something in you'r mod that youn are good at to prove that you deserve the spot.")
sleep(10)
mon.clear()
mon.setCursorPos(1,1)
mon.print("nWe also recommend that you use Sphax texture pack forn tekkit.nIf you have a slow computer, get Sphax 64/32 bit.")
sleep(5)
mon.clear()
mon.setCursorPos(1,1)
mon.print("nBanned items:n Tnt can not be placed.n Nukes can not be crafted.n Nova Catalysts can't be made.n Dynamite can not be made/used. n World Anchors can not be made/placed.n Energy Collectors,n Red morningstars,n Red katars,n Automatic Crafting tables,n and teleport tubes can not be crafted.nn ENERGY CONDENSERS ARE NOT BANNED.")
sleep(15)
mon.clear()
mon.setCursorPos(1,1)
mon.print("N	 NONE OF THIS --->	 :3n	   DO IT AND BE BANNED!")
sleep(7)
mon.clear()
mon.setCursorPos(1,1)
mon.print("nRebooting")
sleep(3)
end
MrBarry #5
Posted 21 September 2012 - 02:29 AM
Unfortunately there's no print function for monitors, and mon.write() does not recognize \n
The workaround is term.redirect(<monitor reference>)
Example

mon = peripheral.wrap("top")
term.redirect(mon)
while true do
  print("Welcome to IndusCraft!\nRules:\n1.Griefing is allowed\n2.Stealing is allowed\n3.Their will be no rollbacks!\n4.Respect the staff and they will respect you. Sept, for\n  Waterman he's a dick.")
  sleep(10)
  ...
  other stuff
  ...
end
term.restore()
Fatal_Exception #6
Posted 21 September 2012 - 07:13 AM
See this thread for information about the stack.