Hi guys I have been running this script as a startup for a long time:
http://pastebin.com/UVJ46frp
Now all of a sudden I have gotten the error:
Java Exception Thrown:
java.lang.UnsupportedOperationException
I have recently added Peripheralls ++ to my Computercraft is this a problem in my code or is it with the game this has popped up on other scripts as well.
0
2 replies to this topic
#1
Posted 01 May 2015 - 02:44 PM
#2
Posted 01 May 2015 - 03:09 PM
The only part I can see that might cause problems is this:
...Because you open a file, then close it without doing anything. I doubt it'd cause an error though.
Considering this happens with other scripts, I'd guess it's a problem with Peripherals++
local file = fs.open(harvestedFile,"a") file.close()
...Because you open a file, then close it without doing anything. I doubt it'd cause an error though.
Considering this happens with other scripts, I'd guess it's a problem with Peripherals++
#3
Posted 01 May 2015 - 11:37 PM
In fact, you could replace this whole block:
... with:
You'd also want to make the turtle sleep on a regular basis. Currently it sleeps for five seconds if it decides it's harvest time, or if it decides it's planting time; while the crop is growing, it never sleeps, instead spamming turtle.inspect() as fast as it can.
It is possible that the error stems from your attempt to perform addition with a string. Lua usually lets you get away with that, but who knows.
You could always spread print statements throughout your script in order to figure out the exact line triggering the error.
Exactly what are you trying to turtle.inspect()?
harvested = {} local file = fs.open(harvestedFile,"a") file.close() local file = fs.open(harvestedFile,"r") local line = file.readLine() repeat table.insert(harvested,line) until line == nil file.close() x = harvested[1] + 1 local file = fs.open(harvestedFile,"w") file.writeLine(x) file.close() print(x)
... with:
local x = 1 if fs.exists(harvestedFile) then local file = fs.open(harvestedFile,"r") x = tonumber(file.readLine()) + 1 file.close() end local file = fs.open(harvestedFile,"w") file.writeLine(x) file.close() print(x)
You'd also want to make the turtle sleep on a regular basis. Currently it sleeps for five seconds if it decides it's harvest time, or if it decides it's planting time; while the crop is growing, it never sleeps, instead spamming turtle.inspect() as fast as it can.
It is possible that the error stems from your attempt to perform addition with a string. Lua usually lets you get away with that, but who knows.
You could always spread print statements throughout your script in order to figure out the exact line triggering the error.
Exactly what are you trying to turtle.inspect()?
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users