Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: WHAM on Sun 31/05/2020 13:10:41

Title: SOLVED - Function cannot return value in float
Post by: WHAM on Sun 31/05/2020 13:10:41
Bah, I just hadn't figured out the right search terms for the forum.
Defining the function as float from the beginning is the solution.

It's also in the manual, but I didn't quite grasp it until I tested it in action.

Code (ags) Select
float blop()
{
  return 0.14;
}



A very simple code example:
Code (ags) Select
function blop()
{
  return 0.14;
}



Produces error:
Type mismatch: cannot convert 'float' to 'int'

Is this a feature, or just a mistake on my part?
Is it not possible for a function to return a value in float?
Title: Re: SOLVED - Function cannot return value in float
Post by: Crimson Wizard on Sun 31/05/2020 15:25:54
Yes, this is because "function" is secretly an alias to "int", for backwards compatibility.
Title: Re: SOLVED - Function cannot return value in float
Post by: WHAM on Sun 31/05/2020 19:02:22
I had no idea that was the case, but now that you mention it, it makes perfect sense.
Thanks!