Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 609 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Managing objects[scene objects] #265558
05/13/09 05:51
05/13/09 05:51
Joined: Apr 2009
Posts: 298
Southern Oceans
KiwiBoy Offline OP
Member
KiwiBoy  Offline OP
Member

Joined: Apr 2009
Posts: 298
Southern Oceans
Hey folks,

Been trying to adapt a script from a buddy that creates an object, controlls its alpha and removes it from the scene when no longer required to be ready again to recreate.
Most of it is working fine EXCEPT that when the object is assigned its action/function, the functions never stop.

Having worked at this all day I can no longer see straight so if anyone could help me out here I would feel indebted.

Code:
var MKt1 = 1;

function remove_t1();
function tree1();

ENTITY* marker;

#define health skill40


function tree1()
{
	while(player == NULL){wait(1);}
   my.red = 200;
   my.green = 220;
   my.blue = 200;
   set(my, TRANSLUCENT);
   my.alpha = 0;
   set(my, PASSABLE);
   set(my, SHADOW); 
  	my.health = 100; 
    while (1)
    {  
       while (vec_dist(my.x, player.x) > 800){wait(1);}
    	 if ((vec_dist(my.x, player.x) < 800) && (MKt1 ==0))
       {
       	if(my.alpha < 100)
            {
            	my.alpha += 15 * time_step;
            	if(my.alpha > 100)
            	{
            		my.alpha = 100;
					}
				}
		 	}
       	else
       	{
          	my.alpha -= 5 * time_step;	
          	my.health -= 5 * time_step;
          	if((my.alpha < 0)&&(my.health < 0))
            	{
            		my.alpha = 0;
            		my.health = 0;
					}
          }
       
       wait (1);
       remove_t1();
    }
}


function remove_t1()
{
	while(vec_dist(my.x, player.x) < 900){wait(1);}
	if ((vec_dist(my.x, player.x) > 900)&&(MKt1 ==0))
	{ 
      if((my.health)&&(my.alpha))
       {
        	my.health = 0;
       	my.alpha = 0;
       	wait(-1);
       	ent_remove(me);
			MKt1 = 1;
       }
	}
}
action makem()
{
	while(player == NULL){wait(1);}
	marker = me;
   set(my, PASSABLE);
   while(1)
   {
   	if((vec_dist(my.x, player.x) < 800) && (MKt1 == 1))  
				{
					ent_create ("cbabe_unanim.mdl", vector(-3554.000, 39.000, -150.000), tree1);
					MKt1  = 0;
				}
				wait(1);
	}
   
}


The way it is written out now allows the script to work in a basic sense in that the expected behaviour is exhibited successfully but maybe thats why it dont work properly?

Thanks....

Re: Managing objects[scene objects] [Re: KiwiBoy] #265594
05/13/09 09:32
05/13/09 09:32
Joined: May 2008
Posts: 331
Lithuania, Vilnius
Jaxas Offline
Senior Member
Jaxas  Offline
Senior Member

Joined: May 2008
Posts: 331
Lithuania, Vilnius
don't use functions for object! use actions smile use watches in SED to track why function don't stop wink


The smaller the bug, the harder it is to kill.
_________________________________________
Forklift DEMO (3dgs)
Re: Managing objects[scene objects] [Re: Jaxas] #265598
05/13/09 09:45
05/13/09 09:45
Joined: Apr 2009
Posts: 298
Southern Oceans
KiwiBoy Offline OP
Member
KiwiBoy  Offline OP
Member

Joined: Apr 2009
Posts: 298
Southern Oceans
Thanks for reply.
Took the hint and removed the while looop and so now the process functions that way as expected smile Thanks.
Just have to tweak the alpha to work now and it will be spot on.



Last edited by KiwiBoy; 05/13/09 11:00.
Re: Managing objects[scene objects]SOLVED [Re: KiwiBoy] #265611
05/13/09 11:01
05/13/09 11:01
Joined: Apr 2009
Posts: 298
Southern Oceans
KiwiBoy Offline OP
Member
KiwiBoy  Offline OP
Member

Joined: Apr 2009
Posts: 298
Southern Oceans
....Ok, solved all probs and script now works as expected.

Code:
action tree1()
{
	while(player == NULL){wait(1);}
   my.red = 200;//testing purposes
   my.green = 220;//testing purposes
   my.blue = 200;//testing purposes
   set(my, TRANSLUCENT);
   my.alpha = 0;
   set(my, PASSABLE);
   set(my, SHADOW); 
    while (1)
    {  
       while (vec_dist(my.x, player.x) > 800){wait(1);}
    	 if (vec_dist(my.x, player.x) < 800)
       {
       	while(my.alpha < 100)
            {
            	my.alpha += 5 * time_step;
            	if(my.alpha >= 100)
            	{
            		my.alpha = 100;
					}
					wait(1);
				}
		 	}
       	else
       	{
       		if((vec_dist(my.x, player.x) > 800)&&(my.alpha > 0))
       		{
          	my.alpha -= 5 * time_step;	
          	my.health -= 5 * time_step;
          	if(my.alpha <= 0)
            	{
            		my.alpha = 0;
					}
          }
          }
       remove_t1();
       return;
       
    }
}


function remove_t1()
{
	while(vec_dist(my.x, player.x) < 900){wait(1);}
	if ((vec_dist(my.x, player.x) > 900)&&(MKt1 ==0))
	{ 
      if(my.alpha)
       {
       	my.alpha = 0;
       	wait(-1);
       	ent_remove(me);
			MKt1 = 1;
       }
	}
}




Last edited by KiwiBoy; 05/13/09 11:01.
Re: Managing objects[scene objects]SOLVED [Re: Jaxas] #265826
05/14/09 12:39
05/14/09 12:39
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
Originally Posted By: Jaxas
don't use functions for object! use actions smile use watches in SED to track why function don't stop wink

i use functions for actions laugh

Re: Managing objects[scene objects]SOLVED [Re: darkinferno] #265835
05/14/09 14:13
05/14/09 14:13
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
function and action are the same. The only different is that actions are showing at WED and can given to a Entity.

Re: Managing objects[scene objects]SOLVED [Re: Widi] #265838
05/14/09 14:33
05/14/09 14:33
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
i know but if you type the function's name into the action select box then it uses your function just as an action smile


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1