Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Helmet
22
Years of Service
User Offline
Joined: 17th Oct 2002
Location: Brazil
Posted: 5th Jan 2003 19:30
How can I use the command function and for what does it serve.
Correct me if I wornged something.
MM is good
Attreid
21
Years of Service
User Offline
Joined: 27th Nov 2002
Location:
Posted: 5th Jan 2003 20:55
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 :



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 :




that's all, and it isn't hard

I'm following John, but I'm not john.
Lol, it is funnier in french

Login to post a reply

Server time is: 2024-11-23 20:55:04
Your offset time is: 2024-11-23 20:55:04