Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Besh on Thu 15/12/2005 16:43:31

Title: Returning float from plugin functions? (SOLVED)
Post by: Besh on Thu 15/12/2005 16:43:31
I cannot return a float variable from my plugin functions!!!

managed struct MyStruct {
   import static MyStruct* Create(...);
   import int aaa(...);
   import float bbb(...);
}

when I call, from the script, the function aaa(...) it's all OK but when I call the function bbb(...) the return value is always 0 or NULL.

any suggestion???
Title: Re: problem: return float
Post by: SSH on Thu 15/12/2005 16:58:53
Maybe they're actually doubles?
Title: Re: problem: return float
Post by: Pumaman on Thu 15/12/2005 21:00:24
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23020.msg283340#msg283340
Title: Re: problem: return float
Post by: Besh on Thu 15/12/2005 23:50:30
OK!! thank you very much!!!

the soulution is:

#define FLOAT_RETURN_TYPE long
#define RETURN_FLOAT(x) return *((long*)&x)

FLOAT_RETURN_TYPE bbb (...) {
  float fval;
  .....
  .....
  RETURN_FLOAT(fval);
}