Jump to content

update variable inside custom function (vex)


ikoon

Recommended Posts

Please, in vex, is it possible to define a custom function, which will update the variable, without classic a = function(a) assignment?

For example:

f@big = 1.5;
clamp01(f@big); // function clamps between 0 and 1
f@result = f@big; // result is 1.0

 

I found nothing, but I am newbie, sorry. Is this technique called "pass by reference", or also "pass a pointer"? Probably not possible in vex?

Link to comment
Share on other sites

I ikoon,

sure you can, here's examples :

vector pos = @P;
void cl(vector pos)
{
    pos.y = 0;
}
cl(@P);
void clamp01(float cl)
{
    cl = clamp(cl,0,1);    
}

f@big = 1.5;
clamp01(@big); // function clamps @big between 0 and 1
f@result = @big; // paste @big to @result

 

Documentation about it

Hope it help,

Gab.

 

 

Edited by Nache
misspelled name
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...