// Off Power Source v1.0.0
// offsource.txt
// by Kelandon

// This power source will shut off every turn. The only way to keep it on is
// to feed it energy constantly with beams.

// This can be really annoying if you have to be around it a lot, because it keeps 
// making the "turning on" sound every turn that it's "on." If you use one of
// these, make sure that the party doesn't have to walk around near it for too
// long.

// Memory Cells - 
//	0 - Terrain number of source when on. If left at 0, defaults to 384, the
//		power source among the default terrains.
//	1 - Terrain number of source when off. If left at 0, defaults to 388, the
//		inactive power source among the default terrains.
//	2 - Whether to turn of instantly or wait a little while. If 0, instantly. If
//		1, wait a little while.

beginterrainscript; 

variables;

body;

beginstate INIT_STATE;
if (get_memory_cell(2) == 0)
	set_script_mode(3);
if (get_memory_cell(2) == 1)
	set_script_mode(0);
if (get_memory_cell(0) == 0)
	set_memory_cell(0,384);
if (get_memory_cell(1) == 0)
	set_memory_cell(1,388);
break;

beginstate START_STATE;
	if (get_terrain(my_loc_x(),my_loc_y()) == get_memory_cell(0))
		set_terrain(my_loc_x(),my_loc_y(),get_memory_cell(1));
break;

beginstate SEARCH_STATE;
break;
