SOLVED - Function cannot return value in float

Started by WHAM, Sun 31/05/2020 13:10:41

Previous topic - Next topic

WHAM

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
float blop() 
{
  return 0.14;
}



A very simple code example:
Code: ags
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?
Wrongthinker and anticitizen one. Pending removal to memory hole. | WHAMGAMES proudly presents: The Night Falls, a community roleplaying game

Crimson Wizard

Yes, this is because "function" is secretly an alias to "int", for backwards compatibility.

WHAM

I had no idea that was the case, but now that you mention it, it makes perfect sense.
Thanks!
Wrongthinker and anticitizen one. Pending removal to memory hole. | WHAMGAMES proudly presents: The Night Falls, a community roleplaying game

SMF spam blocked by CleanTalk