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

Attempt to index ? (a function value)

Started by Digtokiller, 18 April 2012 - 06:17 AM
Digtokiller #1
Posted 18 April 2012 - 08:17 AM
Hello.
I am creating a system that allows you to control unlimited turtles from one controlpanel.
Now resently i had a problem with wireless transmission only reaching 50 blocks :)/>/>

So i decided to place my OS on a turtle and add moving commands.
Here is the problem, it comes with an error.

startup:238: Attempt to index ? (a function value)

at line 238 there is "turtle.forward()"

now i tried to terminate the system and run "go forward 1" and get about the same error.

go:8: Attempt to index ? (a function value)

If i delete my startup and run the go command again it works, so i assume the problem is inside my code, and i have checked and double check but i can't find the problem :)/>/>

The code is available here: http://pastebin.com/eJiq6sTc

Can anyone tell me where and what in my code is messing with ComputerCraft?
Luanub #2
Posted 18 April 2012 - 08:36 AM
For starters you can increase your modem range in your CC config file.

I don't really see any errors in the code but lets try a couple of things and see if they will help.
First try replacing the go in your for loops with something else. I like to just simply use x.
Second remove the second local when you are working on your vars so..

For Loop:

if direction==1 then
        for x=1,distance do
            turtle.forward()
        end

Local Var

local distance=read()
distance=tonumber(distance)

Not sure if either of these are the problem. I'm getting ready to head home and if this doesn't help i will dig deeper when I get there.
Digtokiller #3
Posted 18 April 2012 - 10:48 AM
i know that i can change it local, but i can't change it on every server i am joining.

i will try your suggestions.
Cloudy #4
Posted 18 April 2012 - 12:32 PM
The issue is that you create a function called "turtle" which overwrites the turtle table. Change the name of that function.
Digtokiller #5
Posted 18 April 2012 - 01:08 PM
thanks, the issue was the "turtle" function :)/>/>