// Final Source
// t8finalsrce.txt
// by Kelandon

// This is the black magic that I have to do so that my initially inactive power
// sources turn off when they are not being powered.

// This script flips terrains based on the presence of exactly four mirrors. 
// Basically, you input the places where the mirrors have to be in order to turn 
// on this particular power source, and if they are not there, this source shuts 
// off.

// I have little hope that this script will be useful to anyone but me, but
// maybe someone will be interested.

// Memory Cells -
//	0,1 - x,y of first mirror.
//	2,3 - x,y of second mirror.
//	4,5 - x,y of third mirror.
//	6,7 - x,y of fourth mirror.

beginterrainscript; 

variables;
int i_am_off;

body;

beginstate INIT_STATE;
	set_script_mode(3);
break;

beginstate START_STATE;
	if ((((is_object_on_space(get_memory_cell(2),get_memory_cell(3),5) == 0) && (is_object_on_space(get_memory_cell(2),get_memory_cell(3),6) == 0)) || ((is_object_on_space(get_memory_cell(4),get_memory_cell(5),5) == 0) && (is_object_on_space(get_memory_cell(4),get_memory_cell(5),6) == 0))) || ((is_object_on_space(get_memory_cell(6),get_memory_cell(7),5) == 0) && (is_object_on_space(get_memory_cell(6),get_memory_cell(7),6) == 0)))
		set_terrain(my_loc_x(),my_loc_y(),388);	
break;

beginstate SEARCH_STATE;
break;
