Okay, I'll explain about functions, return values, etc.
Let's take an example function that adds two numbers. This would be
like you meeting some guy, and saying, "From time to time I may call on you.
When I do, I'll give you two numbers. I want you to add them together, and
then give me the result, as a number." Then, you might tell the guy, "3 and
5." He would then say "8."
The return type of a function tells the program what type of value to
expect back from the function. If we say void, that means the function will
not return anything. If we say int, that means that, when we call the
function, we expect it to return an int to us.
When we specify function parameters, here's where the first and second
ints come into play. These are undefined outside our adding function,
because there's no need for them anywhere else. They're kind of like that
particular function's private workspace, where it can do anything it wants.
It can also define other variables that are only valid within that function,
within its private workspace. When the function returns, the janitor comes
along and clears away all the junk from the function's private workspace, so
nobody else will ever see it again.
When we call the function inside the main function, we're passing in
two parameters to the function. These parameters will fill the first and
second ints. That means, the function already has data in its private
workspace when it begins. It then manipulates that data, and returns the
result of those manipulations.
Hope that helped!
Jayson
----- Original Message -----
From: "dark" <[email protected]>
To: <[email protected]>
Sent: Wednesday, March 24, 2010 2:57 PM
Subject: [Audyssey] Bgt stuff that confuses me
Hi.
Having already read through the tutorial once, I stil find myself mildly
confused on a couple of matters.
Firstly, all the stuff relating to doubled short or long intagers and bits
and bytes. I'm rather uncertain why or when I would want to use variables
such as int8, double, or short which relate to the size of bits and bytes.
Shorely, a number is a number and can be written as such?
Secondly, I'm uncertain as to the difference betwene void functions and
return result functions, and I must confess I don't follow this example:
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;
I can see that the alert will write the text string with the int x,
however, hasn't the (3 + 5), already produced the result of 8 for x?
Also, I have absolutely no idea what the business involving "int first"
and "int second" is all about, sinse how does bgt know what first and
second actually mean? it seems this function is working with a lot of
intagers which haven't been defigned successfully, but which work (I tried
creating a secript with this and it printed fine).
Any thoughts on this would be appreciated.
Btw, sinse I'm interested in rpg games (and sinse I'm not exactly
overflowing with useable sounds), I thought I'd begin by writing a basic
text box turn based combat game similar to acefire. I can't promise
anything astounding, but I'm hoping it'll be a good exercise for me if
nothing els, and teach me something useful about Bgt.
Beware the grue!
Dark.
---
Gamers mailing list __ [email protected]
If you want to leave the list, send E-mail to
[email protected].
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/[email protected].
If you have any questions or concerns regarding the management of the
list,
please send E-mail to [email protected].
---
Gamers mailing list __ [email protected]
If you want to leave the list, send E-mail to [email protected].
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/[email protected].
If you have any questions or concerns regarding the management of the list,
please send E-mail to [email protected].