Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
pierremgi

AddAction - handle problem

Recommended Posts

Hi,
I can't understand why the addAction handles are increasing even after nil.

To resume the problem, here is a repeatable test:

On Arma vanilla, SP preview, one player, one car named car1,

place a trigger radio Alpha in order to run the code on demand.

code:

0 = [] spawn {
  act = car1 addAction ["",""];
  hint str act;
  car1 removeAction act;
  act = nil;
};

On my mind, this code should hint 0 each time you call radio alpha.

I create an empty addAction, so the handle starts to 0, then i remove this action and kill the global variable container supposed to be the handle...

The problem is the global variable act still increases on each radio alpha hint, even if the console returns true for isNil act (or even isnil {car1 actionParams 0}.

 

Any idea on what occurs?

Thanks

Share this post


Link to post
Share on other sites
19 minutes ago, pierremgi said:

Hi,
I can't understand why the addAction handles are increasing even after nil.

To resume the problem, here is a repeatable test:

On Arma vanilla, SP preview, one player, one car named car1,

place a trigger radio Alpha in order to run the code on demand.

code:


0 = [] spawn {
  act = car1 addAction ["",""];
  hint str act;
  car1 removeAction act;
  act = nil;
};

On my mind, this code should hint 0 each time you call radio alpha.

I create an empty addAction, so the handle starts to 0, then i remove this action and kill the global variable container supposed to be the handle...

The problem is the global variable act still increases on each radio alpha hint, even if the console returns true for isNil act (or even isnil {car1 actionParams 0}.

 

Any idea on what occurs?

Thanks

 

Why exactly should this code return 0 after removing the action?

Doesn't make any sense.

addAction ID increases with every action added to the object. No matter if the object currently has any actions on it or not.

This is also what's stated at the wiki entry, first action ID = 0, second one = 1 etc.

Your global variable act doesn't increase, it just holds the ID of the current addAction ID. The ID is what increases.

Nothing wrong with that.

 

Cheers

Share this post


Link to post
Share on other sites
4 hours ago, Grumpy Old Man said:

 

addAction ID increases with every action added to the object. No matter if the object currently has any actions on it or not.

This is also what's stated at the wiki entry, first action ID = 0, second one = 1 etc.

 

I understood that.

 

4 hours ago, Grumpy Old Man said:

Your global variable act doesn't increase, it just holds the ID of the current addAction ID. The ID is what increases.

Nothing wrong with that.

 

I thought I could "kill" the handle with nil. In fact, i just duplicated it (with the variable: act) and killed the copy, if I'm right.

I think it's the same for any handle (on EHs or else).

So, we can remove the action or EH, but not the handle, staying somewhere in the game.

 

My former test was to grab all actions on an object, in order to duplicate them after respawn. I don't have a real problem with the code but I was surprised to see a growing loop: for "_i" from 0 to (_obj addAction ["",""]) do {<code>}; even after removing this "beacon" action.

 

Thanks for your comment.

Share this post


Link to post
Share on other sites
2 hours ago, pierremgi said:

I thought I could "kill" the handle with nil. In fact, i just duplicated it (with the variable: act) and killed the copy, if I'm right.

I think it's the same for any handle (on EHs or else).

this is correct. U just niled the copy not the handle.

 

2 hours ago, pierremgi said:

So, we can remove the action or EH, but not the handle, staying somewhere in the game.

I guess this is wrong. I think u remove the handle with removeAction. Same for EH's

Share this post


Link to post
Share on other sites
1 hour ago, sarogahtyp said:

this is correct. U just niled the copy not the handle.

 

I guess this is wrong. I think u remove the handle with removeAction. Same for EH's

Not so evident! In my trigger radio alpha:

if i write:

0 = [] spawn {
  act = car1 addAction ["",""];
  hint str act;
  car1 removeAction act;
  act = nil;
};

The hint increases 0,1,2... each time I call the radio A. No problem. Let's say the Ids have their own life and I just niled the "copy" of the handle. There is neither more actionParams nor possibility to call this action. Fine!

 

On the other hand, for EHs:

 

0 = [] spawn {
  act = car1 addEventHandler ["killed",""];
  hint str act;
  car1 removeEventHandler ["killed",act];
  act = nil;
};

The hint stays to 0. Tada. Here it's not an Id? More an index? a handle if i'm right.

So, two different behaviors for some values which could seem very similar, somewhere.

 

Perhaps, I'm hurting the bottom of the flies with boxing gloves, but EH seems to me much more "clean" to remove than addAction. Is there anything to do instead of saving useless ids?

Share this post


Link to post
Share on other sites

×