Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * 월드에딧 스크립트
- * 버전 0.1 beta
- * 제작: JacobYun
- */
- const VERSION = 0.1;
- const setBlockCommand = "채우기";
- const changeBlockCommand = "변경";
- var pos1 = [0, 0, 0]; //지점 1
- var pos2 = [0, 0, 0]; //지점 2
- var isFirstSeted = false; //지점1 지정여부
- var isSecondSeted = false; //지점2 지정여부
- function newLevel() {
- clientMessage( "월드에딧 " + VERSION );
- clientMessage( "제작: JacobYun" );
- }
- function useItem( x, y, z, item, block ) {
- if ( item == 271 ) {
- pos1[0] = x;
- pos1[1] = y;
- pos1[2] = z;
- isFirstSeted = true;
- clientMessage( "[월드에딧] 1번 지점 : " + x + " " + y + " " + z );
- }
- }
- function destroyBlock( x, y, z, side ) {
- if ( getCarriedItem() == 271 ) {
- preventDefault();
- pos2[0] = x;
- pos2[1] = y;
- pos2[2] = z;
- isSecondSeted = true;
- clientMessage( "[월드에딧] 2번 지점 : " + x + " " + y + " " + z );
- }
- }
- function procCmd( command ) {
- command = command.split(" ");
- switch ( command[0] ) {
- case setBlockCommand:
- if ( isFirstSeted && isSecondSeted ) {
- if ( !( typeof command[1] == "undefined" ) ) {
- editWorld( command[1] );
- } else {
- clientMessage( "[월드에딧] /" + setBlockCommand + " 블럭아이디" );
- }
- } else {
- clientMessage( "[월드에딧] 지점 미설정" );
- }
- break;
- case changeBlockCommand:
- if ( isFirstSeted && isSecondSeted ) {
- if ( !( typeof command[2] == "undefined" ) ) {
- changeBlock( command[1], command[2] );
- } else {
- clientMessage( "[월드에딧] /" + changeBlockCommand + " 블럭아이디 블럭아이디" );
- }
- } else {
- clientMessage( "[월드에딧] 지점 미설정" );
- }
- }
- }
- function editWorld( blockID ) {
- var lowX = getLow( pos1[0], pos2[0] );
- var highX = getHigh( pos1[0], pos2[0] );
- var lowY = getLow( pos1[1], pos2[1] );
- var highY = getHigh( pos1[1], pos2[1] );
- var lowZ = getLow( pos1[2], pos2[2] );
- var highZ = getHigh( pos1[2], pos2[2] );
- for (var x = lowX; x <= highX; x++) {
- for (var y = lowY; y <= highY; y++) {
- for (var z = lowZ; z <= highZ; z++) {
- Level.setTile( x, y, z, blockID );
- }
- }
- }
- }
- function changeBlock( blockID, toBlockID) {
- var lowX = getLow( pos1[0], pos2[0] );
- var highX = getHigh( pos1[0], pos2[0] );
- var lowY = getLow( pos1[1], pos2[1] );
- var highY = getHigh( pos1[1], pos2[1] );
- var lowZ = getLow( pos1[2], pos2[2] );
- var highZ = getHigh( pos1[2], pos2[2] );
- for (var x = lowX; x <= highX; x++) {
- for (var y = lowY; y <= highY; y++) {
- for (var z = lowZ; z <= highZ; z++) {
- if ( Level.getTile( x, y, z ) == blockID ) {
- Level.setTile( x, y, z, toBlockID );
- }
- }
- }
- }
- }
- function getLow( a, b ) { //ab중 더 낮은 값 반환
- return a < b ? a : b;
- }
- function getHigh( a, b ) { //ab중 더 높은 값 반환
- return a > b ? a : b;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement