Jump to content




Please help its annoying me!

turtle computer lua

  • You cannot reply to this topic
14 replies to this topic

#1 Falco

  • Members
  • 33 posts
  • LocationSOMEWHERE 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


#2 Goof

  • Members
  • 751 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.

#3 Falco

  • Members
  • 33 posts
  • LocationSOMEWHERE IN F*%KING MINECRAFT!!!

Posted 23 December 2012 - 09:29 PM

View PostMikk809h, on 23 December 2012 - 09:27 PM, said:

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 :)

#4 Falco

  • Members
  • 33 posts
  • LocationSOMEWHERE IN F*%KING MINECRAFT!!!

Posted 23 December 2012 - 09:31 PM

WAIT!!!! im stil getting an error on line 6..... the "=" is expected...

#5 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 23 December 2012 - 10:23 PM

View PostFalco, on 23 December 2012 - 09:31 PM, said:

WAIT!!!! im stil getting an error on line 6..... the "=" is expected...

Did you add the () to the end of each turtle command?

#6 De Tronazox

  • Members
  • 43 posts
  • LocationSydney, Australia

Posted 23 December 2012 - 10:35 PM

Use () at the end:



function digforward()
turtle.dig()
turtle
.forward()
turtle
.digUp()
end

#7 De Tronazox

  • Members
  • 43 posts
  • LocationSydney, 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()


#8 Falco

  • Members
  • 33 posts
  • LocationSOMEWHERE 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!

#9 jag

  • Members
  • 533 posts
  • LocationStockholm, Sweden

Posted 24 December 2012 - 12:42 AM

View PostMikk809h, on 23 December 2012 - 09:27 PM, said:

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.

#10 Goof

  • Members
  • 751 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 ()

:)

#11 Zambonie

  • Members
  • 477 posts
  • LocationSpring 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!

#12 ChunLing

  • Members
  • 2,027 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.

#13 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 24 December 2012 - 07:22 PM

View PostPAT457, on 24 December 2012 - 06:12 AM, said:

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

#14 ChunLing

  • Members
  • 2,027 posts

Posted 24 December 2012 - 08:00 PM

Well, most browsers allow for those to be disabled.

#15 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 24 December 2012 - 08:01 PM

haha derp. so true





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users