Jump to content
Sign in to follow this  
Mercier

Module Creation MP - Loop

Recommended Posts

Hello guys, I've got a problem to create a spawning units module.
To be short, there is an error when I'm trying to launch a loop in my script.

In fact, this code works at any time but when I launch it through a module configuration, this code doesn't work.

for [{_i = 1}, {_i <= #_groups}, {_i = _i + 1}] do {blablabla...}

# is the error position shown in game.

So, it works when _groups isn't a variable but a number. If I write {_i <= 5}, it works...
So I concluded that my variables are not correctly broadcasted. How can I do that correctly?

I tried with private "_groups", nothing changes.

Of course, _groups is already define in that same script.

 

I also tried with

for "_i" from 0 to _groups step 1 do {...}

Same thing...

 

Thank's guys.

Share this post


Link to post
Share on other sites

(Count _groups) maybe???

I Don't really get what's the error . Maybe you should add the rest of the error text. Something like " expected something , type bla"

Share this post


Link to post
Share on other sites

As mister mentioned above, it's rather difficult to help if the error message nor more code info is given...

Start by checking what type of variable _groups is....

Kind regards,

Sanchez

Share this post


Link to post
Share on other sites

arma_error.png

 

My game is in French so I guess the error intel is "String type, number, not a number expected"

 

_groups is defined like this :

 

In my module config :

class groups
{
    displayName = "Number of groups";
    description = "Define the number of groups.";
    typeName = "TEXT";
    defaultValue = "2";
};

then in the script :

_logic = (_this select 0);
[blablabla]
_groups = (_logic getVariable "groups");
[blablabla]
for [{_i=1},{_i<=_groups},{_i=_i+1}] do {...}

When I write hint format ["%1",_groups] in the loop, _groups is correctly define. I'm lost x)

Share this post


Link to post
Share on other sites

Woops, I totally forgot you were working on a module.

Ryan and I had the same problem with the zombie module, the value people insert into the groups section of the module is a string, not a number.

ParseNumber the _groups variable or compile it to convert the string to a number.

Kind regards,

Sanchez

Share this post


Link to post
Share on other sites

It works! Thank you MrSanchez, you've been a great help!
Thank you too donelsarjo for taking time to look into.

_groups = parseNumber (_this select 1);

:) :) :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×