Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple conditions in one "if" statement
xiphirx Offline
Senior Member

Posts: 662
Threads: 16
Joined: Nov 2010
Reputation: 5
#14
RE: Multiple conditions in one "if" statement

(07-20-2011, 07:13 PM)Roenlond Wrote: I was only referring to more advanced scripting for ME, never did I say that it is the hardest thing to do. I know that it is still very much beginner programming. I only came here to ask a question and I got that answered, motivation isn't an issue. Thanks regardless.

I never stated that what you were trying to do was "the hardest thing to do".

I know all you came for was a question, and I'm glad you got it answered, I just didn't want you to follow false information.
(07-20-2011, 10:43 PM)nemesis567 Wrote:
(07-20-2011, 06:14 PM)xiphirx Wrote: Sorry, this is not advanced scripting, you're still at the beginner level.

It would help if you knew C/++ beforehand, but it looks like you're learning as you go.

The first two examples that Kyle posted in his first post are incorrect as they do not have the same effect. Also, you do not need the return statement really, its a void function to begin with.

Return isn't returning nothing as it can't because we're working on a void function but it stops the code from executing in the same or lower hierarchy levels. For instance he could have the continuation of his function bellow.

This is the basics of coding, there is nothing close to intermediate here, there is nothing close to advanced and few things under intermediate levels in amnesia level scripting.

"return" in that sense is, indeed, returning nothing. It has no use in a void function and is pretty redundant. I know it stops the code from executing, but I would rather not chug returns everywhere, it just looks messy and it can mess with your program flow.

To illustrate my point:
void function(somevar var)
{
    if (var)
    {
        // do stuff
    }
    else
        return;
}

Should be

void function(somevar var)
{
    if (var)
    {
        // do stuff
    }
}

Both do the exact same thing, but the latter is less code, and isn't redundant.

(This post was last modified: 07-21-2011, 12:31 AM by xiphirx.)
07-21-2011, 12:27 AM
Find


Messages In This Thread
RE: Multiple conditions in one "if" statement - by xiphirx - 07-21-2011, 12:27 AM



Users browsing this thread: 1 Guest(s)