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

Ignoring Command

Started by Doomerzzzz, 31 August 2013 - 04:01 AM
Doomerzzzz #1
Posted 31 August 2013 - 06:01 AM
Title: Ignoring Command

I was making program that can place blocks in a wall and shutdown afterwards, everything works for the first layer but the ceases after it reaches the start of the second layer where it was supposed to begin. The issue isn't shuttingdown or fuel and there is no obstructions in the way. Not sure why the second command isn't working

http://pastebin.com/VE7c4RrW
Bubba #2
Posted 31 August 2013 - 08:51 AM
Split into new topic.
floppyjack #3
Posted 31 August 2013 - 09:17 AM

placeright()
placeleft()
if turtle.detectUp() == true then
repback() --line 64
turtle.down()
turtle.down()
turtle.down()
os.shutdown()
end

On line 64, you call a function you didn't define before.
Doomerzzzz #4
Posted 31 August 2013 - 09:24 AM
I cut out a few lines that thought wasn't the problem nor relevant >.> sorry, the rest is here

http://pastebin.com/1zNGeyRe
Doomerzzzz #5
Posted 31 August 2013 - 09:28 AM
the issue is

placeright() - works fine
placeleft() - doesn't work at all
floppyjack #6
Posted 31 August 2013 - 09:45 AM
You forgot the brackets on line 80:

if turtle.detect == false then
Should be:

if turtle.detect() == false then
kreezxil #7
Posted 31 August 2013 - 09:47 AM
Also what's up with the strange logic on lines 12, 13 and 14? The subsequent "for" loop completely nullifies them.
Doomerzzzz #8
Posted 31 August 2013 - 09:54 AM
Oh wow.. thats a noob mistake..

just tried that and still gets stuck after the first row it makes
Doomerzzzz #9
Posted 31 August 2013 - 09:55 AM
lines 12, 13 and 14 are for the turtle to select the next item slot that is filled

Just tested it without line 13, that part wasn't necessary
Edited on 31 August 2013 - 08:03 AM
kreezxil #10
Posted 31 August 2013 - 10:04 AM
are you sure because they don't control what the line

for slot = 2, 16 do

does. As I inderstand it "slot" will be initialized to 2 on its first run, if "break" isn't encountered, it'll iterate all the way to 16 which is the second parameter passed to "for". The lines 12, 13, and 14 have no effect on this line.

I am thinking that you want it to somehow remember where it was in the loop when break was encountered. In which case you'll need a global variable call it lastSlot for instance.

so at the top of your program you would have
lastSlot = 2
and then in your loop declaration it would look like
for slot = lastSlot, 16 do
and right before the "break" command you would have
lastSlot = slot+1
and finally I believe the lines 12, 13 & 14 were meant to check that "slot" wasn't outside of the range 2::16 so they need to be adjusted for lastSlot. The result possibly being

if lastSlot > 16 then
   lastSlot = 2
end
Doomerzzzz #11
Posted 31 August 2013 - 10:11 AM
I see what you mean now
lines 12, 13 and 14 wasn't needed, I'm relatively new to lua, only had started a not long ago, sorry.
that part is fixed up now.


well for now line 15 would be enough for what I need it to do right now, but I'll write that one down for future reference.
for slot = 2, 16 do
kreezxil #12
Posted 31 August 2013 - 10:19 AM
Yeah, I hear you, I'm new to Lua too, but not programming. Programming I do as a hobby and that has been since 1975. I'm no where as 1337 (l33t) as floppyjack but I am fairly good at the basics. Feel free to check out some of my programs listed in the signature. I think you'll fall in love with "dig" and "do".
Doomerzzzz #13
Posted 31 August 2013 - 10:24 AM
Okay, I'll check out your programs, would help alot having a look at another, get a good idea of how to script better.