Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///scr_look_for_element(direction), looks for an element in the direction and returns it's array coordinates
- var dir = argument[0];
- var array = Controller_UI.currentUI;//get the UI array
- var testHeight = 1; //how much ahead of the starting point we will test
- var testDepth = 0; // how far back from the starting point we will test
- var testWidth = 1;// how many tiles in width at the heighest height we will test( -1 for each test before it)
- var maxTestHeight = 15;
- var r = false;
- r[0] = false;
- show_debug_message(string(array));
- while(true){
- for(var i = testDepth + 1; i < testHeight; i++){
- show_debug_message("next height loop");
- for(var j = -testWidth; j < testWidth; j++){
- show_debug_message(string(i) + " i / j "+ string(j));
- var testLoc_x = round(lengthdir_x(j,dir));
- var testLoc_y = round(lengthdir_y(i,dir));
- show_debug_message(string(testLoc_x) + " testlocation x / testlocation y " + string(testLoc_y));
- show_debug_message(string(Controller_UI.width) + " width / height " + string(Controller_UI.height));
- if(testLoc_x != 0 && testLoc_y != 0){
- show_debug_message(string("neihter are zero test if in array"));
- 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){
- show_debug_message("contents of array at that location: " + string(array[currentElement_x + testLoc_x, currentElement_y + testLoc_y]));
- if (array[currentElement_x + testLoc_x, currentElement_y + testLoc_y] != 0){
- r[0] = true;
- r[1] = currentElement_x + testLoc_x;
- r[2] = currentElement_y + testLoc_y;
- show_debug_message(string(r));
- return r;
- }
- }
- }
- }
- }
- if(testHeight == maxTestHeight){
- return r;
- }
- testHeight++;
- testWidth++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement