Jump to content
Sign in to follow this  
Pundaria

How to access array?

Recommended Posts

I don't know what is array and how to access it. Dude, teach me... plz. SOS!

Share this post


Link to post
Share on other sites

So I use what to type or find "_array = [elementOne, elementTwo, ..., lastElement]" these kinda stuff? ARMAEdit???

Share this post


Link to post
Share on other sites

arrays can be defined in scripts eg:

_myarray = [element0,element1,element2];

specific elements in an existing array can be changed or referenced:

_myelement = _myarray select 3;

_myarray select 3 = _newelement; <--- never tried this, think it should work though =]

you can also pass arguments to a script using arrays:

[soldier,helicopter,[getpos player]] execvm "myawesomescript.sqf";

we're bascially talking about script editing here, which can be done using notepad. Just change the file extension from .txt to .sqf

Share this post


Link to post
Share on other sites

_myarray select 3 = _newelement; <--- never tried this, think it should work though =]

It could work, haven't tried it either, but when I did dabble around with these things I used:

http://community.bistudio.com/wiki/Array#Setting_elements

Example

_myarray = ["Rofl", "Kek", "LMAO"];

_myarray set [1, "Hello"]

_myarray is now:

_myarray = ["Rofl", "Hello", "LMAO"];

Please note that the first element in an array is referred to as 0

Share this post


Link to post
Share on other sites
_myelement = _myarray select 3;

_myarray select 3 = _newelement; <--- never tried this, think it should work though =]

That will not work. Assignment operators only work with variables. Use set to set the value of array elements.

Share this post


Link to post
Share on other sites

Well that's that sorted then...hope the original question has been answered.

Also nice to get a bit of discussion going about how to fiddle around with arrays - they are a powerful scripting tool which really help when processing the same command for mulitple units or when passing groups around a script.

Share this post


Link to post
Share on other sites

If I'm not mistaken, the BI_function library has some new push/pop array functions for fast addition of elements to arrays

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  

×