Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,561 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Removing objects in subfunctions #296312
10/30/09 21:41
10/30/09 21:41
Joined: Mar 2009
Posts: 23
S
Siegewolf Offline OP
Newbie
Siegewolf  Offline OP
Newbie
S

Joined: Mar 2009
Posts: 23
In this code when my action is finished, it never reaches pan_remove in my function. Generally, how do I make sure object created in subfunction is removed when the action completes?

Code:
action my_action()
{
 	my_function();
	while (...)
	{
		...
		wait(1);
	}
}

function my_function()
{
 	PANEL* pan = pan_create(...);
	while (me != NULL)
	{
		...
		wait(1);
	}
	pan_remove(pan);
}



Re: Removing objects in subfunctions [Re: Siegewolf] #296318
10/30/09 22:09
10/30/09 22:09
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
what do you mean by action completes, me pointer wont get NULL unless you remove the entity.


3333333333
Re: Removing objects in subfunctions [Re: Quad] #296324
10/30/09 22:39
10/30/09 22:39
Joined: Mar 2009
Posts: 23
S
Siegewolf Offline OP
Newbie
Siegewolf  Offline OP
Newbie
S

Joined: Mar 2009
Posts: 23
Originally Posted By: Quadraxas
what do you mean by action completes, me pointer wont get NULL unless you remove the entity.


Yes I mean when entity is removed. In my_action there is actually ent_remove(me) statement which is executed under some condition. So the entity disappears but panel created in my_function remains on screen.

Re: Removing objects in subfunctions [Re: Quad] #296325
10/30/09 22:46
10/30/09 22:46
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
As Quadraxas stated, the code won't work as you have it written in most cases.

Think more like this code, hit the U key and see what happens.

Code:
#define Health    skill20

action my_action()
{
	my.Health = 100;
 	my_function();
	while (my.Health > 0)
	{
		...
                if(key_U)
		{
			my.Health = 0;
		}

		wait(1);
	}
        ent_remove(my);
} 

function my_function()
{
 	PANEL* pan = pan_create(...);
	while (my != NULL)
	{
		...
		wait(1);
	}
	pan_remove(pan);
}



Think that is more what you was trying to do.

Loco


Professional A8.30
Spoils of War - East Coast Games
Re: Removing objects in subfunctions [Re: Locoweed] #296326
10/30/09 22:51
10/30/09 22:51
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
If that doesn't work, this definitely will. This is the type of method I prefer to use for cleaning up sub-functions because I know exactly what is going to happen.

Code:
#define Health    skill20

action my_action()
{
	my.Health = 100;
 	my_function();
	while (my.Health > 0)
	{
		...
                if(key_U)
		{
			my.Health = 0;
		}

		wait(1);
	}
	wait(1);  // this wait(1) gives time for all sub-functions to end before removing MY
        ent_remove(my);
} 

function my_function()
{
 	PANEL* pan = pan_create(...);
	while (my.Health > 0)
	{
		...
		wait(1);
	}
	pan_remove(pan);
}




The problem is that when you use ent_remove(my); it will also stop all functions that are currently running that MY pointer also, so it might quit function before ptr_remove() is reached.

Loco


Professional A8.30
Spoils of War - East Coast Games
Re: Removing objects in subfunctions [Re: Locoweed] #296327
10/30/09 22:59
10/30/09 22:59
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
And one last possible solution would be using the
proc_mode =
PROC_GLOBAL - the current entity function is not terminated when its my entity is removed by ent_remove, or when the level is changed. A7.76

like this, might work also:

Code:
action my_action()
{
 	my_function();
	while (...)
	{
		...
		wait(1);
	}
}

function my_function()
{
	proc_mode = PROC_GLOBAL; // lite-C

 	PANEL* pan = pan_create(...);
	while (me != NULL)
	{
		...
		wait(1);
	}
	pan_remove(pan);
}



That could possibly work also, hope that helps,
Loco


Professional A8.30
Spoils of War - East Coast Games
Re: Removing objects in subfunctions [Re: Siegewolf] #296769
11/02/09 21:28
11/02/09 21:28
Joined: Mar 2009
Posts: 23
S
Siegewolf Offline OP
Newbie
Siegewolf  Offline OP
Newbie
S

Joined: Mar 2009
Posts: 23
This system with skills is good enough, I will use it in the future. As for this global proc system, I do not have new enough lite-c version so I cannot try it.

Thanks.

Re: Removing objects in subfunctions [Re: Siegewolf] #296781
11/02/09 22:38
11/02/09 22:38
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
I do not have new enough lite-c version...


Why not update?

Last edited by Widi; 11/02/09 22:41.
Re: Removing objects in subfunctions [Re: Siegewolf] #296975
11/04/09 03:16
11/04/09 03:16
Joined: Mar 2009
Posts: 23
S
Siegewolf Offline OP
Newbie
Siegewolf  Offline OP
Newbie
S

Joined: Mar 2009
Posts: 23
I am using free version of lite-C and as far as I know the one I downloaded from this site originally is still only free version available. It is February release still if I am not mistaken.

As for commercial versions, I would rather see first whether I can make at least 80% of the game I am working on currently, before I buy it. Things are looking promising and I am really looking forward to finish this game. But I am still not too optimistic, considering that I am dealing here with POINTER based language which means... a lot of possible unsolvable trouble. Memory leaks, uncatchable phantom bugs due to some nonsense in the memory, etc...


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

Gamestudio download | 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