Jump to content




ComputerCraft Error dont know whats wrong


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

#1 Killah1312

  • New Members
  • 1 posts

Posted 17 January 2016 - 04:54 PM

I have a Problem at Time i write a Bios for computercraft and i dont know where the problem is i get the error "startup:295: Expected String"
os.pullEvent = os.pullEventRaw
term.setTextColor(colors.white)
term.clear()
local StFile = nil
local filePath = "system32/kernel/bos/startup"
local fileHandle = fs.open(filePath, 'r')
StFile = textutils.unserialize (fileHandle.readLine(1))
fileHandle.close()
function PKey() --Bootmenu Key
while true do
  local event, key = os.pullEventRaw("key")
 
  if key == keys.f12 then
shell.run("system32/kernel/bos/bios")
    break
  end
end
end
function PInfo() --Prints the Text
-------------
--Erste Zeile
-------------
term.setCursorPos(1,1)
print("_")
sleep(0.1)
term.setCursorPos(1,1)
print(" ")
sleep(0.1)
term.setCursorPos(1,1)
print("_")
sleep(0.1)
term.setCursorPos(1,1)
print(" ")
sleep(0.1)
term.setCursorPos(1,1)
print("_")
sleep(0.1)
term.setCursorPos(1,1)
textutils.slowPrint("CCW-Bios v1.0 press F12 to enter Bootmenu")
sleep(0.1)
term.setCursorPos(42,1)
print("_")
sleep(0.1)
term.setCursorPos(42,1)
print(" ")
sleep(0.1)
term.setCursorPos(42,1)
print("_")
sleep(0.1)
term.setCursorPos(42,1)
print(" ")
sleep(0.1)
term.setCursorPos(42,1)
print("_")
sleep(0.1)
term.setCursorPos(42,1)
print(" ")
--------------
--Zweite Zeile
--------------
term.setCursorPos(1,2)
print("_")
sleep(0.1)
term.setCursorPos(1,2)
print(" ")
sleep(0.1)
term.setCursorPos(1,2)
print("_")
sleep(0.1)
term.setCursorPos(1,2)
print(" ")
sleep(0.1)
term.setCursorPos(1,2)
print("_")
sleep(0.1)
term.setCursorPos(1,2)
textutils.slowPrint("© by Killah1312 2012-2016")
sleep(0.1)
term.setCursorPos(26,2)
print("_")
sleep(0.1)
term.setCursorPos(26,2)
print(" ")
sleep(0.1)
term.setCursorPos(26,2)
print("_")
sleep(0.1)
term.setCursorPos(26,2)
print(" ")
sleep(0.1)
term.setCursorPos(26,2)
print("_")
sleep(0.1)
term.setCursorPos(26,2)
print(" ")
--------------
--Dritte Zeile
--------------
term.setCursorPos(1,4)
print("_")
sleep(0.1)
term.setCursorPos(1,4)
print(" ")
sleep(0.1)
term.setCursorPos(1,4)
print("_")
sleep(0.1)
term.setCursorPos(1,4)
print(" ")
sleep(0.1)
term.setCursorPos(1,4)
print("_")
sleep(0.1)
term.setCursorPos(1,4)
textutils.slowPrint("MC Dual-Core CPU X7223 @1.5GHz")
sleep(0.1)
term.setCursorPos(31,4)
print("_")
sleep(0.1)
term.setCursorPos(31,4)
print(" ")
sleep(0.1)
term.setCursorPos(31,4)
print("_")
sleep(0.1)
term.setCursorPos(31,4)
print(" ")
sleep(0.1)
term.setCursorPos(31,4)
print("_")
sleep(0.1)
term.setCursorPos(31,4)
print(" ")
--------------
--Vierte Zeile
--------------
term.setCursorPos(1,5)
print("_")
sleep(0.1)
term.setCursorPos(1,5)
print(" ")
sleep(0.1)
term.setCursorPos(1,5)
print("_")
sleep(0.1)
term.setCursorPos(1,5)
print(" ")
sleep(0.1)
term.setCursorPos(1,5)
print("_")
sleep(0.1)
term.setCursorPos(1,5)
textutils.slowPrint("DDR3 1600MHz VRAM94866 4096MB")
sleep(0.1)
term.setCursorPos(30,5)
print("_")
sleep(0.1)
term.setCursorPos(30,5)
print(" ")
sleep(0.1)
term.setCursorPos(30,5)
print("_")
sleep(0.1)
term.setCursorPos(30,5)
print(" ")
sleep(0.1)
term.setCursorPos(30,5)
print("_")
sleep(0.1)
term.setCursorPos(30,5)
print(" ")
--------------
--Fünfte Zeile
--------------
term.setCursorPos(1,6)
print("_")
sleep(0.1)
term.setCursorPos(1,6)
print(" ")
sleep(0.1)
term.setCursorPos(1,6)
print("_")
sleep(0.1)
term.setCursorPos(1,6)
print(" ")
sleep(0.1)
term.setCursorPos(1,6)
print("_")
sleep(0.1)
term.setCursorPos(1,6)
textutils.slowPrint("SH37941005 Sata600 HDD Detected")
sleep(0.1)
term.setCursorPos(32,6)
print("_")
sleep(0.1)
term.setCursorPos(32,6)
print(" ")
sleep(0.1)
term.setCursorPos(32,6)
print("_")
sleep(0.1)
term.setCursorPos(32,6)
print(" ")
sleep(0.1)
term.setCursorPos(32,6)
print("_")
sleep(0.1)
term.setCursorPos(32,6)
print(" ")
---------------
--Sechste Zeile
---------------
term.setCursorPos(1,8)
print("_")
sleep(0.1)
term.setCursorPos(1,8)
print(" ")
sleep(0.1)
term.setCursorPos(1,8)
print("_")
sleep(0.1)
term.setCursorPos(1,8)
print(" ")
sleep(0.1)
term.setCursorPos(1,8)
print("_")
sleep(0.1)
term.setCursorPos(1,8)
textutils.slowPrint("Loading PXE-Networkboot Agent...")
sleep(0.1)
term.setCursorPos(33,8)
print("_")
sleep(0.1)
term.setCursorPos(33,8)
print(" ")
sleep(0.1)
term.setCursorPos(33,8)
print("_")
sleep(0.1)
term.setCursorPos(33,8)
print(" ")
sleep(0.1)
term.setCursorPos(33,8)
print("_")
sleep(0.1)
term.setCursorPos(33,8)
print(" ")
sleep(1)
--------------
--Siebte Zeile
--------------
term.setCursorPos(1,9)
print("_")
sleep(0.1)
term.setCursorPos(1,9)
print(" ")
sleep(0.1)
term.setCursorPos(1,9)
print("_")
sleep(0.1)
term.setCursorPos(1,9)
print(" ")
sleep(0.1)
term.setCursorPos(1,9)
print("_")
sleep(0.1)
term.setCursorPos(1,9)
textutils.slowPrint("Exeting PXE-Networkboot Agent...")
sleep(0.1)
term.setCursorPos(33,9)
print("_")
sleep(0.1)
term.setCursorPos(33,9)
print(" ")
sleep(0.1)
term.setCursorPos(33,9)
print("_")
sleep(0.1)
term.setCursorPos(33,9)
print(" ")
sleep(0.1)
term.setCursorPos(33,9)
print("_")
sleep(0.1)
term.setCursorPos(33,9)
print(" ")
sleep(1)
end
parallel.waitForAny(PKey, PInfo)
if fs.exists(StFile) then
term.clear()
shell.run(StFile)
else
term.setCursorPos(1,11)
print("_")
sleep(0.1)
term.setCursorPos(1,11)
print(" ")
sleep(0.1)
term.setCursorPos(1,11)
print("_")
sleep(0.1)
term.setCursorPos(1,11)
print(" ")
sleep(0.1)
term.setCursorPos(1,11)
print("_")
sleep(0.1)
term.setCursorPos(1,11)
textutils.slowPrint("No Bootable System found! Enter Bootmenu to set it!")
PKey()
end
Can someone help me?

#2 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

Posted 17 January 2016 - 06:27 PM

I don't see any problem on line 295, any chance you have accidentally fixed it in copying your code into your post?

Also, fake loading screens are despised on the forums.

Edited by Lupus590, 17 January 2016 - 06:28 PM.


#3 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 17 January 2016 - 07:13 PM

View PostLupus590, on 17 January 2016 - 06:27 PM, said:

Also, fake loading screens are despised on the forums.
Not only that, but the code here code greatly be shortened by using for loops

#4 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 17 January 2016 - 07:20 PM

Lines 4-9
local StFile = nil
local filePath = "system32/kernel/bos/startup"
local fileHandle = fs.open(filePath, 'r')
StFile = textutils.unserialize (fileHandle.readLine(1)) --#My comment here, StFile is now a TABLE.
--#Also, readLine reads only the next line, it doesn't take a line number
fileHandle.close()

Lines 290-292
if fs.exists(StFile) then
term.clear()
shell.run(StFile)
Do you see your problem? You cannot use fs.exists on a table (Or nil, as I suspect it's turning into). It's expecting a string. Don't unserialize an apparent file name.

Edit: I also agree with the above, don't really like fake loading screens. Most games that do have loading screens (I'm meaning like flash games or whatevs) only really use the loading screens as a way to show the user that while it's taking time, it's still progressing. It's doing other stuff than just printing to the screen that it's progressing.

Edited by Dragon53535, 17 January 2016 - 07:48 PM.


#5 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 17 January 2016 - 09:53 PM

View PostTheOddByte, on 17 January 2016 - 07:13 PM, said:

Not only that, but the code here code greatly be shortened by using for loops

For example, this sort of thing:

Spoiler

... can be reduced to:

Spoiler

http://lua-users.org...ructureTutorial

#6 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 19 January 2016 - 12:01 AM

And you could even shorten the second block by using the modulo operator and ternary operators.
for i = 1, 6 do
  term.setCursorPos(33,9)
  print( i % 2 == 0 and " " or "_" )
  sleep(0.1)
end
The only difference with this is that you may want to increase the amount of times to loop.

http://lua-users.org...TernaryOperator





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users