Originally Posted By: Malice
Ok we create a empty ENTITY struct with pointer ENTITY* door_ent;

We create a action call door()

We assign that action to 3 of any of the entity types (model, sprite, map_ent).

Each of these 3 get a automatically assigned a entity struct, and each get a memory pointer. Each are created one at a time.

Each of the 3 is then assigned into the empty pointer struct door_ent=my;
thous - only that last create entity actual shares a memory pointer address with door_ent.



Wow man i was sooo stupid , haha (when i create this script my mind it not in scripting ) so i correct the code :

Code:
action door()
{
	my.skill99 = 100; /// its a door
	while(1)
	{
		if(my.skill2  == 1)
		{
			var tmp_z = my.z + 50;
			while(my.z < tmp_z)
			{
				my.z += 5;
				wait(1);
			}
			my.skill2 = 2;
		}
		if(my.skill2  == 3)
		{
			var tmp_z = my.z - 50;
			while(my.z > tmp_z)
			{
				my.z -= 5;
				wait(1);
			}
			my.skill2 = 0;
		}
		wait(1);
	}
}

action opener()
{
	while(1)
	{
		c_scan(my.x, my.pan, vector(360, 180, t_switch_range), IGNORE_ME | SCAN_ENTS);
		if(you)
		{
			if((you == player)&&(key_enter))
			{
				for(you = ent_next(NULL); you; you = ent_next(you))
				{
					if(you.skill99 == 100)
					{
						if(you.skill1 == my.skill1)
						{
							while(!key_enter){wait(1);}
							if(you.skill2 == 0)
							{
								var trig_percentage = 0;
								while(trig_percentage < 100)  //stops an infinite loop. 
								{
									trig_percentage += 2*time_step;
									ent_animate(me, "on", trig_percentage, ANM_CYCLE);
									wait(1);
								}
								you.skill2 = 1;
							}
							else
							{
								if(you.skill2 == 2)
								{
									var trig_percentage =0;
									while(trig_percentage < 100)  //stops an infinite loop. 
									{
										trig_percentage += 2*time_step;
										ent_animate(me, "off", trig_percentage, ANM_CYCLE);
										wait(1);
									}
									you.skill2 = 3;
								}								
							}
						}
					}
				}
				
			}
		}
		wait(1);
	}
}



Last edited by Dico; 10/21/15 10:13.