Defining non void functions in MNSCRIPT

ThomasDotCom

Well-known Member
Feb 6, 2021
3
1
31
Simple problem but couldn't find a solution as tutorials seem in early stages.
I'm trying to define a function that returns something, so I assume I would do for example:

Code:
number func(number parameter){
    return parameter;
}

number x = func(1);

though it doesn't like this.
I also tried using the keyword function however I got the error "Returning in void function or outside function scope" so I assumed you defined the function with its returned variable type.

I'm sure there is an easy solution and I'm just being an idiot,

Thomas
 

Metro

Lead Developer
Lead Developer
Employee
Group Moderator
Dec 26, 2020
74
90
71
You can specify a data type that you want a function to return like so:


C-like:
function<number> MyFunction(){
    return 1;
}

number MyNumber = MyFunction()

Of course you can replace <number> with <string> or <bool> etc depending on what you want to do.