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

Emmh help with lua please

Started by Kasea, 18 August 2012 - 06:38 PM
Kasea #1
Posted 18 August 2012 - 08: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
sjele #2
Posted 18 August 2012 - 08:41 PM

for 1 = 1, 29 do  --Idk if this makes it do 30.
  turtle.placeUp()
  turtle.forward()
end
Kasea #3
Posted 19 August 2012 - 12:11 AM
WOW FAST reply FTW :(/>/>

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

also the error code: http://prntscr.com/e0u53
Cranium #4
Posted 19 August 2012 - 12:50 AM
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
Kasea #5
Posted 19 August 2012 - 01:47 AM
Works thx a lot can be closed now :D/>/>
Matrixmage #6
Posted 19 August 2012 - 06: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.
Kasea #7
Posted 19 August 2012 - 07:40 AM
still watching :D/>/>

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

well i'll try and stick with the easiest ways :P/>/>
immibis #8
Posted 19 August 2012 - 01: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)