//flaglever.txt - Lever which, when pulled, flips a flag from 0 to 1 and back. No locks
// or other trickery.
//Cell 0,1 - The sdf which is set to 1 or 0 when lever is pulled.
// Cell 2 - skill needed, if 0 none
// Cell 3 - If 1, can't flip back
beginobjectscript; 

variables;

body;

variables;
	short range = 0;
body;

beginstate INIT_STATE;
		if (get_flag(get_memory_cell(0),get_memory_cell(1)) > 0) 
				set_object_icon(ME,11);
				else set_object_icon(ME,10);
	break;

beginstate DEAD_STATE;

break;

beginstate START_STATE; // door closed, waiting
break;

beginstate USE_STATE;
	if ((get_memory_cell(1) == 14) && (gf(35,7) == 0)) {
		sf(35,7,1);
		
		set_terrain(0,44,48,0);
		set_terrain(0,47,48,0);
		set_terrain(0,50,48,0);
		set_terrain(0,53,48,0);
		set_terrain(0,44,52,0);
		set_terrain(0,47,52,0);
		set_terrain(0,50,52,0);
		
		set_floor(0,44,48,11 + get_ran(1,0,1));
		set_floor(0,47,48,11 + get_ran(1,0,1));
		set_floor(0,50,48,11 + get_ran(1,0,1));
		set_floor(0,53,48,11 + get_ran(1,0,1));
		set_floor(0,44,52,11 + get_ran(1,0,1));
		set_floor(0,47,52,11 + get_ran(1,0,1));
		set_floor(0,50,52,11 + get_ran(1,0,1));
		
		activate_hidden_group(2);
		set_name(30001,"Vahnatai Figurine");
		set_resistance(30001,7,100);
		set_aggression(30001,40);
		
		ok_dlog(55,1);
		
		end();
		
		}
	if ((get_memory_cell(1) == 11) && (gf(35,0) == 0) && (gf(35,24) > 0)) {
		sf(35,0,1);
		
		ok_dlog(57,1);

		activate_hidden_group(1);

		end();
		
		}
		
	if ((get_memory_cell(0) > 0) || (get_memory_cell(1) > 0)) {
		if (get_flag(get_memory_cell(0),get_memory_cell(1)) > 0) {

				print_str("Pull Lever: You shift the lever to the left position.");
					set_flag(get_memory_cell(0),get_memory_cell(1),0);
					set_object_icon(ME,10);
			}
			else {
				print_str("Pull Lever: You shift the lever to the right position.");
				set_flag(get_memory_cell(0),get_memory_cell(1),1);
				set_object_icon(ME,11);
				}
		}
	play_sound(21);
break;
