Jump to content

Photo

Script for ex1, ex2, and ex3 buttons


  • Please log in to reply
2 replies to this topic

#1 sonlen

sonlen

    Junior

  • Members
  • Real Name:Chris

Posted 14 April 2009 - 05:17 PM

Can someone make me a script for the first 3 ex buttons where u can select the item and set them to that item slot, like the c buttons on OoT and MM? Thnx in advance. icon_smile.gif

#2 Cjc

Cjc

    Cor Blimey!

  • Members

Posted 14 April 2009 - 09:37 PM

Well... currently that is not possible. You cannot script items to other buttons.

You can, however, script buttons to other buttons, as so:

CODE

import "std.zh"

////global variables go here

int ButtonShuffle; //You'll have to define this at the global level,
//or this won't work.
//ButtonShuffle is used to tell the code that Link is performing an imput
//that the keyboard did not initiate.  Here are the values for ButtonShuffle:
    //ButtonShuffle == 1 is for the A button.
    //ButtonShuffle == 2 is for the B button.
    //ButtonShuffle == 3 is for the R button.
    //ButtonShuffle == 4 is for the L button.
    //ButtonShuffle == 5 is for the Ex1 button.
    //ButtonShuffle == 6 is for the Ex2 button.
    //ButtonShuffle == 7 is for the Ex3 button.
    //ButtonShuffle == 8 is for the Ex4 button.
    //ButtonShuffle == 9 is for the Start Button.
    //ButtonShuffle == 10 is for InputUp.  This is 10 + the Direction constant for facing up.
    //ButtonShuffle == 11 is for InputDown.  This is 10 + the Direction constant for facing down.
    //ButtonShuffle == 12 is for InputLeft.  This is 10 + the Direction constant for facing left.
    //ButtonShuffle == 13 is for InputRight.  This is 10 + the Direction constant for facing right.
    //ButtonShuffle == 20 is for the Map Button.
//If you ever force the engine to use an input, through input = true, you
//will have to precede that line with ButtonShuffle = #, using the number
//for the forced button.  This will make sense shortly.



global script onstart {
    void run() {
    
    ////one time things go here
    ButtonShuffle = 0;
        while(true) {
            ////function calls go here
            
            if(Link->InputEx1 && ButtonShuffle != 5){ //Checks if Link actually pressed the button
            //or if this script simulated the press of that button.  Necessary to avoid
            //creating a loop.
                ButtonShuffle = 1; //Sets the button truth to the button who's
                //effect you want the Ex1 button to have
                //For ButtonTruth to function properly, you must have this
                //kind of integer assignment above EVERY script-forced input.
                //The number is 1, because the forced input is for A and "A"
                //has an assigned number of 1 in the ButtonTruth.
                Link->InputA = true; //Same as button truth, makes this button
                //have that effect.  To change the target button, change
                //this line to the target button, and change the ButtonTruth
                //number to that appropriate for the target button.
                Link->InputEx1 = false; //Disables the original function of this
                //button.
        
                //I've set the Ex1 button to function as "A" here, so that I
                //could assign an item to it.
            }
            else if(Link->InputA && ButtonShuffle != 1){ //Checks if Link actually pressed the button
            //or if this script simulated the press of that button.
                ButtonShuffle = 5; //For each button who's function you change, you will
                //also need to change the function of the target button.  For example, if
                //you wanted to swap Ex1 and A, you would have to use this code for both buttons
                //and not just one.  If you want Ex1 to act as A and A to act as something else,
                //(For example, R), then you must also make R act as something else.  Otherwise
                //you will have two buttons with the same function, and one button who's
                //function CANNOT be used, period.
                Link->InputEx1 = true; //I am making A function as "Ex1"
                //If I attach a function to InputA, my other scripts will
                //still say "InputA", but in the player you will hit the "Ex1" button
                //to use that effect.
                Link->InputA = false; //Disables the original function of this
                //button.
            }
            else if(Link->InputEx2 && ButtonShuffle != 6){ //Checks if link actually pressed the button
            //or if this script simulated the press of that button.
                ButtonShuffle = 2; //Ex2 will be the new B.    
                Link->InputB = true;
                Link->InputEx2 = false;
                
                //Players would press Ex2 to select items in the subscreen, and press Ex2 to use them
                //with this script in place.
            }
            else if(Link->InputB && ButtonShuffle != 2){ //Checks if link actually pressed the button
            //or if this script simulated the press of that button.
                ButtonShuffle = 6; //B will be the new Ex2.     Now all swapped buttons are assigned
                Link->InputEx2 = true;
                Link->InputB = false;
            }
            else{ButtonShuffle = 0;}
        Waitframe();
        }
    }
        ////functions go here
}


Good news and bad news! The good news is, you'll be able to use Ex1 and Ex2 to assign and use items. The bad news? Well, there's a lot of it. First, we cannot assign items to three buttons. The engine currently doesn't allow for giving other buttons the same general function as the original ones. As such, we can only ever have two buttons for using items. Sorry. There may be some way for a person to script a third item button, but I do not know how.
Second, you will need to craft custom scripts for both the A button (Which I'm guessing you'll want rolling and activation, judging by your request) and the B button (Which will probably be the sword, but you'll have to script it from scratch). I cannot do either of these things for you.
Oh, and your custom scripts for A and B should really be scripts for Ex1 and Ex2, as buttonshuffle will make them automatically function on A and B.

Hope this helps somebody else finish the request. It's a good start, anyway.

PS: This script uses the global slot2 format. See the annotations with four backslashes (////)? Those are the markers for that Global Script Slot 2 template. Just copy everything beneath that until the next column of script, and paste it in the appropriate section. If you have trouble with this, let me know and I'll break the code into pieces for you.

#3 sonlen

sonlen

    Junior

  • Members
  • Real Name:Chris

Posted 31 May 2009 - 10:57 AM

ok, i just had an idea, for the example ex1=x...
so when u push x, it switches b and x, so ex1=b, and then after the item is set or used, ex1 goes back to x, and b goes back to b, is that possible?


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users