lots of script

Non-platform specific questions.

lots of script

Postby Zehper48 » Sun Nov 19, 2006 12:28 am

on a single mouse down event i want alot of stuff to happen. how do i make this code work
if A1 = 1 or higher and if A2=1 or higher
(do this)
if lastdirection.textNumber = 1 create actor bulletup
if lastdirection.textNumber = 2 create actor bulletright
if lastdirection.textNumber = 3 create actor bulletdown
if lastdirection.textNumber = 4 create actor bulletleft

what is the proper way i would code that. tell me if you dont understand and i will try to be more clear
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby DilloDude » Sun Nov 19, 2006 1:26 am

try:
Code: Select all
if (A1 >= 1 && A2 >= 1)
{
    switch(lastdirection.textnumber)
    {
        case 1:
        //create bulletup
        break;

        case 2:
        //create bulletright
        break;

        case 3:
        //create bulletdown
        break;

        case 4:
        //create bulletleft
        break;
    }
}
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby Zehper48 » Sun Nov 19, 2006 1:50 am

i put that in just like it is and there was a couple of errors, should i replace any of it with something else and if so what should i replace it with
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby DilloDude » Sun Nov 19, 2006 4:52 am

You will need to insert the CreateActor function in the required places. Click on the variables/functions button and select CreateActor to insert it automatically.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby Zehper48 » Sun Nov 19, 2006 5:00 am

ok i replaced it but when i click ok it says
Error line 1: Unknown type in binhconst
Waring line 1: Possible non relational operation
Error line 1: Undefined type for relational operation
Error line 3: Illegal structure operation
lol i dont know what to do
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby makslane » Sun Nov 19, 2006 7:29 pm

Post the code
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Zehper48 » Sun Nov 19, 2006 8:42 pm

here it is
Code: Select all
if (A1 >= 1 && A2 >= 1)
{
    switch(lastdirection.textnumber)
    {
        case 1:
        //CreateActor("bulletup", "bulletup", "(none)", "(none)", 0, 0, false);
        break;

        case 2:
        //CreateActor("bulletright", "bulletright", "(none)", "(none)", 0, 0, false);
        break;

        case 3:
        //CreateActor("bulletdown", "bulletdown", "(none)", "(none)", 0, 0, false);
        break;

        case 4:
        //CreateActor("bulletleft", "bulletleft", "(none)", "(none)", 0, 0, false);
        break;
    }
}





Thanks for helping me
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby makslane » Sun Nov 19, 2006 8:48 pm

1) textnumber must be textNumber
2) The switch command works only with integers, so use:
Code: Select all
switch((int)lastdirection.textNumber)
{
...
}


3) Remove the comments //
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Zehper48 » Sun Nov 19, 2006 9:04 pm

i hate to be such a pain but i changed the script to
Code: Select all
if (A1 >= 1 && A2 >= 1)
{
    switch((int)lastdirection.textNumber)
{


    {
        case 1:
        //CreateActor("bulletup", "bulletup", "(none)", "(none)", 0, 0, false);
        break;

        case 2:
        //CreateActor("bulletright", "bulletright", "(none)", "(none)", 0, 0, false);
        break;

        case 3:
        //CreateActor("bulletdown", "bulletdown", "(none)", "(none)", 0, 0, false);
        break;

        case 4:
        //CreateActor("bulletleft", "bulletleft", "(none)", "(none)", 0, 0, false);
        break;
    }
}


and it said
Error line 1: Unknown type in binhconst
Warning line 1: Possible non relational operation
Error line 1: Undefined type for relational operation
Error line 272: Expected }

to be super helpful to me could you post exactaly what i need to put in
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby makslane » Sun Nov 19, 2006 10:47 pm

A1 and A2 need to be a numerical variable, like an integer.
What's the type of this variables in your code?
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Zehper48 » Sun Nov 19, 2006 11:36 pm

ooooooo A1 and A2 are textNumbers so i changed that but it still says error line 1331 expected }

this is what i have
Code: Select all
if (A1.textNumber >= 1 && A2.textNumber >= 1)
{
    switch((int)lastdirection.textNumber)
{


    {
        case 1:
        //CreateActor("bulletup", "bulletup", "(none)", "(none)", 0, 0, false);
        break;

        case 2:
        //CreateActor("bulletright", "bulletright"", "(none)", "(none)", 0, 0, false);
        break;

        case 3:
        //CreateActor("bulletdown"", "bulletdown"", "(none)", "(none)", 0, 0, false);
        break;

        case 4:
        //CreateActor("bulletleft", "bulletleft", "(none)", "(none)", 0, 0, false);
        break;
    }
}
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby makslane » Mon Nov 20, 2006 12:09 am

Put a } at end of code to close the if command
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Zehper48 » Mon Nov 20, 2006 12:45 am

i got the code to work but where is says case and break, should i replace those with something else
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby Game A Gogo » Mon Nov 20, 2006 12:47 am

no, you must remove the
Code: Select all
//
before the action thing so it can work.
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Zehper48 » Mon Nov 20, 2006 12:59 am

Code: Select all
if (A1.textNumber >= 1 && A2.textNumber >= 1)
{
    switch((int)lastdirection.textNumber)
{


    {
        case 1:
        CreateActor("bulletup", "bulletup", "(none)", "(none)", 0, 0, false);
        break;

       case 2:
        CreateActor("bulletright", "bulletright", "(none)", "(none)", 0, 0, false);
        break;

        case 3:
        CreateActor("bulletdown", "bulletdown", "(none)", "(none)", 0, 0, false);
        break;

        case 4:
        CreateActor("bulletleft", "bulletleft", "(none)", "(none)", 0, 0, false);
        break;
    }
}


}

that is what i have but the code wont create the bullet
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest