Jump to content

Problem with: Late Activation, Mist Respawn, Unit.getByName('unit'):isActive() etc


Recommended Posts

Posted (edited)

Hello.

There is a LATE ACTIVATION group named 'MyGroup-1' with only one unit called 'MyGroup-1'.

step-01. Activating the LATE ACTIVATION group, 'MyGroup-1':
                local group = Group.getByName('MyGroup-1')    
                                       trigger.action.activateGroup(group)

step-02. Destroying 'MyGroup-1' group:
                local myGroup = Group.getByName('MyGroup-1')
                                            Group.destroy(myGroup)

step-03. Respawning 'MyGroup' with Mist:
                mist.respawnGroup('MyGroup-1', true)

My problem is when: trying to set some conditions for the
respawned UNIT 'MyGroup-1' such as:

if Unit.getByName('MyGroup-1'):isAlive()
if Unit.getByName('MyGroup-1'):isActive()
if Unit.getByName('MyGroup-1'):inAir() == true

i've got NIL errors after the group has been Mist respawned,
but not before LATE ACTIVATION.

Where am i doing wrong ?

Thank you.

Edited by ADHS

Democracy was already invented, while Scrat was eating oak fruits.

  • ADHS changed the title to Problem with: Late Activation, Mist Respawn, Unit.getByName('unit'):isActive() etc
Posted
20 minutes ago, toutenglisse said:

I'd say you maybe try to access to respawned Unit at the same time that it is respawned.

Hello and thank you for your reply 😃.

Once you didn't find any error in the flow , i will try your directions.

Thank you (always)

Democracy was already invented, while Scrat was eating oak fruits.

Posted (edited)
On 10/25/2022 at 12:40 AM, toutenglisse said:

before checking with "if Unit.getBy...."

Thank you (once more), you are amazing man. You are helping us all here!

Next time, before i start filling variables with vacum,
i will start with a simple: IF UNIT then... 😃

PS: the *.*:isAlive() is not working with Units ?
Was the only variable that wasn't accepted. Any alternatives to use it ?

Thank you (always)

Edited by ADHS

Democracy was already invented, while Scrat was eating oak fruits.

Posted
7 hours ago, ADHS said:

PS: the *.*:isAlive() is not working with Units ?

I recommend you use Unit.isExist(someUnit) to ensure that the other accessors don’t abend.

note that it’s important to use the ‚class‘ method ‚Unit‘, as someUnit may not exist (in other words: someUnit:isExist() can fail if someUnit doesn’t exist, while Unit.isExist(someUnit) is safe.

 

  • Like 1
  • Thanks 1
Posted (edited)
7 hours ago, cfrag said:

it’s important to use the ‚class‘ method ‚Unit‘,

Hello and thank you very much for the xplanations and your time my friend.👍
Yes, class function "Unit.*(someUnit)" check & assignement from now on.
Thank you, thank you.

I had never pay attention to UNITs before, but in this mission i forced to
reconcider many ways and thinking. I thought that just with GROUP functions
all was fine till stucked with LATE ACTIVATION that assumes a GROUP: ALIVE.😡
So now, i have to re-code all of my functions.😇

Edited by ADHS

Democracy was already invented, while Scrat was eating oak fruits.

Posted
14 hours ago, cfrag said:

note that it’s important to use the ‚class‘ method

EVERYTHING WORKS FINE!

Thank you👍👍👍

Democracy was already invented, while Scrat was eating oak fruits.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...