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

Can someone help me with this turtleprogram?

Started by malleusmintaka, 02 June 2015 - 01:01 PM
malleusmintaka #1
Posted 02 June 2015 - 03:01 PM
Im relatively new to CC and I try to get some programs, this is more or less my first.


The purpose of the program is to place a variable amout of blocks in the shape of a rectangle.
I know that the autorefill is not in there, but my problem right now is, that it turns itself around on the same block or that it builds an interesting construct, but either way it doesnt work right.


local arg1,arg2,arg3,arg4 = ...
  write "length="
  print (arg1)
  write "width="
  print (arg2)
  write "height="
  print (arg3)

fwdvar = tonumber(arg1)
sdevar = tonumber(arg2)
hgtvar = tonumber(arg3)
hgt = 0
while hgt < hgtvar do
fwd = 1
while fwd < fwdvar do
  turtle.select(5)
  turtle.placeDown()
  turtle.forward()
  fwd = fwd + 1
end
turtle.turnRight()
sde = 1
while sde < sdevar do
  turtle.placeDown()
  turtle.forward()
  sde = sde + 1
end
turtle.turnRight()
fwd = 1
while fwd < fwdvar do
  turtle.placeDown()
  turtle.forward()
  fwd = fwd + 1
end
turtle.turnRight()
sde = 1
while sde < sdevar do
  turtle.placeDown()
  turtle.forward()
  sde = sde + 1
end
turtle.up()
turtle.turnRight()
hgtvar = hgtvar +1
end

(sorry,if there is a spoiler thing, I cant find it)

~ malleusmintaka
Lupus590 #2
Posted 02 June 2015 - 03:40 PM
What do you mean by "doesn't work right"?
Describe what it does that you think isn't correct.
KingofGamesYami #3
Posted 02 June 2015 - 04:02 PM
You may want to look into for loops. They make this sort of thing much easier.

Aside from that, a picture of what it does do vs what you want it to do would be helpful.
malleusmintaka #4
Posted 02 June 2015 - 05:51 PM
it rotates at this block the whole time, the other thing I cant recreate


@KingofGamesYami Where exactly would you place a loop?
flaghacker #5
Posted 02 June 2015 - 06:46 PM
Does your turtle have fuel?
malleusmintaka #6
Posted 02 June 2015 - 06:57 PM
I pla with FTB Ulti, dont know the CC version, but i dont need fuels there afaik
flaghacker #7
Posted 02 June 2015 - 06:59 PM
Try typing this into your turtle:


> lua
> turtle.forward()

Does the turtle go forward?
malleusmintaka #8
Posted 02 June 2015 - 07:11 PM
nop. it returns false
TechedZombie #9
Posted 02 June 2015 - 07:39 PM
Then you need fuel

Put something you can burn in the turtles inventorty like coal and then type refuel or in a program or Command Prompt call turtle.refuel(Amount)
malleusmintaka #10
Posted 02 June 2015 - 07:51 PM
But why did it work withotu fuel then?
Dragon53535 #11
Posted 02 June 2015 - 07:56 PM
Try typing this instead. Because I'm not so sure you do need fuel. Since the lua prompt didn't say that you needed fuel and only said false.

lua
turtle.getFuelLevel()
Say what that tells you
malleusmintaka #12
Posted 02 June 2015 - 08:01 PM
it tells me 0, before i needed no fuel though
Dragon53535 #13
Posted 02 June 2015 - 08:08 PM
Server probably changed the config then. Since it does say 0, then you do need fuel. Get something that you can put in a furnace for fuel and put it in the turtle, and then type refuel.
malleusmintaka #14
Posted 02 June 2015 - 08:15 PM
well, now it just places the first row of blocks :/
Bomb Bloke #15
Posted 03 June 2015 - 12:43 AM
And then what does it do? Run out of blocks to place?
malleusmintaka #16
Posted 03 June 2015 - 11:48 AM
no, it runs arond crazy, but could fix it, it works now, thanks for the help!