
Additionally, if the rank names are not known in the engine anymore (just via C4Script), some fields e.g. in the stats of a clonk in a C4P can not be filled (wasn't there a "Next rank: blabla" or something) plus can't be displayed in the GUI anymore. Only in the game, when all definitions have been loaded.
However if we were to use the old engine-based system and do not shrink down the rank system to a mere store of the rank number and experience points, there would have to be a possibility to access the rank graphics for a crew member via c4Script (SetGraphics).
Here is the implementation, I think you can see why I am not so content with this. Discuss.
/*
Standard rank definition
Author: Newton
This is a ressource object in which the rank graphics and the rank names
are stored. Any (crew) object can freely define which rank graphics it
wants to use by defining the function func RanksID() { return [myrankid] }.
Any other ranks definition should include this object
*/
global func GetRankName(int rank)
{
var idRank;
// extra rank definition
if(this)
idRank = this->~RanksID();
if(!idRank)
idRank = RANK;
return DefinitionCall(idRank,"RankName",rank);
}
public func RankName(int rank, int extra)
{
if(rank < 0) return nil;
var rrank = rank % RegularRankCount();
var erank = (rank / RegularRankCount() % ExtraRankCount());
// here you see the limits of C4Script
// r=Format("$Rank%d",rrank); is not possible
var r,e;
if(rrank==0) r="$Rank0$";
else if(rrank==1) r="$Rank1$";
else if(rrank==2) r="$Rank2$";
else if(rrank==3) r="$Rank3$";
else if(rrank==4) r="$Rank4$";
else if(rrank==5) r="$Rank5$";
else if(rrank==6) r="$Rank6$";
else if(rrank==7) r="$Rank7$";
else if(rrank==8) r="$Rank8$";
else if(rrank==9) r="$Rank9$";
else if(rrank==10) r="$Rank10$";
else if(rrank==11) r="$Rank11$";
else if(rrank==12) r="$Rank12$";
else if(rrank==13) r="$Rank13$";
else if(rrank==14) r="$Rank14$";
else if(rrank==15) r="$Rank15$";
else if(rrank==16) r="$Rank16$";
else if(rrank==17) r="$Rank17$";
else if(rrank==18) r="$Rank18$";
else if(rrank==19) r="$Rank19$";
else if(rrank==20) r="$Rank20$";
else if(rrank==21) r="$Rank21$";
else if(rrank==22) r="$Rank22$";
else if(rrank==23) r="$Rank23$";
else if(rrank==24) r="$Rank24$";
if(erank==1) e = Format("$RankExtra1$",r);
else if(erank==2) e = Format("$RankExtra2$",r);
else if(erank==3) e = Format("$RankExtra3$",r);
else if(erank==4) e = Format("$RankExtra4$",r);
if(erank) return e;
else return r;
}
public func RegularRankCount() { return 25; }
public func ExtraRankCount() { return 4; }

I think you can use Isilkor's new script functions to access string table entries.
Anyway: Why exactly are you moving rank names and symbols into script? What's the advantage?
> I think you can use Isilkor's new script functions to access string table entries.
Yes,
r = Translate(Format("Rank%d", rrank));
should work here.
Maybe we could introduce string manipilation add operator:
e="$Rank"+IntToStr(erank)+"$"
The
$foo$
syntax isn't actually evaluated at run time, but works like a simple text replacement (think C preprocessor).
oops.
i didn't know this.
but the post above looks weird.
Maybe this:
i didn't know this.
but the post above looks weird.
Maybe this:
const ranks=["$Rank0$","$Rank1$", .....];
return ranks[ranknr];

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill