/* DESCRIPTION : Functions for the world click handler and manipulating entities. NOTES : */ // ==================================================================== addGlobalHandler ("worldClick", worldClickHandler); // ==================================================================== // The world-click handler - called whenever the user clicks the terrain function worldClickHandler(event) { args=new Array(null, null); console.write("worldClickHandler: button "+event.button+", clicks "+event.clicks); if (isSelecting()) { getGlobal().selectionWorldClickHandler(event); return; } // Right button single- or double-clicks if (event.button == SDL_BUTTON_RIGHT && event.clicks <= 2) { if (event.clicks == 1) cmd = event.order; else if (event.clicks == 2) { console.write("Issuing secondary order"); cmd = event.secondaryOrder; } } else { return; } //setting rally point if ( getCursorName() == "cursor-rally" ) { for ( var i=0; i 0 ) return( selection[0] ); return( null ); } // ==================================================================== function triggerSelectionRun() { for ( i=0; i< selection.length; i++ ) { selection[i].triggerRun(); } } // ==================================================================== function setSelectionRun() { for ( i=0; i< selection.length; i++ ) { selection[i].setRun( false ); } } // ==================================================================== function validProperty (propertyName) { // Accepts a string representing an entity property (eg "selection[0].traits.id.generic") // and checks if all the elements (selection[0].traits, selection[0].traits.id, etc) are valid properties. // Returns false if any invalids are found. Returns true if the whole property is valid. // An empty string is always successful. if (propertyName == "") return true; // An undefined string is always unsuccessful. if (propertyName == undefined) return false; // Store elements of the property as an array of strings. var splitArray = propertyName.toString().split ("."); // Seek through elements in array. var arrayString = ""; for (var i = 0; i < splitArray.length; i++) { // Test each element combination of the string to ensure they are all valid. if (i > 0) arrayString += "."; arrayString += splitArray[i]; // If the property name is not valid, return false. if (!(eval (arrayString))) return false; } // If we managed to check them all, every element in the property is valid. Return true. return true; } // ====================================================================