You are not logged in.    Login    New User    Forum Home    Search

Location:
JBPLAY  \  Meteor 2  \  Editing  \  program control: if, else, while, for...

Back to Threads

Viewing Thread: program control: if, else, while, for...

 

fuzinavl
 Official Sponsor

Joined: 06 October 2004
Posts: 287
26 July 2005 16:16 (UK time)

Can I use program control mechanisms in scripts?
( if, then, else, for, while ...)
If so, where can I find info on that?

Also, does
SC_Wait(); pause all script activity, or just the current code block?

Edited: 26 July 2005 16:17


You need to login to create posts in this thread.

Dave Man

Joined: 19 October 2003
Posts: 374
27 July 2005 01:14 (UK time)

Yes you can, I'll show you some examples down below. For more info look in the script editing file that James has on his website or at the orginal script code files found in M2.

If example:

void SecondGroup()
if(Sc_GetObjectHidden(2)==1)
{ //Represents your "then" code
Sc_SetObjectHidden(2,0);
}
Else //Obviously your "Else" code
{
Sc_SetObjectIndestructible(2,0);
} //And your "End" code

While or For Example:
Now I'm not sure you can specifically do while statments with the term "while" but I now a way around it...

void ThirdGroup()
int i=1 //Set up a variable
if(i==8) //8 represents when this code will end
{
SC_SetObjectHidden(2,0);
}
Else
{
...do something while the "while" Statment is not done
i+1=1; //Now I'm not sure how to add to a vairable using C+ but I this is how you do it in GML or ASCII
}

There you go... at least to my knowledge

You need to login to create posts in this thread.

arezey

Joined: 16 June 2005
Posts: 1599
27 July 2005 07:20 (UK time)

Eh? I didn't understand that!

You need to login to create posts in this thread.

Dave Man

Joined: 19 October 2003
Posts: 374
28 July 2005 01:55 (UK time)

Okay. Here's the laymans version.

To use a "if" code you need to test two things out like the statment if 1=1. Since this is true the computer would return 1 or in this case it would start the code that was located inbetween the first two "{" and "}". Now if you had a statement that was false the computer would then do the code that was inbetween the the else statment's "{" and "}". Oh and there's just one more thing. For some reason C code or C+, I'm not sure, likes to use two "=" signs to state equals. It's the same for => or <= which means is equal to or greater than or is equal or less then, repsectivily. The second statement of how to use while code works the same way expect it uses a variable to count two a certain number and than it stops the execution of the code. Basically it will operate the code until "i" equals something, adding one two "i" each time the code is executed. This would be helpful in reptiful codes or a timing code. Questions?

You need to login to create posts in this thread.

arezey

Joined: 16 June 2005
Posts: 1599
28 July 2005 09:26 (UK time)

Hmmm, I'll try to figure this out. I have borrowed Microsoft Visual C++6 from the city library, and I'm going on with it quite good. I'll try your code out in M2 to have a some kind of seeing of this.

You need to login to create posts in this thread.

James Bunting
Joined: 17 September 2003
Posts: 1308
29 July 2005 01:55 (UK time)

Yes its all standard C code. It can be as complex or simple as you decide to make it. Saying that if you happen to know a bit of C then you can do some really cool stuff.

Visual C++ 6 is a very good choice, its actually what I use to make Meteor 2 in the first place.

You need to login to create posts in this thread.

arezey

Joined: 16 June 2005
Posts: 1599
29 July 2005 10:53 (UK time)

I knew you do, I looked up the screenshot "M2 in the flesh" and saw in the top "Microsoft Visual C". I found this in the city library because if you used it, it must be a good program.

Edited: 29 July 2005 10:53


You need to login to create posts in this thread.



Forums system (C) 1999-2023 by James Bunting.

Terms of Use