it's easy
a function is a new command that you make. there are three kinds of functions :
- the functions that make an action
- the functions that give a value
- the functions that make an action and guve a value
to make a function, it's easy :
function()
rem commands
endfunction
between ( and ), you can put variables, here's an example :
add(a#,b#)
result# = a# + b#
endfunction result#
look, after endfunction, I write the variable that the function has to give back
and use it is easy :
print add(16.57,63.975)
but you can do others things :
function moveOnAxeX(obj,var#)
x# = object position x(obj)
y# = object position y(obj)
z# = object position z(obj)
position object obj,x#+var#,y#,z#
endfunction
look, there isn't any variable after endfunction 'cause I don't want that it give a result
between function and endfunction you can use all the db commands, but warning, this code don't work because the variables that are in the function are only in it :
do
ordi()
print a#
sync
loop
function ordi()
a# = 25.369
endfuction
it will print 0 and not 25.369 because a# is in the function, and even if it want, it cannot go out
here's a good function that give the distance between two objects :
function distances(A,B)
1x# = object position x(a)
1y# = object position y(a)
1z# = object position z(a)
2x# = object position x(b)
2y# = object position y(b)
2z# = object position z(b)
dist# = SQRT(( (1x#-2x#)^2 + (1y#-2y#)^2 + (1z#-2z#)^2))
endfunction dist#
that's all, and it isn't hard
I'm following John, but I'm not john.
Lol, it is funnier in french