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

Noob Questions Help!

Started by unstopablekk, 26 February 2012 - 02:08 PM
unstopablekk #1
Posted 26 February 2012 - 03:08 PM
I am kinda new to computercraft and have made a couple of scripts in it, but some scripts i question..
(please organize any answers to avoid confusion please)
Q:
1. How do I copy my script from either turtle or computer to a floppy disk? (number it step by step please)

2. How do I get my turtle to count the blocks so It can go only so many blocks forward?

3. Can I loop a script on my turtle? if so then how? (number step by step)

4. If I am able to copy my script from a turtle or computer how do I get it to read it?

5. How do I have a turtle or computer repeat a set of lines/strings or repeat all of the script?

6. Can someone make a script for me that fills in holes in the ground after an explosion? ex: "ohh no! Creeper!" or Can someone edit my code so it does so? (so far it fills the hole in but turns when a block in front of it is detected so i just make a barrier and square off the hole.)

Code for Question 6. : the script is called "fix" (without "" and all lowercase) if you guys need it for the code.


while turtle.forward() do
turtle.placeDown()
end
if turtle.detect() then
turtle.turnRight()
turtle.forward()
turtle.placeDown()
turtle.turnRight()
end
while turtle.forward() do
turtle.placeDown()
end




Here are a few codes that I made (they are really simple to make) : [attachment=43:codes.txt]
unstopablekk #2
Posted 26 February 2012 - 03:10 PM
Q:
7. Can I tell the turtle to pick up a certain block? ex: grass only
unstopablekk #3
Posted 26 February 2012 - 03:11 PM
Q:
8. Is there an addition script that I can add where the turtle goes back to its starting position? If not then how to I get it back to the starting position after its traveled 10 blocks forward and two blocks to the right?
Casper7526 #4
Posted 26 February 2012 - 03:15 PM
1. How do I copy my script from either turtle or computer to a floppy disk? (number it step by step please)

#place floppy in disk
#place computer or turtle next to disk
#cp disk/programname newprogramname

2. How do I get my turtle to count the blocks so It can go only so many blocks forward?
for x = 1, 10 do turtle.forward() end – moves 10 forward

3. Can I loop a script on my turtle? if so then how? (number step by step)

while true do
// your code here
if <condition> == <result> then break end – to leave the loop
end


4. If I am able to copy my script from a turtle or computer how do I get it to read it?
if your talking inside a program you would just shell.run(<programpath>)

5. How do I have a turtle or computer repeat a set of lines/strings or repeat all of the script?
those are just all within a loop while <condition> do <code> end
for <initial value> , <maxvalue> , <stepcount> do <code> end
repeat <code> until <condition>

6. Can someone make a script for me that fills in holes in the ground after an explosion? ex: "ohh no! Creeper!" or Can someone edit my code so it does so? (so far it fills the hole in but turns when a block in front of it is detected so i just make a barrier and square off the hole.)
I cannot make it for you, but your on the right track!



Q:
7. Can I tell the turtle to pick up a certain block? ex: grass only
Not yet, sorry

8. Is there an addition script that I can add where the turtle goes back to its starting position? If not then how to I get it back to the starting position after its traveled 10 blocks forward and two blocks to the right?
You have to keep track of that yourself.
Make a map or a variable that holds the information for what the turtle did then use that to return to it's position. There might be scripts in the program library that could help
unstopablekk #5
Posted 26 February 2012 - 03:19 PM
Thanks
unstopablekk #6
Posted 26 February 2012 - 06:34 PM
can you give me an example of answer # 5?