Melscript

ok, here we go
sorry, I have to bother anyone with this, but:
if there are people outside to whom it is err kind of pleasure?!? or maybe it is worth a big lol to have a look at a completely amateur script..
well: my situation is that I am not a programmer, never was, I met mel 2 weeks ago and I desperately need help on this one!
so this should be a script using a simple vector formula and should give me in the end some generations of points, arranged in 3d kind of a confused decision tree ...
instead of building the generation step for step, I decided to use sphrand as vector function

well, here it is:

//proc tree with recursion

proc tree(vector $vector_gen, int $points) {
vector $ep; // endpoint

vector $addvec = sphrand(rand(2,10));
$ep = $vector\_gen + $addvec;


curve -d1 ($vector\_gen.x) ($vector\_gen.y)  ($vector\_gen.z)  $ep ($ep.x) ($ep.y) ($ep.z);
Sphere -d1 ($ep.x) ($ep.y) ($ep.z) -ax 0 1 0 -ssw 0 -esw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -nsp 4 -ch 1;    //syntax ok?



int $maxpoints = 9;  //zahl austauschbar
if ($points > $maxpoints) break; //need break? but. only in use with while & for possible...

//rekursion
$points++;
tree($ep);

}

select -all;
delete;

vector $startP = <>;
tree($startP, 0); // number changeable

ok, so dont laugh , it is my first script after helloworld, I would be pleased if you could help me with this!!!
but please dont ignore what I 've already written, just how to change syntax correctly? or what to do with the break? how to make it run so it would give optically a decision tree???
big SOS

mnake the proc return a int. and then usse if something return 1; and it will quite the recursion.

Aslos by the way you have bad habit of using a global wavr pass it to your script too.

QUOTE(Joojaa @ 01/29/06, 04:38 PM) [snapback]226527[/snapback]
mnake the proc return a int. and then usse if something return 1; and it will quite the recursion.
Aslos by the way you have bad habit of using a global wavr pass it to your script too.

well ok, but that is a possible way for the counter..:slight_smile: IF I am able to write it..*g
but: I think there is much more in the syntax not working...
and to me it is not easy to correct (my own stuff, yes, I admitt)

thx for the first reply!

CODE
proc int tree(vector $vector_gen, int $numberOfSegments) {
vector $ep;
vector $addvec = sphrand(rand(2,10));
$ep = $vector_gen + $addvec;
curve -d 1 -p ($vector_gen.x) ($vector_gen.y) ($vector_gen.z)
                -p ($ep.x) ($ep.y) ($ep.z)
          -k 0 -k 1;
sphere -p ($ep.x) ($ep.y) ($ep.z) -ax 0 1 0 -ssw 0 -esw 360
       -r 0.1 -d 3 -ut 0 -tol 0.01 -s 4 -nsp 2 -ch 1;
$numberOfSegments--;
if ($numberOfSegments <= 0) return 1;
tree($ep,$numberOfSegments);
return 1;
}
tree(<>, 10);

i modified your logic a bit to include the number of segments instead of some random to get to value.

joojaa!!!
wow it works!!
well, dont know how to thank you!!
at least it does something!!!!
AND it looks like a confused tree...(like me till now)

great great great....

thx very much for the time you lent me!!!!

XXX

ps. again: great!!!

well its your code i just modified it so it makes sense.

Use rot unit and mag for a tree not sphrand!

*g
well u didnt see my desperate thoughts bout this decision tree script
really new to mel and scripting - every action seeming to you very short is a long quest for me, I suppose:-)

ok, I'll try with your suggestions...

now I'll try to go for more of the rendering of that strange space decision tree for human behaviour to choose one or another planet or..well dunno...

thx again