Line 72: |
Line 72: |
| temp_obj = array, | | temp_obj = array, |
| // Have a holder for instructional control return array | | // Have a holder for instructional control return array |
| + | success_o_meter = true, |
| future_instructional_return = []; | | future_instructional_return = []; |
| | | |
Line 83: |
Line 84: |
| console.log("instructions are an object, in path " + path); | | console.log("instructions are an object, in path " + path); |
| | | |
− | //||||||||||||||||||||||||||[ Check if elements of instruction object are arrays themselves ]|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| | + | //||||||||||||||||||||||||||[ Check if elements of instruction object are arrays themselves ]|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
| | | |
| if ( Array.isArray (read[path]) ) { | | if ( Array.isArray (read[path]) ) { |
Line 90: |
Line 91: |
| | | |
| console.log("instructions are an array of arrays, going through " + read[ path ][ path2 ] ); | | console.log("instructions are an array of arrays, going through " + read[ path ][ path2 ] ); |
− | future_return_partition = data_function( future_return_partition, read[ path ][ path2 ] ); | + | |
| + | if ( data_function( future_return_partition, read[ path ][ path2 ] ) !== future_return_partition ){ |
| + | future_return_partition = data_function( future_return_partition, read[ path ][ path2 ] ); |
| + | } else { |
| + | success_o_meter = false; |
| + | } |
| | | |
− | //|||||||||||||||||||||||||||||||||||||||||||||||||||[ I N S T R U C T I O N S C O N T R O L |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| | + | //|||||||||||||||||||||||||||||||||||||||||||||||||||[ I N S T R U C T I O N S C O N T R O L ||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
| | | |
| }); | | }); |
| + | if ( success_o_meter === true ) { |
| // Put the result of the travel along the paths in array element of array into the future_instructional_return bunch | | // Put the result of the travel along the paths in array element of array into the future_instructional_return bunch |
− | console.log("arrived at")
| + | console.log("arrived at") |
− | console.log(future_return_partition);
| + | console.log(future_return_partition); |
− | future_instructional_return.push(future_return_partition);
| + | future_instructional_return.push(future_return_partition); |
| + | } else { |
| + | console.log("seeking derailed"); |
| + | success_o_meter = true; |
| + | } |
| | | |
| } | | } |
| | | |
− | //|||||||||||||||||| If instruction object element is not an array anymore, lets just do one step |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| | + | //|||||||||||||||||| If instruction object element is not an array anymore, lets just do one step |||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
| | | |
| else { | | else { |
| | | |
| // INCLUDE step block with read[path] | | // INCLUDE step block with read[path] |
− | future_instructional_return.push( data_function( temp_obj, read[ path ] ) ); | + | if ( data_function( temp_obj, read[ path ] ) !== temp_obj ){ |
| + | future_instructional_return.push( data_function( temp_obj, read[ path ] ) ); |
| + | } else { |
| + | future_instructional_return.push( undefined ); |
| + | } |
| | | |
| } | | } |
Line 115: |
Line 130: |
| } | | } |
| | | |
− | //||||||||||||[ If we are not in instruction object, let's see if we have an instruction array ]||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| | + | //||||||||||||[ If we are not in instruction object, let's see if we have an instruction array ]|||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
| | | |
| else if ( Array.isArray(read) ) { | | else if ( Array.isArray(read) ) { |
| // If so let's follow the array of instructions | | // If so let's follow the array of instructions |
| Object.keys( read ).forEach( function ( ect ) { | | Object.keys( read ).forEach( function ( ect ) { |
− | temp_obj = data_function( temp_obj, read[ ect ] ); | + | if ( data_function( temp_obj, read[ ect ] ) !== temp_obj ){ |
| + | |
| + | temp_obj = data_function( temp_obj, read[ ect ] ); |
| + | |
| + | } else { |
| + | |
| + | success_o_meter = false; |
| + | |
| + | } |
| }); | | }); |
| } | | } |
| | | |
− | //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| | + | //||||||||||||[ If we have a single instruction, let's try following that ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
| | | |
| else { | | else { |
− | temp_obj = data_function( temp_obj, read ); | + | |
| + | if ( data_function( temp_obj, read ) !== temp_obj ){ |
| + | |
| + | temp_obj = data_function( temp_obj, read ); |
| + | |
| + | } else { |
| + | |
| + | success_o_meter = false; |
| + | |
| + | } |
| + | } |
| + | if ( success_o_meter === true ) { |
| + | return temp_obj; |
| + | } else { |
| + | return undefined; |
| } | | } |
− |
| |
− | return temp_obj;
| |
| } | | } |
| | | |
− | //|||||||||||||||||||||||||||||||||||||||||||||||||||||[ S T E P B L O C K ]||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| | + | //|||||||||||||||||||||||||||||||||||||||||||||||||||||[ S T E P B L O C K ]|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
| | | |
| function data_function ( temp_obj, moving ) { | | function data_function ( temp_obj, moving ) { |