Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pretty command to locate_block.sc #346

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions programs/survival/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,10 @@ Various scripts that modify various game elements, often replicating popular mod

### [locate_block.sc](https://github.com/gnembon/scarpet/blob/master/programs/survival/locate_block.sc):
#### By Ghoulboy
This will allow you to see how many blocks of a specific type there are in an area around a point.
locate will tell you first 100 blocks, as well as how many there are in total, and you can tp to them by clicking in chat.
hist will print a histogram like in gnembon's ancient debris video, but this will accept any block, and if there are less than 40 blocks for that y level, it will print a nice looking histogram.
This will allow you to see how many blocks of a specific type there are in a cubic area around a point.
/locate_block locate will tell you the positions of the first 100 blocks, as well as how many there are in total, and you can tp to them by clicking in chat.
/locate_block hist will print a nice looking histogram depicting the number of blocks in each y-level.
Both commands can either be executed from player's position or from a position specified by the player.


### [lodestone_chunk_loader.sc](https://github.com/gnembon/scarpet/blob/master/programs/survival/lodestone_chunk_loader.sc)
Expand Down
30 changes: 24 additions & 6 deletions programs/survival/locate_block.sc
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,49 @@
//locate prints the first 100, and you can tp to those locations
//hist gives a distribution over defined y values
//By: Ghoulboy
__command()->(print(''));

locate(r,cx,cy,cz,block)->(
__config()->{
'commands'->{
''->_()->print('Root call'),
'locate <radius> <block>'->['locate',null],
'locate <radius> <block> <pos>'->'locate',
'hist <radius> <block>'->['hist',null],
'hist <radius> <block> <pos>'->'hist',
},
'arguments'->{
'radius'->{
'type' -> 'int',
'min' -> 0,
'suggest' -> [10, 50, 100]
},
}
};

locate(r,block,c_pos)->(
[cx, cy, cz] = c_pos||pos(player());
i=0;
scan([cx, cy, cz], [r, r, r],
if(_==block,
if(i<100,
pos = pos(_);
print(format('gi '+pos,str('!/script run modify(p,\'pos\',%s)',str(pos))))
print(player(), format('gi '+pos,str('!/script run modify(p,\'pos\',%s)',str(pos))))
);
i+=1
)
);
'Block: '+block+' was found '+i+' times'
print(player(), format('gi Block: '+block+' was found '+i+' times'))
);

hist(r,cx,cy,cz,block)->(
hist(r,block,c_pos)->(
[cx, cy, cz] = c_pos||pos(player());
blocks={};
scan([cx,cy,cz],[r,r,r],
if(_==block,blocks:_y+=1)
);
for(blocks,
if(blocks:_<40,
print(_+': '+'*'*blocks:_+' '+blocks:_+' times'),
print(_+': '+blocks:_+' times')
print(_+': '+'*'*30+' '+blocks:_+' times')
)
)
)