33 posts
Location
SOMEWHERE IN F*%KING MINECRAFT!!!
Posted 23 December 2012 - 09:10 PM
Okay first off thanks for looking at my post, okay I'm trying to avoid the "LONG" turtle commands for my programs so I decided to create functions insted, example:
function digforward()
turtle.dig
turtle.forward
turtle.digUp
end
Now I'm new to ComputerCraft and I cant understand why this wouldn't work…?
Heres my full code thats in my file currently and im getting the error: '=' expected on line 6.
Spoiler
-- Written by Falco.
-- ******* basic moving functions ******* --
function forward()
turtle.forward
end
function turnleft()
turtle.turnLeft
end
function turnright()
turtle.turnRight
end
function digforward()
turtle.dig
turtle.forward
turtle.digUp
end
-- ******* end of basic moving functions ******* --
digforward()
767 posts
Posted 23 December 2012 - 09:27 PM
All apis, requirres two () parantheses after the function.it tells you, that it think turtle.dig is a variable, but there is no variable in it..
Just remember the parantheses in the end of all your turtle commands.
33 posts
Location
SOMEWHERE IN F*%KING MINECRAFT!!!
Posted 23 December 2012 - 09:29 PM
All apis, requirres two () parantheses after the function.it tells you, that it think turtle.dig is a variable, but there is no variable in it..
Just remember the parantheses in the end of all your turtle commands.
I can't belive i missed those… DERP delete this post if needed its a waste of time and thank you very much my good sir :)/>
33 posts
Location
SOMEWHERE IN F*%KING MINECRAFT!!!
Posted 23 December 2012 - 09:31 PM
WAIT!!!! im stil getting an error on line 6….. the "=" is expected…
2088 posts
Location
South Africa
Posted 23 December 2012 - 10:23 PM
WAIT!!!! im stil getting an error on line 6….. the "=" is expected…
Did you add the () to the end of each turtle command?
40 posts
Location
Sydney, Australia
Posted 23 December 2012 - 10:35 PM
Use () at the end:
function digforward()
turtle.dig()
turtle.forward()
turtle.digUp()
end
40 posts
Location
Sydney, Australia
Posted 23 December 2012 - 10:36 PM
The whole code done:
-- Written by Falco.
-- ******* basic moving functions ******* --
function forward()
turtle.forward()
end
function turnleft()
turtle.turnLeft()
end
function turnright()
turtle.turnRight()
end
function digforward()
turtle.dig()
turtle.forward()
turtle.digUp()
end
-- ******* end of basic moving functions ******* --
digforward()
33 posts
Location
SOMEWHERE IN F*%KING MINECRAFT!!!
Posted 23 December 2012 - 11:55 PM
Thanks for the help guys i relised what the problem was i was saving it to the wrong file so changes i was making wasnt changing when i ran it on the PC HERP A DERP DERP!
521 posts
Location
Stockholm, Sweden
Posted 24 December 2012 - 12:42 AM
All apis, requirres two () parantheses after the function.it tells you, that it think turtle.dig is a variable, but there is no variable in it..
Just remember the parantheses in the end of all your turtle commands.
If I'm not incorrect about this, then isn't almost everything a form of a variable?
For example
-- Tables
local myTable = {
somthing = "nothing",
someone = "noone",
}
local newTable = myTable
-- Variables
local myVariable = "foo"
local newVariable = myVariable
-- Functions
local function myFunc()
print("good")
print("morning")
print("mr cucumber")
end
local newFunc = myFunc
-- A nice combination, tables + functions
local moves = {
up = turtle.up
down = turtle.down
left = turtle.turnLeft
right = turtle.turnRight
}
-- Playing though the table
for id,value in pairs(moves) do
moves[id]()
end
In the example of tables + functions, you could maybe figure out that this is the same way the (for example turtle) functions are grouped.
767 posts
Posted 24 December 2012 - 01:24 AM
yes it is, but in the way the OP did it it is not… because he didnt make any variable to that turtle command… he just forgot to make the two parantheses at the end ()
:)/>
604 posts
Location
Spring Hill, Fl
Posted 24 December 2012 - 06:12 AM
I poroly could tell you the answer,but my computer wont let me open the spoiler!
2005 posts
Posted 24 December 2012 - 07:12 PM
Or rather, Lua always expects you to do something with a variable. The default assumption is that you are going to assign it a value (from another variable, a function, or an operation). But you can also call them if they contain functions, which is what was intended in this case.
1548 posts
Location
That dark shadow under your bed...
Posted 24 December 2012 - 07:22 PM
I poroly could tell you the answer,but my computer wont let me open the spoiler!
what browser are you using? it probably doesn't support the script used to open the spoiler
EDIT: they are using javascript and of course CSS. if your browser doesn't support those then I really don't know where you got that from
2005 posts
Posted 24 December 2012 - 08:00 PM
Well, most browsers allow for those to be disabled.
1548 posts
Location
That dark shadow under your bed...
Posted 24 December 2012 - 08:01 PM
haha derp. so true