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

MagicTurtle API having issues

Started by vegasera, 07 August 2012 - 11:33 PM
vegasera #1
Posted 08 August 2012 - 01:33 AM
Tried installing the MagicTurtle API, and now I have this error when I try to start up the turtle.

bios:206: [string "magicturtle"]:45: ')' expected


This is lines 44-46 in the API


addPath = function(self,state)
table.insert(vertexPaths[self.ID],#vertexPaths[self.ID] 1,state)
end,


where's the issue?
Pharap #2
Posted 08 August 2012 - 04:52 AM
is this Lua or Java? If it's Java, you might want to put a Java tag on it
Lyqyd #3
Posted 08 August 2012 - 05:10 AM
It's lua.

OP, usually close paren errors usually indicate an unbalanced open paren much earlier in the file.
vegasera #4
Posted 08 August 2012 - 09:35 AM
Even with the tip and scouring over it for about an hour, I haven't been able to find the issue. I suppose it just takes a more trained mind. Since it was just copy and paste, I'm not sure why no one else seems to be having this issue. I pasted the file on my server in /mods/computercraft/lua/rom/apis/turtle/

http://pastebin.com/Yt1u8zAu

It would be greatly appreciated.

This is also the page it was on originally. http://www.computerc...ng-exploration/

——
Edit, noticed something bizarre…. There's meant to be a + sign before the 1 in line 45. I also checked throughout the script and every time there was meant to be a +, it was missing in the serverside file.

After uploading it again and checking it while it's in txt format, it's fine. If I remove the extension the +s go away again. Leaving the txt extension seems to make things work.

I appreciate the help on this.
Edited on 08 August 2012 - 08:16 AM
Pharap #5
Posted 08 August 2012 - 06:08 PM
I always though APIs for computercraft were coded in Java. If I'm wrong, I'd like to know how to create and install a lua API to help me out.

Seeing the code, it looks like you never close the curly brace on vertex= on line 26. Comparing it to how node is set out, node has an end curly brace after it's final end, but line 73 where vertex's should be is missing.

Also, where the # symbol is, it gets the length of a string in bytes.
I'm not sure why you are trying to add 1 to the length of a string in bytes,
but I'm guessing what you're trying to do is add 1 to an ID number, in which case the # symbol conflicts

On top of which, according to the lua index, since vertexPaths[self.ID] refers to an item in the table and not the table itself, # converts it to nil.
Also, with insert, the first argument is a table, you (again) have used vertexPaths[self.ID], referring to an item, not a table.

So try switching out vertexPaths[self.ID] with vertexPaths until you get it working.

I hope this helps.
Cranium #6
Posted 08 August 2012 - 07:18 PM
Even with the tip and scouring over it for about an hour, I haven't been able to find the issue. I suppose it just takes a more trained mind. Since it was just copy and paste, I'm not sure why no one else seems to be having this issue. I pasted the file on my server in /mods/computercraft/lua/rom/apis/turtle/

http://pastebin.com/Yt1u8zAu

It would be greatly appreciated.

This is also the page it was on originally. http://www.computerc...ng-exploration/

——
Edit, noticed something bizarre…. There's meant to be a + sign before the 1 in line 45. I also checked throughout the script and every time there was meant to be a +, it was missing in the serverside file.

After uploading it again and checking it while it's in txt format, it's fine. If I remove the extension the +s go away again. Leaving the txt extension seems to make things work.

I appreciate the help on this.
If you are using the default Notepad program for Windows, I suggest upgrading to Notepad ++. It's free, and it actually keeps all of the formatting that you copy into it, and numbers all of the lines so you know where you done messed up… Give it a try, just search it in Google!
Matrixmage #7
Posted 08 August 2012 - 08:32 PM
Even with the tip and scouring over it for about an hour, I haven't been able to find the issue. I suppose it just takes a more trained mind. Since it was just copy and paste, I'm not sure why no one else seems to be having this issue. I pasted the file on my server in /mods/computercraft/lua/rom/apis/turtle/

http://pastebin.com/Yt1u8zAu

It would be greatly appreciated.

This is also the page it was on originally. http://www.computerc...ng-exploration/

——
Edit, noticed something bizarre…. There's meant to be a + sign before the 1 in line 45. I also checked throughout the script and every time there was meant to be a +, it was missing in the serverside file.

After uploading it again and checking it while it's in txt format, it's fine. If I remove the extension the +s go away again. Leaving the txt extension seems to make things work.

I appreciate the help on this.
If you are using the default Notepad program for Windows, I suggest upgrading to Notepad ++. It's free, and it actually keeps all of the formatting that you copy into it, and numbers all of the lines so you know where you done messed up… Give it a try, just search it in Google!

I second that, Notepad ++ is an amazing tool for any coder, never leave home without one ;)/>/>

(sorry for the useless post)
vegasera #8
Posted 09 August 2012 - 01:46 AM
I was using Notepad++, it is quite good.

The problem was when I removed the extension in the server files, so I could do anything ingame (there's problems when you try to use magicturtle.txt.forward() in the lua interpreter)

the problem was fixed when I removed the extension before uploading.