Actually, this is quite simple. If you need to get the value stored in
a function and pass it to a variable your function must return a
value. However, you need to remember to set the functions return tuype
to the ttype of value you are returning.
In your sample code you have declared void main() () but return an
integer value. This would blow up because main is suppose to return a
null value instead of an integer in this case. To fix the problem you
need to declare main as type int. Does this make sense?
Here is a real world example of what I am talking about. Let's say you
want to get a characters x position on the map and pass it to a value
called x. Here is it in code.
// Get the player's x position
// Get the player's x position and store it in x
float x = GetX();
In this simple example the function GetX() returns the player's x
coordinate and passes it off to the value x which can be evaluated in
On 3/24/10, dark <d...@xgam.org> wrote:
> Appologies, but I'm stil a bit lost on returning functions.
> Could someone please give me a blow by blow on this example from the
> tutorial sinse other than the alert function and the original void main I'm
> slightly lost with this one:
> void main()
> int x=add_numbers(3, 5);
> alert("Wow", "3 + 5 is... " + x + "!");
> int add_numbers(int first, int second)
> int result=first+second;
> return result;
> Really sorry for the question, ---- it might just be me being extremely
> stupid here.
> Beware the grue!
> Gamers mailing list __ Gamers@audyssey.org
> If you want to leave the list, send E-mail to
> You can make changes or update your subscription via the web, at
> All messages are archived and can be searched and read at
> If you have any questions or concerns regarding the management of the list,
> please send E-mail to gamers-ow...@audyssey.org.
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
All messages are archived and can be searched and read at
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.