Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. /**
  2. * 월드에딧 스크립트
  3. * 버전 0.1 beta
  4. * 제작: JacobYun
  5. */
  6.  
  7. const VERSION = 0.1;
  8. const setBlockCommand = "채우기";
  9. const changeBlockCommand = "변경";
  10.  
  11. var pos1 = [0, 0, 0]; //지점 1
  12. var pos2 = [0, 0, 0]; //지점 2
  13. var isFirstSeted = false; //지점1 지정여부
  14. var isSecondSeted = false; //지점2 지정여부
  15.  
  16. function newLevel() {
  17. clientMessage( "월드에딧 " + VERSION );
  18. clientMessage( "제작: JacobYun" );
  19. }
  20.  
  21. function useItem( x, y, z, item, block ) {
  22. if ( item == 271 ) {
  23. pos1[0] = x;
  24. pos1[1] = y;
  25. pos1[2] = z;
  26. isFirstSeted = true;
  27. clientMessage( "[월드에딧] 1번 지점 : " + x + " " + y + " " + z );
  28. }
  29. }
  30.  
  31. function destroyBlock( x, y, z, side ) {
  32. if ( getCarriedItem() == 271 ) {
  33. preventDefault();
  34. pos2[0] = x;
  35. pos2[1] = y;
  36. pos2[2] = z;
  37. isSecondSeted = true;
  38. clientMessage( "[월드에딧] 2번 지점 : " + x + " " + y + " " + z );
  39. }
  40. }
  41.  
  42. function procCmd( command ) {
  43. command = command.split(" ");
  44. switch ( command[0] ) {
  45. case setBlockCommand:
  46. if ( isFirstSeted && isSecondSeted ) {
  47. if ( !( typeof command[1] == "undefined" ) ) {
  48. editWorld( command[1] );
  49. } else {
  50. clientMessage( "[월드에딧] /" + setBlockCommand + " 블럭아이디" );
  51. }
  52. } else {
  53. clientMessage( "[월드에딧] 지점 미설정" );
  54. }
  55. break;
  56. case changeBlockCommand:
  57. if ( isFirstSeted && isSecondSeted ) {
  58. if ( !( typeof command[2] == "undefined" ) ) {
  59. changeBlock( command[1], command[2] );
  60. } else {
  61. clientMessage( "[월드에딧] /" + changeBlockCommand + " 블럭아이디 블럭아이디" );
  62. }
  63. } else {
  64. clientMessage( "[월드에딧] 지점 미설정" );
  65. }
  66. }
  67. }
  68.  
  69. function editWorld( blockID ) {
  70. var lowX = getLow( pos1[0], pos2[0] );
  71. var highX = getHigh( pos1[0], pos2[0] );
  72. var lowY = getLow( pos1[1], pos2[1] );
  73. var highY = getHigh( pos1[1], pos2[1] );
  74. var lowZ = getLow( pos1[2], pos2[2] );
  75. var highZ = getHigh( pos1[2], pos2[2] );
  76.  
  77. for (var x = lowX; x <= highX; x++) {
  78. for (var y = lowY; y <= highY; y++) {
  79. for (var z = lowZ; z <= highZ; z++) {
  80. Level.setTile( x, y, z, blockID );
  81. }
  82. }
  83. }
  84. }
  85.  
  86. function changeBlock( blockID, toBlockID) {
  87. var lowX = getLow( pos1[0], pos2[0] );
  88. var highX = getHigh( pos1[0], pos2[0] );
  89. var lowY = getLow( pos1[1], pos2[1] );
  90. var highY = getHigh( pos1[1], pos2[1] );
  91. var lowZ = getLow( pos1[2], pos2[2] );
  92. var highZ = getHigh( pos1[2], pos2[2] );
  93.  
  94. for (var x = lowX; x <= highX; x++) {
  95. for (var y = lowY; y <= highY; y++) {
  96. for (var z = lowZ; z <= highZ; z++) {
  97. if ( Level.getTile( x, y, z ) == blockID ) {
  98. Level.setTile( x, y, z, toBlockID );
  99. }
  100. }
  101. }
  102. }
  103. }
  104.  
  105. function getLow( a, b ) { //ab중 더 낮은 값 반환
  106. return a < b ? a : b;
  107. }
  108.  
  109. function getHigh( a, b ) { //ab중 더 높은 값 반환
  110. return a > b ? a : b;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement