look.txt 1008 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. event.load("block_click");
  2. @wait
  3. wait();
  4. if(player.getName(player) != "SirTerence7"){
  5. goto("wait");
  6. }
  7. if(action == "PHYSICAL"){
  8. goto("wait");
  9. }
  10. player_look = entity.getLook(player);
  11. main_look = entity.getMainLookDirection(player_look);
  12. msg("dev", text.new(main_look));
  13. goto("wait");
  14. function entity.getMainLookDirection(look_array){
  15. X = look_array[0];
  16. Y = look_array[1];
  17. Z = look_array[2];
  18. X_abs = math.abs(X);
  19. Y_abs = math.abs(Y);
  20. Z_abs = math.abs(Z);
  21. looks_map = map.new();
  22. map.add(looks_map, X_abs, 0);
  23. map.add(looks_map, Y_abs, 1);
  24. map.add(looks_map, Z_abs, 2);
  25. main_direction = map.get(looks_map, math.max(math.max(X_abs, Y_abs), Z_abs)); //0=X,1=Y,2=Z
  26. if(main_direction == 0){
  27. if(X < 0){
  28. return "west";
  29. }else{
  30. return "east";
  31. }
  32. }elseif(main_direction == 1){
  33. if(Y < 0){
  34. return "down";
  35. }else{
  36. return "up";
  37. }
  38. }elseif(main_direction == 2){
  39. if(Z < 0){
  40. return "north";
  41. }else{
  42. return "south";
  43. }
  44. }
  45. }