Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. ///scr_look_for_element(direction), looks for an element in the direction and returns it's array coordinates
  2.  
  3. var dir = argument[0];
  4. var array = Controller_UI.currentUI;//get the UI array
  5. var testHeight = 1; //how much ahead of the starting point we will test
  6. var testDepth = 0; // how far back from the starting point we will test
  7. var testWidth = 1;// how many tiles in width at the heighest height we will test( -1 for each test before it)
  8. var maxTestHeight = 15;
  9. var r = false;
  10. r[0] = false;
  11. show_debug_message(string(array));
  12. while(true){
  13. for(var i = testDepth + 1; i < testHeight; i++){
  14. show_debug_message("next height loop");
  15. for(var j = -testWidth; j < testWidth; j++){
  16. show_debug_message(string(i) + " i / j "+ string(j));
  17.  
  18. var testLoc_x = round(lengthdir_x(j,dir));
  19. var testLoc_y = round(lengthdir_y(i,dir));
  20. show_debug_message(string(testLoc_x) + " testlocation x / testlocation y " + string(testLoc_y));
  21. show_debug_message(string(Controller_UI.width) + " width / height " + string(Controller_UI.height));
  22. if(testLoc_x != 0 && testLoc_y != 0){
  23.  
  24. show_debug_message(string("neihter are zero test if in array"));
  25. if(currentElement_x + testLoc_x < Controller_UI.width && currentElement_x + testLoc_x >= 0 && currentElement_y + testLoc_y < Controller_UI.height && currentElement_y + testLoc_y >= 0){
  26. show_debug_message("contents of array at that location: " + string(array[currentElement_x + testLoc_x, currentElement_y + testLoc_y]));
  27. if (array[currentElement_x + testLoc_x, currentElement_y + testLoc_y] != 0){
  28. r[0] = true;
  29. r[1] = currentElement_x + testLoc_x;
  30. r[2] = currentElement_y + testLoc_y;
  31. show_debug_message(string(r));
  32. return r;
  33. }
  34. }
  35. }
  36. }
  37. }
  38. if(testHeight == maxTestHeight){
  39. return r;
  40. }
  41. testHeight++;
  42. testWidth++;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement