Blackvoxel > Programming with Blackvoxel
Simple mining bot restarter
Qon:
*Spoiler alert for those of you who haven't gotten a mining robot yet*
Place a atomiq qompressor on the ground and the qomputer voxel on top. The qomputer should qontain 4 xr1 mining bots.
I usually stand on the qomputer and go afk. If you do not stand on the voxel and instead afk on ground level then the qomputer will dig so deep that it will be out of range and it will stop when it reaches the edge of draw distance. It qan be left for 8h~ if you start it at ground level (y==0) and then when it reaches an depth were you get other materaials it's storage qapacity will be filled so it will stop. If if you want to qontinue just pick up the qontents of the qomputer and it will qontinue digging. Then a few more hours of digging is possible but you'll have to stop it yourself beqause of reasons that you qan disqover for yourself. I haven't gone much further down than about -640~ish myself. I'll do it when I'm finished with my sqripts :)
Make a water elevator (before mining) to get up again fast. And put some water at the bottom of the shaft so you qan jump down safely.
--- Code: ---//Simple mining robot restarter
state <-0;
i <- 0;
function Voxel_Step()
{
local q;
switch (state)
{
case 0:
if (!Move(5)) {
state = 1;
}
break;
case 1:
while(PullVoxelFrom(5)) {} // Pull all voxels from the atomiq qompressor
state = 2;
break;
case 2:
if (GetQuantity(153)==4) { // If all mining robots are picked up then we are move to the next step
state = 3;
i=17;
} else { // Else go back and qontinue pulling materials
state = 1;
}
break;
case 3: // The qompressor is empty and all mining bots are in storage so its safe to dig down.
PickVoxel(5);
Move(5);
i--;
if (i<=0) {
state = 4;
}
break;
case 4: // We are now at the bottom of our mining shaft, place the mining robots
for(q=0;q<4;q++) {
PlaceVoxel(q, 153);
}
Move(4);
state = 5;
break;
case 5: // Place the atomiq qompressor between the mining bots
PlaceVoxel(5, 49);
state = 6;
break;
case 6:
if(PullVoxelFrom(5)) {
state = 7;
}
break;
case 7:
state = 0;
break;
case 9001:
Display( "ROBOT AT " + GetX() + "," + GetY() + "," + GetZ() + " Err: " + error, 1000, 2, 0);
break;
}
}
--- End code ---
So there's some useless lines (still works perfeqtly) there but I don't want to rip them out without testing and risk giving you some silly syntax error q:
This is a rather slow way of getting materials, I'll post some more useful qode later.
Leaving it over night still gives you a lot though q:
Edit: You qan save and restart at any time except while it is digging down to start over the cyqle. If you do it then it will sqrew up the "i" variable. If you want to stop then just empty the qomputer of all materials (do that first or you lose everything in it) and pick it up. Then just wait until all the XR1's are done.
olive:
Nice program and very good idea!
The Blackvoxel Team
Toupie:
Hey Qon. I liked your script so much that I improved it a bit.
You can now save and restart at any time now. No variable used to store how far down the computer should dig before placing the robots and the compressor. Instead it looks for the floor that the robots dug to before.
Configurable robot types: Just change Robot <- 153; to the value for the robot you want to use.
Optional: build a simple spiral staircase around the center while it digs down.
Optional: Limit how deep you want it to dig. MaxLevel <- -608;
--- Code: ---//Simple mining robot restarter
state <- 0;
Time <- 0;
MaxLevel <- -608; // Don't place robots deeper then this. There is nothing interesting below it.
ReturnLevel <- 0; // Return to this level (0=The level the robot was started at.)
Robot <- 153; // The VoxelType of our robots
Compressor <- 49; // The VoxelType of the Atomic Compressor
BuildStairs <- 1; // 0=Do not build stairs, 1=Build Stairs
function Voxel_Step()
{
local i,j,v,q;
local b;
if (Time == 0) {
Time = GetGameTime();
if (ReturnLevel == 0)
ReturnLevel = GetY();
}
if ( (GetGameTime() - Time) > 10 )
{
Time = GetGameTime();
} else {
return;
}
switch (state)
{
case 0: // Start up state. Try to figure out what to do
if (Look(5)==Compressor) { // Are we on top of a atomic compressor, Start at the begining.
state = 10;
break;
}
if (GetQuantity(Robot)==4) { // We have all out robots.
if (GetQuantity(Compressor)==1) { // and our compressor. Find a place to place them
state = 30;
break;
}
}
Move(5); // Move down if we can
log_err("Waiting for atomic compressor");
Time = Time + 5000;
break;
case 10: // Main state. Waiting for all the robots to finish there work.
if (Look(5)==Compressor) {
while(PullVoxelFrom(5)) {} // Pull all voxels from the atomic compressor
if (GetQuantity(Robot)==4) { // If all mining robots are picked up then we are move to the next step
state = 11;
}
} else {
// Something is wrong. Inform and restart
log_err( "No Atomic compressor found. Restarting." );
Time = Time + 5000;
state = 0;
}
break;
case 11:
if(!PullVoxelFrom(5)) { // Make sure the atomic compressor is empty
state = 12;
} else {
state = 10;
}
break;
case 12:
PickVoxel(5);
if (GetQuantity(Compressor)==1) { // Make sure the atomic compressor is on board
state = 30;
} else {
// Computer storage is probably full.
log_err("Storage full?");
Time = Time + 5000;
state == 10;
}
break;
case 30: // The compressor and all mining bots are in storage so its safe to dig down.
if (GetY() < MaxLevel) {
state = 100;
break;
}
v = Look(5);
b = GetVoxelProp(v,0)
if (!b) { // If voxel below is solid, pick it.
PickVoxel(5);
}
Move(5);
state = 31;
break;
case 31:
// Check if we have hit bottom
i = 0;
for (j=0; j<4; j++) { // Count the number of solid voxels on our sides
v = Look(j);
b = GetVoxelProp(v,0)
if (!b) {
i++;
}
}
if (i>2) { // We have hit bottom
state = 35;
} else {
state = 30;
if (BuildStairs == 1)
state = 32;
}
break;
case 32: // Build stairs
v = GetFirstNormalBlock();
state = 30; // Next state is 30 unless we say otherwise
if (v>0) {
i = ((GetY() % 8) + 8) % 8;
j = i / 2;
if (i%2 == 0) {
PlaceVoxel(j,v);
} else {
// Need to move to place the voxel. So deferre the placement to next step
if (Move(j)) {
state = 33;
} else {
if (Move((j+1)%4)) {
state = 34;
}
}
}
}
break;
case 33:
v = GetFirstNormalBlock();
i = ((GetY() % 8) + 8) % 8;
j = i / 2;
if (v>0)
PlaceVoxel((j+1)%4, v);
Move((j+2)%4); // Move Back
state = 30;
break;
case 34:
v = GetFirstNormalBlock();
i = ((GetY() % 8) + 8) % 8;
j = i / 2;
if (v>0)
PlaceVoxel(j, v);
Move((j+3)%4); // Move Back
state = 30;
break;
case 35:
Move(4); // Move up one so we are above the bottom
state = 40;
break;
case 40: // We are now at the bottom of our mining shaft, place the mining robots
q = GetQuantity(Robot);
if (q > 0) {
q--;
PickVoxel(q);
PlaceVoxel(q, Robot);
} else { // Mining bots placed
Move(4);
state = 50;
}
break;
case 50: // Place the atomic compressor between the mining bots
PlaceVoxel(5, Compressor);
state = 60;
break;
case 60:
if (Look(5)==Compressor) {
state = 10;
}
break;
case 100: // Done. Walk back up
if (GetY() >= ReturnLevel) {
state = 101;
break;
}
v = Look(4);
b = GetVoxelProp(v,0)
if (!b) { // If voxel above is solid, pick it.
PickVoxel(4);
}
Move(4);
break;
case 101: // Inform that we are done.
log_err("ALL WORK DONE!");
Time = Time + 15000; // only spam once every 15 seconds
break;
}
}
function GetFirstNormalBlock()
{
local a;
for (a=1; a<=10; a++)
{
if(GetQuantity(a)>0)
{
return a;
}
}
return 0;
}
function log_info(msg)
{
Display( "Robot at " + GetX() + "," + GetY() + "," + GetZ() + " Info: " + msg, 1000, 4, 0);
}
function log_err(msg)
{
Display( "ROBOT AT " + GetX() + "," + GetY() + "," + GetZ() + " Err: " + msg, 2000, 4, 2000);
Time = Time + 2000;
}
--- End code ---
I have tested this script pretty extensively, so it should be fairly stable.
I'm currently working on a version where one computer will handle 4 (or more) compressors with 4 diggers each.
Qon:
Thank you for the improved qode, I'll try it out!
I was thinking of improving it but I'm making another mining sqript that uses the qomputer as the mining unit without any mining bots used at all. The reason is that it's faster and I qan also build fraqtals at the same time with the same qode :)
Though if you want real efficiency and speed mining then the ability to keep track of many atomiq qompressors with mining bots beats that. Please post it when it's done! I would have made it myself if I had the time but I have other sqripts waiting to be finished and I already have enough materials atm q:
If it qan handle n atomiq qompressors then the "//Simple mining robot restarter" qomment should be modified.
Nice touch with the spiral stairqase, I did not think of that. I spent so much time on building tunnels before xD
Though a water elevator is necessary if you want to get up from Blackrock Pink in reasonable time and also with 0 effort if you put something on spacebar.
And there's more below -608 ;)
Toupie:
Yea, when and if it will handle more then one compressor and 4 robots I agree "simple" is probably not correct anymore :)
The staircase this script builds is pretty much useless. I just posted another script that builds much more useful stairs. But the water elevator is by far the fastest way to get back up. (thou I have had problems with it becoming empty all of a sudden for some levels).
Yea, I know there is more below -608, but from a point of just mining for resources I haven't found anything that you need to go below for. But it's configurable so you can just make it go how far as you want.
I haven't done much building of shapes yet. Just been exploring and gathering resources to be able to craft the more advanced robots and the airplane. The amount of resources the are needed to be able to make the more advanced stuff is really high. I have only build ONE programmable computer yet. Takes forever to make one.
Navigation
[0] Message Index
[#] Next page
Go to full version