Jump to content

Add set/getdarray


Senshuken

Recommended Posts


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  11
  • Reputation:   0
  • Joined:  04/14/12
  • Last Seen:  

add

  • setdarray
  • getdarray

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

add

  • setdarray
  • getdarray

I think getelementofarray can be used to do some of this.

For example:

set .@group, 1;

// for each element in .items_1[]
for (set .@i,0; .@i<10; set .@i, .@i+1) {
set .@this_item, getelementofarray(getd(".items_"+.@group), .@i);
// do stuff with .@this_item

}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  11
  • Reputation:   0
  • Joined:  04/14/12
  • Last Seen:  

add

  • setdarray
  • getdarray

I think getelementofarray can be used to do some of this.

For example:

set .@group, 1;
// for each element in .items_1[]
for (set .@i,0; .@i<10; set .@i, .@i+1) {
set .@this_item, getelementofarray(getd(".items_"+.@group), .@i);
// do stuff with .@this_item

}

Sorry, I meant it as a dynamic array setter and getter.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  40
  • Reputation:   20
  • Joined:  12/31/11
  • Last Seen:  

This does already work with setd and getd:

getd(".somearray["+.@i+"]");
setd ".somearray["+.@i+"]", 0;

or did you mean something like that:

setdarray ".somearray", 0, 5, 4, 3, 6;

but here getdarray would make no sense, since you can only get 1 value at a time

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  11
  • Reputation:   0
  • Joined:  04/14/12
  • Last Seen:  

This does already work with setd and getd:

getd(".somearray["+.@i+"]");
setd ".somearray["+.@i+"]", 0;

or did you mean something like that:

setdarray ".somearray", 0, 5, 4, 3, 6;

but here getdarray would make no sense, since you can only get 1 value at a time

You're right, getdarray would be pointless, but yes I do mean the setdarray ".somearray", 0, 1, 2, 3, 4

Link to comment
Share on other sites

  • 6 months later...

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  44
  • Reputation:   48
  • Joined:  11/19/11
  • Last Seen:  

you can already do this using a combination of getd and setarray.

setarray getd(".test[0]"), 1, 2, 3, 4, 5;

Also sorry for the necro... =P

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

Added the array example to script_commands.txt in r16963 since it could be helpful. :>

Link to comment
Share on other sites

×
×
  • Create New...