Moments ago I had a nice idea how to store skills into an array easily using call by reference.
Works with A6.31.4, but should work with every GS version supporting call by reference.
So here's the code:
Code:
var player_data[400];
function copySkills(&skillvar, num)
{
var cnt = 0;
num = 100 * num;
while (cnt < 100) {
player_data[num + cnt] = skillvar[cnt];
cnt += 1;
}
return;
}
function loadSkills(&skillvar, num)
{
var cnt = 0;
num = 100 * num;
while (cnt < 100) {
skillvar[cnt] = player_data[num + cnt];
cnt += 1;
}
return;
}
Description:
Pass a skill as first parameter, this skill (memory adress) can now (as a var) be handled as an array and being stored into another array, or the other way round.
The second parameter just is a unique player number that defines the offset to create a multidimensional array (100 slots per actor/ entity).
And that's how you call it:
Code:
copySkills(my.skill1, my._player_number);
loadSkills(my.skill1, my._player_number);
You
always pass
skill1 since this is the start of the "skill-arrya" and player number is the offset, for example 0 or 4 or 17, but you have to take care about the correct setup of the player numbers.