Jump to content




Emmh help with lua please


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

#1 Kasea

  • Members
  • 12 posts

Posted 18 August 2012 - 07:38 PM

Okey, so i though i was getting good at this...

boy was i wrong xD

okey so i got 2 questions :(/>

1: can someone make me a script that does this: go 29 blocks forward while placing blocks under (the turtle.forward turtle.placeDown) or something, but i do not know how to loop correctly... but you'll see that soon

2: http://prntscr.com/e0h9v

well that's the error :)/> tried googelin but nothing ...

also here's the code: http://prntscr.com/e0hao

#2 sjele

  • Members
  • 334 posts
  • LocationSomewhere on the planet called earth

Posted 18 August 2012 - 07:41 PM

for 1 = 1, 29 do  --Idk if this makes it do 30.
  turtle.placeUp()
  turtle.forward()
end


#3 Kasea

  • Members
  • 12 posts

Posted 18 August 2012 - 11:11 PM

WOW FAST reply FTW :(/>

anywho seemed to not work ;P but can you explain it?

also the error code: http://prntscr.com/e0u53

#4 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 18 August 2012 - 11:50 PM

You want this instead. sjele was close:
for i = 1,29 do -- yes it will loop until it hits 29
turtle.placeDown()
turtle.forward()
print(i) --will print the number it's at.
end


#5 Kasea

  • Members
  • 12 posts

Posted 19 August 2012 - 12:47 AM

Works thx a lot can be closed now :D/>

#6 Matrixmage

  • Members
  • 116 posts
  • LocationAt my Computer coding for the Computer in my Computer

Posted 19 August 2012 - 05:51 AM

Even though I don't think your watching this, you can use while and have the movement run in a function, like this:

i = 0

function countUpAndMove()

turtle.placeDown()
turtle.forward()
i = i + 1

end

while i >= 29 do
countUpAndMove()
end

it could allow you to have the moving / counting called multiple times by different pieces of code.

#7 Kasea

  • Members
  • 12 posts

Posted 19 August 2012 - 06:40 AM

still watching :D/>

mhm... seemed like more complex :P/>

well i'll try and stick with the easiest ways :P/>

#8 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 19 August 2012 - 12:12 PM

By the way, the "__add on nil and number" was because you forgot the space between "local" and "i", so instead you assigned 1 to the variable "locali" (instead of making "i" local and assigning 1 to it)





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users