I could use a little help with a little attributewrangle i'm making.
What i'm trying to achieve is a node to control the distribution of types of trees for a forest.
I've got 10 versions of treetype 1, 15 versions of treetype2 etc, 4 TreeTypes at the moment.
What i've got so far (and is working perfectly fine) is this:
i@Tree1_vars = chi("Tree1_variations");
i@Tree2_vars = chi("Tree2_variations");
i@Tree3_vars = chi("Tree3_variations");
i@Tree4_vars = chi("Tree4_variations");
f@total = ch("TreeType1") + ch("TreeType2")+ch("TreeType3")+ ch("TreeType4") ;
f@TreeType1_cutOff = ch("TreeType1")/@total;
f@TreeType2_cutOff = (ch("TreeType1")+ch("TreeType2"))/@total;
f@TreeType3_cutOff = (ch("TreeType1")+ch("TreeType2")+ch("TreeType3"))/@total;
if ( rand(@ptnum) < @TreeType1_cutOff ) {
f@selection = ceil(rand(@ptnum+45563)*@Tree1_vars);
s@instance = "/obj/Berk_v" + itoa(int(@selection));
}else if ( rand(@ptnum) < @TreeType2_cutOff ) {
f@selection = ceil(rand(@ptnum/23)*@Tree2_vars);
s@instance = "/obj/BroadleafBark_v" + itoa(int(@selection));i@Tree1_vars = chi("Tree1_variations");
i@Tree2_vars = chi("Tree2_variations");
i@Tree3_vars = chi("Tree3_variations");
i@Tree4_vars = chi("Tree4_variations");
f@total = ch("TreeType1") + ch("TreeType2")+ch("TreeType3")+ ch("TreeType4") ;
f@TreeType1_cutOff = ch("TreeType1")/@total;
f@TreeType2_cutOff = (ch("TreeType1")+ch("TreeType2"))/@total;
f@TreeType3_cutOff = (ch("TreeType1")+ch("TreeType2")+ch("TreeType3"))/@total;
if ( rand(@ptnum) < @TreeType1_cutOff ) {
f@selection = ceil(rand(@ptnum+45563)*@Tree1_vars);
s@instance = "/obj/Berk_v" + itoa(int(@selection));
}else if ( rand(@ptnum) < @TreeType2_cutOff ) {
f@selection = ceil(rand(@ptnum/23)*@Tree2_vars);
s@instance = "/obj/BroadleafBark_v" + itoa(int(@selection));
}else if ( rand(@ptnum) < @TreeType3_cutOff ) {
f@selection = ceil(rand(@ptnum*+1223)*@Tree3_vars);
s@instance = "/obj/EuropeanLinden_v" + itoa(int(@selection));
}else {
f@selection = ceil(rand(@ptnum-12387)*@Tree4_vars);
s@instance = "/obj/CypressOak_v" + itoa(int(@selection));
}
}else if ( rand(@ptnum) < @TreeType3_cutOff ) {
f@selection = ceil(rand(@ptnum*+1223)*@Tree3_vars);
s@instance = "/obj/EuropeanLinden_v" + itoa(int(@selection));
}else {
f@selection = ceil(rand(@ptnum-12387)*@Tree4_vars);
s@instance = "/obj/CypressOak_v" + itoa(int(@selection));
}
Just hit the create spare parms btn after this and Bob's your uncle.
What i would like however is to have the number of treetypes a bit more dynamic as well. I was thinking somewhere in the line of arrays but that's a bit difficult still for me, when it comes to syntax and the creation of the space parms.
Could someone point me in the right direction for this?
Tnx in advance.