checkers.txt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //cornerpieces
  2. corner1 = loc.new();//black
  3. corner2 = loc.new();//white
  4. facing("south"); //the way the skulls of the black side face
  5. //south: Z++
  6. add_x = -1;
  7. add_z = 1;
  8. air_material = material.get("AIR");
  9. world = world.get("games");
  10. black_disc = material.get("WITHER_SKELETON_SKULL");
  11. white_disc = material.get("SKELETON_SKULL");
  12. black_tile = material.get("DARK_OAK_PLANKS");
  13. function checkers.clear_field(){
  14. temp_it = loc.iterator(world, x1,y1,z1,x2,y2,z2);
  15. while(hasnext(temp_it)){
  16. block.setMaterial(block.get(next(temp_it)), $air_material);
  17. }
  18. }
  19. function checkers.set_field(){
  20. checkers.clear_field();
  21. temp_black = $corner1;
  22. for(a = 0; a < 4; a++){
  23. setcorner1 = loc.mod($corner1, add_x*2*a, 0, add_z*2*a);
  24. setcorner2 = loc.mod($corner2, -add_x*2*a, 0, -add_z*2*a);
  25. block.set(block.get(loc.mod(setcorner1, 0, 0, 0)), $black_disc);
  26. block.set(block.get(loc.mod(setcorner1, add_x, 0, add_z)), $black_disc);
  27. block.set(block.get(loc.mod(setcorner1, 0, 0, 2*add_z)), $black_disc);
  28. block.set(block.get(loc.mod(setcorner2, 0, 0, 0)), $white_disc);
  29. block.set(block.get(loc.mod(setcorner2, -add_x, 0, -add_z)), $white_disc);
  30. block.set(block.get(loc.mod(setcorner2, 0, 0, -2*add_z)), $white_disc);
  31. }
  32. }
  33. function checkers.move_is_valid(){
  34. if(block.getType != $black_tile){
  35. return false;
  36. }
  37. }