34 posts
Posted 09 September 2012 - 05:52 PM
This is not so much a "ask a pro" as a "i don't get this"…
so I've told my turtle "go down 50 then mine a 10x10 quarry"
he told me "ok, gimme 610 fuel for starters", i give him the fuel, the little fella goes down… and starts the first layer of the quarry… that's basically a 10x10x3 hole with digUp, digDown and dig… so total movement of the lieele guy is less then 300 blocks… i go take a shower, i come back… he's not up yet…
so i jump down with my swiftwolf and what do i see… he's out of fuel…
so… am i getting this right… 1 movement = 1 fuel and nothing else uses up fuel? only turtle.up, turtle.down, turtle.forward and turtle.back?
do just use up fuel recklessly or is there something i'm missing? :D/>/>
12 posts
Posted 09 September 2012 - 06:07 PM
well 10x10x3 would be 300 movements so with 610 fuel he'd only make it through about a 10x10x6 area.
34 posts
Posted 09 September 2012 - 06:14 PM
I'm wasting quite a bit of fuel on some tasks but just cause it was easier to code then making it fuel efficient… this quarry program is for personal use so i don't have to add too many checks and optimizations… just wondered why he ate so much fuel and if i'm reading the wiki correctly :D/>/>
8543 posts
Posted 09 September 2012 - 06:15 PM
We'll need to see the code.
34 posts
Posted 09 September 2012 - 06:20 PM
it's 278 lines long ;P so to save you all the reading I was just wondering if turtle up,down,forward and back are the only commands using up fuel :D/>/>
if yes, then I prolly have him running circles somewhere and will have to read a bit more ^^
8543 posts
Posted 09 September 2012 - 06:22 PM
278 lines is pretty short. It is my understanding that those are the only four that cause fuel level decrements. If you post the code, we will be able to help you more effectively.
34 posts
Posted 09 September 2012 - 06:28 PM
I THINK I found the error…
prolly needs to be a "little" more optimized tho…
put him down for another "quarry 10 10 50" to see what happens now… so far, so good…
but now my shaft miner got stuck… i should really implement new functions for up, down, back and forward and tell them "if you try 20 times with no luck, gimme a warning where you got stuck"…
http://pastebin.com/ucMqRt0Jhere's the quarry in case I've missed an error or 10 :D/>/>
edit: just noticed i forgot to set it to LUA heh
8543 posts
Posted 09 September 2012 - 06:35 PM
Well, your goHome function is quite broken.
while not turtle.up() do end
As soon as it is blocked by something while going up, the program won't go anywhere. Same with every single one of those statements in the goHome function. Still looking through the code, will edit with further comments.
34 posts
Posted 09 September 2012 - 06:40 PM
yea… my "error handing" in this is basically "if something is along the way you already passed, it's prolly a player so just retry until you can move"
downside… someone placing a block down or a mob spawning might break the code…
upside… i don't have to rewrite all the up, down, back, forward functions with manual ones :D/>/>
8543 posts
Posted 09 September 2012 - 06:51 PM
So, let's see. For each layer, you move the length of each row twice, the width twice, and down once. The expression for this is, per layer:
2 * front * right + 2 * right + 1
And for a fuel cost from the top, per layer:
2 * front * right + 2 * right + 2 * (delay + depth + 1)
Whereas your current fuel formula is only:
2 * front * right + 2 * (depth + delay + 2 )
So, I'd estimate that you're short (2 * right) fuel each time.
34 posts
Posted 09 September 2012 - 07:15 PM
so… you like looking at other people's bad code then? ^^
guess i'll just increase "ref" then by a little… that should improve it…
the little guy just came up for fuel while I wasn't watching it seems… so at least that part works :D/>/>
btw… tyvm for the input ^^
8543 posts
Posted 09 September 2012 - 07:37 PM
so… you like looking at other people's bad code then? ^^
guess i'll just increase "ref" then by a little… that should improve it…
the little guy just came up for fuel while I wasn't watching it seems… so at least that part works :D/>/>
btw… tyvm for the input ^^
That's what we do here in Ask a Pro! Hope that solves the problem.