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

Error after conversion

Started by Icepick1982, 15 April 2013 - 09:52 AM
Icepick1982 #1
Posted 15 April 2013 - 11:52 AM
Hi guys,

I am having a problem with my status program.

The program gives a OK when there is room in my chest. When it is full then the status changes to Chest full.

This program works fine in tekkit classic but now i converted my world to tekkit lite and now i just get the following error.

startup:9: attempt to index ? (a nil value)

I hope that someone can figure out what is wrong.

This is my code:

–Colors
–Bone = white | Gunpowder = yellow | Blaze Rod = lightGray | Wool LGray = brown
–Arrow = orange | Rotten Flesh = lime | Ink Sac = cyan | Wool Gray = green
–String = magenta | Ender Pearl = pink | Wool White = purple | Leather = red
–Spider Eye = lightBlue | Slime Ball = gray | Wool Black = blue | Feather = black

while true do

mon = peripheral.wrap("left")
monitor.printM("left", "————Kist Status————-")
monitor.writeM("left", "| Bone - ")
if rs.testBundledInput("back", colors.white) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "| Arrow - ")
if rs.testBundledInput("back", colors.orange) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "| String - ")
if rs.testBundledInput("back", colors.magenta) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "| Spider Eye - ")
if rs.testBundledInput("back", colors.lightBlue) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "| Gunpowder - ")
if rs.testBundledInput("back", colors.yellow) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "| Rotten Flesh - ")
if rs.testBundledInput("back", colors.lime) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "| Ender Pearl - ")
if rs.testBundledInput("back", colors.pink) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "| Slime Ball - ")
if rs.testBundledInput("back", colors.gray) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "| Blaze Rod - ")
if rs.testBundledInput("back", colors.lightGray) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "| Ink Sac - ")
if rs.testBundledInput("back", colors.cyan) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "| Wool White - ")
if rs.testBundledInput("back", colors.purple) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "| Wool Black - ")
if rs.testBundledInput("back", colors.blue) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "| Wool LGray - ")
if rs.testBundledInput("back", colors.brown) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "| Wool Gray - ")
if rs.testBundledInput("back", colors.green) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "| Leather - ")
if rs.testBundledInput("back", colors.red) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "| Feather - ")
if rs.testBundledInput("back", colors.black) == false then
monitor.printM("left", "OK |")
else
monitor.printM("left", "Kist Vol |")
end
monitor.writeM("left", "————————————")
sleep(2)
mon.clear()
mon.setCursorPos(1, 1)
end
Sammich Lord #2
Posted 15 April 2013 - 11:59 AM
You defined "mon" but not "monitor". They are not interchangeable. I also don't know what printM or writeM is.
Icepick1982 #3
Posted 18 April 2013 - 04:52 AM
Tnx i changed monitor in mon so now is everything the same.

But now i get the error startup:9: attempt to call nil

i changed printM in print and writeM in write but the problem is still the same. when i change print in write then i get all the text in one line.
LordIkol #4
Posted 18 April 2013 - 05:03 AM
And the monitor is still on the left side?
And i would put the wrap command, before the while true do.
Not sure if this makes a problem but there is no need to wrap it more than one time
Dlcruz129 #5
Posted 18 April 2013 - 03:23 PM
I believe there is no print function for monitors.
Sammich Lord #6
Posted 18 April 2013 - 03:24 PM
I believe there is no print function for monitors.
Yep, only write. But you can use term.redirect to use print.
Icepick1982 #7
Posted 22 April 2013 - 10:38 AM
Hi guys,

it still does not work.

i changed mon.print to term.redirect but still i get errors.

can someone test the code for me.
MudkipTheEpic #8
Posted 22 April 2013 - 11:07 AM
Allright, here goes.


term.redirect(peripheral.wrap("left")) --Makes printing and stuff go on monitor
print("Test") --Example
term.restore() --Back to terminal
Icepick1982 #9
Posted 23 April 2013 - 02:34 AM
Hi mudkip,

I changed my code and it works fine.

TNX