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

Edit Error

Started by GyroW, 24 October 2013 - 12:05 PM
GyroW #1
Posted 24 October 2013 - 02:05 PM
Hello,
I encountered these 2 errors in the standard edittor while i was testing out string.sub for a calculator i'm working on.

1. When i press "Down key" -> edit:404: attemp to call nil
2. And when i click -> edit:590: attempt to call nil

–Specs
Computercraft 1.5.2
Miscperipherals 1.5.2
Openperipheral 1.5.2
Ftb unleashed 1.5.2
SMP

Sorry for no pictures

Edit: I didn't change anything about the edit code. This isn't a coding problem really.
Lyqyd #2
Posted 24 October 2013 - 02:28 PM
Of course it's a problem with your code. Post your calculator code so we can tell you what you've overwritten with a nil value.
GyroW #3
Posted 24 October 2013 - 02:30 PM
Oh… :/
Its basicly:

math = "Math 1+2"
print(string.sub(math, 5))
Lyqyd #4
Posted 24 October 2013 - 02:33 PM
The variable named math contains a table of functions [like math.min()], so you are overwriting and destroying that table. Use a different variable name. You should probably also make it a local variable:


local myString = "Math 1 + 2"
GyroW #5
Posted 24 October 2013 - 03:00 PM
Thank you