Page 1 of 2

lots of script

PostPosted: Sun Nov 19, 2006 12:28 am
by Zehper48
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

PostPosted: Sun Nov 19, 2006 1:26 am
by DilloDude
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;
    }
}

PostPosted: Sun Nov 19, 2006 1:50 am
by Zehper48
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

PostPosted: Sun Nov 19, 2006 4:52 am
by DilloDude
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.

PostPosted: Sun Nov 19, 2006 5:00 am
by Zehper48
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

PostPosted: Sun Nov 19, 2006 7:29 pm
by makslane
Post the code

PostPosted: Sun Nov 19, 2006 8:42 pm
by Zehper48
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

PostPosted: Sun Nov 19, 2006 8:48 pm
by makslane
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 //

PostPosted: Sun Nov 19, 2006 9:04 pm
by Zehper48
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

PostPosted: Sun Nov 19, 2006 10:47 pm
by makslane
A1 and A2 need to be a numerical variable, like an integer.
What's the type of this variables in your code?

PostPosted: Sun Nov 19, 2006 11:36 pm
by Zehper48
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;
    }
}

PostPosted: Mon Nov 20, 2006 12:09 am
by makslane
Put a } at end of code to close the if command

PostPosted: Mon Nov 20, 2006 12:45 am
by Zehper48
i got the code to work but where is says case and break, should i replace those with something else

PostPosted: Mon Nov 20, 2006 12:47 am
by Game A Gogo
no, you must remove the
Code: Select all
//
before the action thing so it can work.

PostPosted: Mon Nov 20, 2006 12:59 am
by Zehper48
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