Proudly present, the 'fast' finalized version,
thanks to FRAJO*DELETED* old code for 100 skills *DELETED*
Fot those who care about script time execution
I'm using in this version some kind of 'linked list'
Code:
define Skills, SKILL60; //define skill for handle storing
entity* GetSetEnt; //pointer for SKILL box entity
string PsEnt=<ps.mdl>; //create very small MDL5 entity (it takes 296 bytes only)
action PsEntAction{ //action for our SKILL box
my.invisible=on; //invisible passable static
my.passable=on;
my.dynamic=off;
}
function GetArr(&Arr, SkillNum){ //helper function to get skill by index
return(Arr[SkillNum]);
}
function SetArr(&Arr, SkillNum, SkillVal){ //helper function to set skill by index
Arr[SkillNum]=SkillVal;
}
function GetSkill(EntName, SkillNum){ //Get SkillNum value for EntName entity
if (!EntName){return(-1);} //No entity, ERROR
if (SkillNum<1){return(-1);} //No Skill, ERROR
GetSetEnt=EntName; //type casting ;)
SkillNum=int(SkillNum); //for a case
if (SkillNum>100){
if (GetSetEnt.Skills==0){ //No entity for skill storing
GetSetEnt.Skills=handle(ent_create(PsEnt,my.x,PsEntAction)); //create it
}
GetSetEnt=ptr_for_handle(GetSetEnt.Skills); //set pointer to next entity
GetSkill(GetSetEnt, SkillNum - 100); //and get skill for next entity
}else{
return(GetArr(GetSetEnt.Skill1, int(SkillNum))); //skill < 100, get it
}
}
function SetSkill(EntName, SkillNum, SkillVal){ //Set SkillNum to SkillVal for EntName entity
if (!EntName){return(-1);} //No entity, ERROR
if (SkillNum<1){return(-1);} //No Skill, ERROR
GetSetEnt=EntName; //type casting ;)
SkillNum=int(SkillNum); //for a case
if (SkillNum>100){
if (GetSetEnt.Skills==0){ //No entity for skill storing
GetSetEnt.Skills=handle(ent_create(PsEnt,my.x,PsEntAction)); //create it
}
GetSetEnt=ptr_for_handle(GetSetEnt.Skills); //set pointer to next entity
SetSkill(GetSetEnt, SkillNum-100, SkillVal); //and set skill for next entity
}else{
SetArr(GetSetEnt.Skill1, SkillNum, SkillVal); //skill < 100, set it
}
return(0); //no ERROR
}
function EntRemoveSkills(EntName){ //remove SKILL box, call this to remove entity, not ent_remove(EntName)
var TempEntHandle=0; //handle for current entity
if (!EntName){return(-1);} //No entity, ERROR
GetSetEnt=EntName; //type casting ;)
if (GetSetEnt.Skills!=0){ //No entity for skill storing
TempEntHandle=handle(GetSetEnt); //store current entity
RemoveSkills(ptr_for_handle(GetSetEnt.Skills)); //remove next entity
}
ent_remove(ptr_for_handle(TempEntHandle)); //remove current entity
return(0); //no ERROR
}
Sorry for posting as answer, edit disabled for me
usage example:
Code:
define MySkill456, 456; //define name for skill456 (56th skill on 4th entity in list)
define MySkill301, 301; //define name for skill301 (1st skill on 3 entity in list)
...
SetSkill(you,MySkill456,1024); //you.skill456=1024
SomeVar=GetSkill(my,MySkill301); //SomeVar=my.skill301
...
SetSkill(my,6,100); //my.skill6=100 :) this and next are useless just for fun
SomeVar=GetSkill(my,6); //SomeVar=my.skill6
...
EntRemoveSkills(me); //ent_remove(me);
...
Feel free to use this stuff.