BrutusMUD help

SCRIPT USER FUNCTIONS

Level: 61

In every script you can define your own functions. You can use these functions
from every script in the same zone. Functions must be defined before any script
code.

Special variables are:
argc - number of given parameters
argv[0] - first parameter
argv[argc-1] - last parameter

Another usable variables:
every mobs/obj (my.), zone or global variables
standard script variables are hidden in user functions!!!

Examples:

define and use function:
--------------------- Cut here ---------------------
function helo{
return 1
}

say function return value: @(helo())
--------------------- Cut here ---------------------

More complicated example
now call function with @ before parameter
it causes when parameter value is changed, new value
will be stored to original parameter


--------------------- Cut here ---------------------
function another
{
say Function start, number of parameters: @argc

#changing value of first parameter
say first parameter before change: @argv[0]

let argv[0] = 5

say first parameter after change: @argv[0]

say Function End
return argc
}

let val = 1
say value val before function: @val
say return value: @(another(val, 2))
say value val after function: @val
mppromptroom

say second call of function with @ before first parameter

mppromptroom
say value val before function: @val
say return value: @(another(@val, 2))
say value val after function: @val
--------------------- Cut here ---------------------

 

Back to index

 
 

© Michal Kumžák 2011 | Provozováno na CMS E4E | Mapa webu