ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


multiple_return_values

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
multiple_return_values [2019/04/19 21:17] korshunmultiple_return_values [2019/04/19 21:20] korshun
Line 5: Line 5:
 ACSUtils uses a convention to fake returning multiple values from a function. The convention is as follows: there are 8 global variables with names ''r1'' through ''r8''. If a function returns multiple values, it actually returns no value and writes the first "returned" value to ''r1'', the second one to ''r2'', and so on. ACSUtils uses a convention to fake returning multiple values from a function. The convention is as follows: there are 8 global variables with names ''r1'' through ''r8''. If a function returns multiple values, it actually returns no value and writes the first "returned" value to ''r1'', the second one to ''r2'', and so on.
  
-Here's an example, RotateVector returns X and Y:+Here's an example, ''RotateVector'' returns X and Y:
  
 <code> <code>
Line 11: Line 11:
 int newX = r1; int newX = r1;
 int newY = r2; int newY = r2;
 +</code>
 +
 +The following is also valid:
 +<code>
 +RotateVector(x, y, angle);
 +x = r1;
 +y = r2;
 +</code>
 +
 +''normalize3d'' returns three values:
 +<code>
 +normalize3d(x, y, z);
 +int newX = r1;
 +int newY = r2;
 +int newZ = r3;
 </code> </code>
  
multiple_return_values.txt · Last modified: 2019/04/22 00:32 by korshun