0 registered members (),
18,767
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
Senior Expert
|
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
Siegewolf
OP
Newbie
|
OP
Newbie
Joined: Mar 2009
Posts: 23
|
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
Locoweed
Expert
|
Expert
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.
#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
Locoweed
Expert
|
Expert
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.
#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
Locoweed
Expert
|
Expert
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:
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]
#296781
11/02/09 22:38
11/02/09 22:38
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
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.
|
|
|
|