Jump to content




Ignoring Command


12 replies to this topic

#1 Doomerzzzz

  • Members
  • 7 posts

Posted 31 August 2013 - 05: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

#2 Bubba

    Use Code Tags!

  • Moderators
  • 1,142 posts
  • LocationRHIT

Posted 31 August 2013 - 07:51 AM

Split into new topic.

#3 floppyjack

  • Members
  • 18 posts

Posted 31 August 2013 - 08: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.

#4 Doomerzzzz

  • Members
  • 7 posts

Posted 31 August 2013 - 08: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

#5 Doomerzzzz

  • Members
  • 7 posts

Posted 31 August 2013 - 08:28 AM

the issue is

placeright() - works fine
placeleft() - doesn't work at all


#6 floppyjack

  • Members
  • 18 posts

Posted 31 August 2013 - 08:45 AM

You forgot the brackets on line 80:
if turtle.detect == false then
Should be:
if turtle.detect() == false then


#7 kreezxil

  • Members
  • 128 posts
  • LocationBowie, TX

Posted 31 August 2013 - 08:47 AM

Also what's up with the strange logic on lines 12, 13 and 14? The subsequent "for" loop completely nullifies them.

#8 Doomerzzzz

  • Members
  • 7 posts

Posted 31 August 2013 - 08:54 AM

Oh wow.. thats a noob mistake..

just tried that and still gets stuck after the first row it makes

#9 Doomerzzzz

  • Members
  • 7 posts

Posted 31 August 2013 - 08: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 by Doomerzzzz, 31 August 2013 - 09:03 AM.


#10 kreezxil

  • Members
  • 128 posts
  • LocationBowie, TX

Posted 31 August 2013 - 09: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


#11 Doomerzzzz

  • Members
  • 7 posts

Posted 31 August 2013 - 09: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


#12 kreezxil

  • Members
  • 128 posts
  • LocationBowie, TX

Posted 31 August 2013 - 09: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".

#13 Doomerzzzz

  • Members
  • 7 posts

Posted 31 August 2013 - 09: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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users