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

help with a simple program plz :D

Started by monkeybee11, 23 December 2012 - 09:40 AM
monkeybee11 #1
Posted 23 December 2012 - 10:40 AM
really new to lua and me just want a digging turtle to spam dig in till all 16 slots are full then turn to the left and dump in inv in to a chest and loop back to the start D: its for a snowfarm :P/>

sry if this is in the wrong spot
Goof #2
Posted 23 December 2012 - 12:39 PM
Our job on this section/forum is not to code for you. Its fo
r explaining why your code does not work. , or if you Are having some questions. You can try, looking at the tutorials section, if you want a Nice tutorial on how to do the specific thing.

(I dont mean that you have to find errors out yourself. Thats why we Are here :D/>/>/>)

And: did you look at the pinned topic with Nice beginner tutorials? I think you would find that topic interresting.


tell us what you've got so far, and then we can help you.
monkeybee11 #3
Posted 23 December 2012 - 12:48 PM
tbh me dont know where to start me have watched tut by sethbling and me know how to use the turtle.dig() turtle.turn() in the lua thingy but me dont know if me have to do like a i = 1 or something at the start D: me know the basic of programing in lua but dont know how to make a program yet
Goof #4
Posted 23 December 2012 - 12:56 PM
Well. When digging until a turtles inventory is full, requirres a while loop


turtle.select(1) -- selects slot 1.
While turtle.getItemCount(16) < 64 do -- if 16th slot is full then
-- do your turtle digs one block, and moves forward.
turtle.dig() -- dig block in front of the turtle
turtle.forward() -- moves forward
turtle.digUp() -- digs up.
end 



that will dig until its 16th slot is full

this only checks if the inv is full. If its not full, it will mine a 1x2 wide and heigth tunnel.
monkeybee11 #5
Posted 23 December 2012 - 01:24 PM
ok thx so all me have to do is remove the move and it will basicly do what me want then just have to add a if full turn left dump in chest right? (snow stacks to 16)

ok me have not tested this in game but this is the code that me want right?

turtle.select(1) -- selects slot 1.
While turtle.getItemCount(16) < 16 do -- if 16th slot is full then
-- do your turtle digs one block, and moves forward.
turtle.dig() -- dig block in front of the turtle
If turtle.getItemCount(16) = 16 do
   turtle.turnLeft(1) --face chest
   sleep(1)
   turtle.placeall() -- puts snowballs in chest
if turtle.getItemCount(16) < 16
   turtle.turnRight() -- face snowman
end 
Goof #6
Posted 24 December 2012 - 12:15 AM
This is your code, improved a bit, (and hopefully no errors…)

Before making a program its good to know what the things you need is named or called.. on that way the most people dont get messed up.
:)/>
And remember that Lua does not know what a Capital START letter is.
If with a big "I" will cause an error because lua doesnt know the capital If. (this is mostly only if you use statements, for loops etc..)



turtle.select(1)
  while turtle.getItemCount(16) < 16 do
	turtle.dig()
	turtle.forward()
	turtle.digUp()
  end -- When the inventory is full it will end this, so AFTER this end you have to turn around to the chest, drop off, and then make a snowman...

turtle.turnLeft()-- dont use Arguments in the movement... that will cause errors... -- this will turn around to the chest...
sleep(1) -- sleeps one second.
  for i = 1, 16 do -- make a for loop, that selects each slot in the turtles inv, and then drop the slots, one by one...
	turtle.select(i) -- selects the I which counts all the slots...
	turtle.drop() -- drops the slot into the chest... (Remember here, that turtle.placeAll, doesnt exists, so you have to use turtle.drop()
  end
turtle.turnRight() -- faces to the snowman / farm


The code is not tested, but it should work.
monkeybee11 #7
Posted 24 December 2012 - 12:43 AM
ok thanks …but tbh me got no clue what a Capital START means XD will test the code after me clean my pets out :P/>

wait a min y is tehere foward? the turtle dont have to move foward it just has to spam dig then turn to the chest then turn back to the snow man S: thats the reason y me removed the foward in that while loop u gave me befor S:

turtle.select(1)
  while turtle.getItemCount(16) < 16 do
	turtle.dig()
  end -- When the inventory is full it will end this, so AFTER this end you have to turn around to the chest, drop off, and then make a snowman...

turtle.turnLeft()-- dont use Arguments in the movement... that will cause errors... -- this will turn around to the chest...
sleep(1) -- sleeps one second.
  for i = 1, 16 do -- make a for loop, that selects each slot in the turtles inv, and then drop the slots, one by one...
	turtle.select(i) -- selects the I which counts all the slots...
	turtle.drop() -- drops the slot into the chest... (Remember here, that turtle.placeAll, doesnt exists, so you have to use turtle.drop()
  end
turtle.turnRight() -- faces to the snowman / farm

ther was a bug with the turtle.foward bc there is a snowman right in front of it so me removed turtle.foward() and tutle.digUp()
and it was working but
when it inv is full up it says
bios:133: Expected number
what dose that mean
forgot to put a 1 in sleep() :P/> it working now :D/> is there a way to put a loop at the end of the program so me wont have to keep giving it the comarnd after it puts the snow in the chest ?
Goof #8
Posted 24 December 2012 - 12:50 AM
yeah.. dont read the capital START.. in that way i just meaned that you may not start
if statements
for loops
while loops
etc, with a capital start letter like this:
If statements
For loops
While loops – theese 3 is wrong…
monkeybee11 #9
Posted 24 December 2012 - 02:26 AM
ok gonna take me a bit to understand that not the sharpest tool in the shead ya know :P/>
and how u make crafty turtles craft? the plan was to make the turtle dig the snow and pipe it form teh chest in to a auto crafting table then me thort y not make a digging crafty turtle and make the blocks befor placing them in the chest have been looking at the wiki but using the lua inturpter it keeps saying something a bout string and attempted to call nil S:
makerimages #10
Posted 24 December 2012 - 03:02 AM
We need precise error statements.

A quick translating(idunno if you need this)

String- text between" Example: "I am a string"
Real- numbers
Nil- some sort of value needed, but got nothing


I asssume your error is somethinlike this::

Program: line linenr string expected, got nil. It means that in Program on line linenr it needed a string but didnt got a thing
Goof #11
Posted 24 December 2012 - 03:10 AM
crafty turtles =

XCT
XXX
XXX

X = empty
C = crafting bench / table
T = turtle.
monkeybee11 #12
Posted 24 December 2012 - 03:20 AM
ok well me found the problem and u are just gong to face parm with this XD me looked up what the lua comarnd for crafting turtle is on the wiki and me putted the comarnd in to a digging turtle not a crafty digging turtle :lol:/>
ok me am going to try this 1 last time :P/> me think seeing it will only have snow in its inv me will only have to add turtle.craft(2x2) in to the program befor turtle.drop in the snow program right ?

and for the loop me want so the only time it will stop is if the chest is full will
if turtle.ItemCount(16) = 0 run snow
work? (me named the program in my turtle snow)

ya ok me did some searching on the net and the ida of having the turtle craft the snow blocks wont work :P/> un less me make the program to complacted for my tiny brain to handle XD

ok me have been trying all day even got my dad to help but wher stuck at this it keeps coming back saying it exspects "do then if while ect" then when we put it in it gives us unexspected symble D:

turtle.select(1)
   while turtle.getItemCount(16) < 16 do
		 turtle.dig()
   end
turtle.turnLeft()
sleep(1)
  for i = 1, 16 do
	    turtle.select(i)
	    turtle.drop()
	    turtle.getItemCount(i) = 0 do
	    turtle.turnRight()
end

dont know y me have such a hard time with lua me have been trying to use it since me was playing roblox 5 years a go and me still know oh most nothing