Posted 30 November 2013 - 10:34 AM
Hello Community and Pros,
I am completly new to programming in Lua. The last few days i have watched a lot of tutorials, read wikis and tutorials and all this stuff. I have to admit, that i am somehow a little bit proud, that, even if it is based on an existing program, my own LevelArea program at least does something (after at least a week of testing and searching). But unfortunatly not what i really want. I can see the beginnings of what i want, but now i don't know any further. So i ask you. Maybe you can help me.
The program:
What i want is a program that levels an area (mainly on the surface, not underground) where you give the Turtle not only a square area like in the excavate program but an area where i can choose width and lenght. This part somehow worked out.
The movement of the excavate program is good for me, (dig one lane, turn around, dig the second lane, etc. Hope you know what i mean), so i want to keep it. Heres the big change.
The turtle should dig one block forward and then detect if there are blocks above (the excavate program is to dig under the earth, i want the opposite direction). If there is, it should dig that block up, go one upward and detect if there is a block above again. If there is no block above the turtle, it should go two blocks upwards testing for blocks to make sure it isn't a hole and there really is nothing more about it. After that, it should go down to the starting level on the y-axis, move one block forward and detect again for blocks above. This whole procedure should be done until the area is cleaned.
Here are the problems and what it does until now:
The turtle starts and dig forward, geos forward, then digs upwards and goes one upwards. This procedure repeats until there is nothing in front of the turtle and it begins to circle in the given area (for example 3 x 4 blocks). When it turns and there is a block in front of it again, it goes forward and up again, until there is an area with no blocks in the given area.
Second problem is, the turtle does not stop. it circles around until there is no fuel left.
Maybe some on can help me. I choosed the excavate program because it is comfortable for big areas, with fuel refill and bring back the inventar when it is full. But because it is (for a beginner) an advanced program i have difficulties with it.
Here is the pastebin link to the code because it is about 400 lines big. I have written some comments in the code, that specify my explanations here to the questionable functions.
http://pastebin.com/YUez12RP
Thank you
Soapy
I am completly new to programming in Lua. The last few days i have watched a lot of tutorials, read wikis and tutorials and all this stuff. I have to admit, that i am somehow a little bit proud, that, even if it is based on an existing program, my own LevelArea program at least does something (after at least a week of testing and searching). But unfortunatly not what i really want. I can see the beginnings of what i want, but now i don't know any further. So i ask you. Maybe you can help me.
The program:
What i want is a program that levels an area (mainly on the surface, not underground) where you give the Turtle not only a square area like in the excavate program but an area where i can choose width and lenght. This part somehow worked out.
The movement of the excavate program is good for me, (dig one lane, turn around, dig the second lane, etc. Hope you know what i mean), so i want to keep it. Heres the big change.
The turtle should dig one block forward and then detect if there are blocks above (the excavate program is to dig under the earth, i want the opposite direction). If there is, it should dig that block up, go one upward and detect if there is a block above again. If there is no block above the turtle, it should go two blocks upwards testing for blocks to make sure it isn't a hole and there really is nothing more about it. After that, it should go down to the starting level on the y-axis, move one block forward and detect again for blocks above. This whole procedure should be done until the area is cleaned.
Here are the problems and what it does until now:
The turtle starts and dig forward, geos forward, then digs upwards and goes one upwards. This procedure repeats until there is nothing in front of the turtle and it begins to circle in the given area (for example 3 x 4 blocks). When it turns and there is a block in front of it again, it goes forward and up again, until there is an area with no blocks in the given area.
Second problem is, the turtle does not stop. it circles around until there is no fuel left.
Maybe some on can help me. I choosed the excavate program because it is comfortable for big areas, with fuel refill and bring back the inventar when it is full. But because it is (for a beginner) an advanced program i have difficulties with it.
Here is the pastebin link to the code because it is about 400 lines big. I have written some comments in the code, that specify my explanations here to the questionable functions.
http://pastebin.com/YUez12RP
Thank you
Soapy