cannot convert DEF_POSITION* into int (SOLVED)

Started by spook1, Wed 05/04/2006 20:45:02

Previous topic - Next topic

spook1

In a room I have not touched since I moved to ags 2.72, I want to add a new object.
BUt once I open the room, I cannot save it anymore, because of the error:

"Cannot convert DEF_POSITION* into 'int'  "

it is generated on a line where I state:

return(position) 

at the end of a function:
Code: ags

function vehicle_position(int left_fwd,int right_fwd){
  //first call realtive function to calculate the relative positionchange
 relative_translation(left_fwd,right_fwd); //how much do left and right move

 fposition.x = 
     fadd ( fposition.x, 
       fadd(
	fcos_component(fpositionchange.x, fposition.orientation), 
        fsin_component(fpositionchange.y,fposition.orientation)
       )
     );
 fposition.y = 
     fadd(fposition.y,
       fadd( 
	fcos_component( fpositionchange.y, fposition.orientation ), 
        fsin_component( fpositionchange.x,fposition.orientation )
       )
     );
 fposition.orientation =
     fadd(fposition.orientation, fpositionchange.orientation);
     
 position.x = float_to_int(fposition.x);
 position.y = float_to_int(fposition.y);
 position.orientation = float_to_int(fposition.orientation);

 return(position);
 
}


I gues it has something to do with the function not being declared correctly. It was probably allowed in previous releases.
How should I declare my function as a DEF_POSITION type?


The game works fine, no errors or anything, exeprt when I try to edit this room.

In the beginning of the script, where I declare my variables I have:

Code: ags

struct DEF_POSITION{
  int x;
  int y;
  int orientation;
};


DEF_POSITION fpositionchange;
DEF_POSITION fposition;
DEF_POSITION position;



How can I solve this??

strazer

Functions can only return primitive types, not custom structs or arrays.

spook1

OK, indeed, the return functions was a legacy remark. It was not really used in the game.
The new compiler checks better.
Commenting out the line was sufficient.

Thanks for helping though, I have a feeling this is some kind of C++ course I am following from you guys. I am very greatful for the patience you have witrh me :-)

SMF spam blocked by CleanTalk