GetNumber. The arguments that this function accepts on the RED4ext side are very specific and unrelated to the arguments it accepts in Redscript, and need to be particular types.
floatin the header's
float* aOutis the return type - it can also be a RTTI type like
RED4ext::GameObject, but it needs to be a pointer. If the function takes no arguments, you can use
void* aOutin the header instead.
Int32as arguments on the Redscript side, and to get these values, we have to use
RED4ext::GetParameterand the stack frame that's passed into our function through RED4ext. We'll retrieve them in-order, passing the function each of our variables' references. Once we've read the last argument, we need to run
aFrame->code++to let the system know we're done reading the arguments.
*aOuta value, being sure to use the pointer. If the function has a
Voidreturn type, we can omit this line.
RED4ext::CClassFunction::Createfunction, we pass the type we've created, the long & short names of the function as strings (how it'll be referenced in Redscript), and then a reference to the function itself.
isNativeflag to the function. The arguments need to be registered to the function using the name of the type (like it is in Redscript), followed by the argument name. The return's type is set in the same way, using the name of the type as a String.
nativekeywords, and the function added without a body (depending on your Redscript version, the semicolon at the end might need to be omitted):