It is a noob question, but as I can't search the forum...
What is the syntax for calling a function that returns a value but has no parameters?
Thanks,
Thierry
Sorry, this doesn't work, at least for me. Quest answers that there can be no null parameters. By the way, the "null parameter" is called "key".
Ok, I know, I could update a global variable, but "my" solution would be more elegant.
Also, parens are optional if there are no arguments. So
x = Myfunction()
or
x = MyFunction
But it sounds like what Pertex said. :)
in code:
http://docs.textadventures.co.uk/quest/elements/function.html
// defining (setting up) the Function (with NO Parameters but it DOES RETURN a Value):
<function name="NAME_OF_YOUR_FUNCTION" type="THE_RETURN_ATTRIBUTE_TYPE">
// whatever scripting
return (YOUR_VALUE_WHICH_MUST_MATCH_UP_WITH_YOUR_SET_RETURN_TYPE_IN_THE_FUNCTION'S_HEADER_ABOVE)
</function>
// calling the Function (and setting it's RETURN Value to be stored in a VARIABLE --- you MUST do something with the RETURNED VALUE, storing it in a VARIABLE or having another script use it, else you'll get an ERROR!):
VARIABLE = NAME_OF_YOUR_FUNCTION
in the GUI~Editor:
// defining the Function:
Function -> Add -> Name: NAME_OF_YOUR_FUNCTION
NAME_OF_YOUR_FUNCTION -> 'whatever' Tab -> there should be options for having it return a value and setting its attribute type
// calling the Function:
'whatever' Element -> run as script -> add new script -> 'variables' section/category -> 'set a variable or an attribute' Script -> [EXPRESSION] -> set variable YOUR_VARIABLE = [EXPRESSION] NAME_OF_YOUR_FUNCTION
Aaah, that's it ! Thanks to you all. But it seems that parens aren't optional, which is logical for me.
Parentheses are optional when the function is on its own. So
MyFunction
But
x = MyFunction()
msg(MyFunction())
Ah, thank you for clarifying up when parenthesis are needed vs not/optionally, Pixie!