// flag2lever.txt 
// by Thralni
// v 1.0.0

// A lever that toggles SDF's to 0 or 1. When it is walked onto, asks if the
// party wants to pull it. If they do, toggles SDF from 0 to 1, or vice versa. 

// (When a terrain type is defined, you can set a swap terrain type for
// it, a terrain type that it changes to if it is opened/closed. For
// example, a closed gate's swap terrain is an open gate.

// Memory Cells - 
//   0,1 - The x,y coordinated of a SDF this lever sets to value stated in cell 2.
//	 2   - value to be before lever can be pulled.
//	 3	 - value to set SDF stated in cells 0 and 1.

beginterrainscript; 

variables;
	short choice;

body;

beginstate INIT_STATE;
break;

beginstate START_STATE;
break;

beginstate SEARCH_STATE;
reset_dialog_preset_options(2);
choice = run_dialog(0);
	
	if (choice == 1)
		end();

	if (get_flag(get_memory_cell(0),get_memory_cell(1)) == get_memory_cell(2)) {
			set_flag(get_memory_cell(0),get_memory_cell(1),get_memory_cell(3));
			flip_terrain(my_loc_x(),my_loc_y());
			play_sound(106);
			print_str_color("You pull the lever.",2);
			end();
			}
		flip_terrain(my_loc_x(),my_loc_y());
		play_sound(106);
		print_str_color("You pull the lever.",2);
		end();
			
break;

beginstate STEP_INTO_SPOT_STATE;
break;
