some code scripting knowledge needed?

Game Editor comments and discussion.

some code scripting knowledge needed?

Postby tinkergnome » Thu Nov 10, 2011 7:03 pm

hi ..... i was wondering about
if... then statements? & case select?

i need to know instead of if(x1.textNumber> 10) "this will happen";'
what about if a textNumber=10???? i want to know how that can be different.

with case select (if that is possible????) how do i arrange the code for certain things to happen?

i have an idea about creating a specific type of mahjong tile game ..... i wasnt sure if those 2
code pieces would suffice in any building into a mahjong game. i want to include some most
academic type of coding but keeping it simple.
User avatar
tinkergnome
 
Posts: 16
Joined: Wed Oct 12, 2011 5:11 pm
Score: 1 Give a positive score

Re: some code scripting knowledge needed?

Postby skydereign » Thu Nov 10, 2011 11:47 pm

You can do this though I suggest you never use textNumber like that.
Code: Select all
if(textNumber==10)
{
    // do this
}

// here are other ways of using if
if(var>=0) { /* code */ }
if(var<=0) { /* code */ }
if(var>0) { /* code */ }
if(var<0) { /* code */ }
if(var!=0) { /* code */ }

The only time I'd suggest using textNumber, is setting textNumber equal to something. You can also use switch statements, which is probably what you mean by case select.
Code: Select all
switch(int_var)
{
    case 0: // execute code if int_var==0
    // this until the break
    break;

    case 1: // execute code if int_var==1
    // code
    break;

    case 2: // if int_var==2
    break;

    default: // if no other cases were met
    break;
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest