Jump to content

Photo

Enable L Key Script


  • Please log in to reply
4 replies to this topic

#1 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 12 September 2011 - 01:14 AM

So I am using aaa2's Press L to Run script, which he modified for me so that I can toggle Link's ability
to run on and off by pressing the L button, rather than holding it down.

Part 1:
The thing is I want to make this into an item. But rather than asking him to change the script,
I thought it might be easier to make a script which will make the L button invalid until Link
collects a dummy item.

Part 2:
I am also hoping to make it so that none of Link's button items will function as long as the
running ability is turned on (with the feather being a possible exception).

If you can only do Part 1, Part 2 is much less important, and I can live without it.

Edited by Cukeman, 12 September 2011 - 01:20 AM.


#2 aaa2

aaa2

    Wizard

  • Banned

Posted 12 September 2011 - 05:19 AM

I fulfilled part 1:

CODE



int round(float f){
    
    if(f<0.5&&f>-0.5){
        return 0;
    }else{
    int diff=f;
    int num=0;
    if(diff>0){
    while(diff>1){
    diff-=1;
    num+=1;
    }
    if(diff<0.5){
    return num;
    }else{
    return num+1;
    }
    }else{
        while(diff<-1){
    diff+=1;
    num-=1;
    }
    if(diff>-0.5){
    return num;
    }else{
    return num-1;
    }
    
    }
    }
    }
const float Lspeedpercent=150;
global script onstart {
   void run() {
float    Lspeed=Lspeedpercent/100;
     int x=Link->X;
     int y=Link->Y;
     int curmap=-1;
     int curscreen=-1;
    bool pressdL=false;
    int downtime=-1;
Game->Counter[CR_SCRIPT10]=1;
    //one time things go here
    while(true) {
  if(Game->Counter[CR_SCRIPT10]==1){  //make input false when item wasnt lifted yet
   Link->InputL=false;
  }
        if(curscreen!=Game->GetCurScreen()&&curmap==Game->GetCurMap()){
            Waitframes(10);
            curscreen=Game->GetCurScreen();
            x=Link->X;
            y=Link->Y;
        }
        if(curmap!=Game->GetCurMap()&&curscreen==Game->GetCurScreen()){
            Waitframes(10);
            curmap=Game->GetCurMap();
            x=Link->X;
            y=Link->Y;
        }
        if(curmap!=Game->GetCurMap()&&curscreen!=Game->GetCurScreen()){
            Waitframes(10);
            curscreen=Game->GetCurScreen();
            curmap=Game->GetCurMap();
            x=Link->X;
            y=Link->Y;
        }    

        if(Link->InputL&&downtime<0){ //checkj if L pressed if so toggle between running and not running state
            pressdL=!pressdL;
            downtime=10;  
        }
        if(downtime>-1){  // the downtime makes sure there are no glitches by the toggle button like toggle between running and not running too fast
            downtime-=1;
        }

        if(pressdL){ //Test if L was pressed
            Link->X+=round((Lspeed-1)*(Link->X-x));
            Link->Y+=round((Lspeed-1)*(Link->Y-y));
        }
        
        x=Link->X;
        y=Link->Y;
          Waitframe();
        
    }
   }
  
  //functions go here
}



now the L button wont work unless a constant i set is changed.





To go with it here is a script that changes the constant once you pickup an item. so you can run once you pick up the item you chose for that.

CODE


item script activateL{
    void run(int m){
        Game->Counter[CR_SCRIPT10]=2;
    }
}





Last but not least a demoquest showing that it all works out fine:

http://www.mediafire...atijperh9p55645





If you want i could fulfil part 2 by disabling A button and B button while link is in running state. But i am not sure if thats exactly what you want. would be only adding 2 lines to the script.

The script would then change to:


CODE



int round(float f){
    
    if(f<0.5&&f>-0.5){
        return 0;
    }else{
    int diff=f;
    int num=0;
    if(diff>0){
    while(diff>1){
    diff-=1;
    num+=1;
    }
    if(diff<0.5){
    return num;
    }else{
    return num+1;
    }
    }else{
        while(diff<-1){
    diff+=1;
    num-=1;
    }
    if(diff>-0.5){
    return num;
    }else{
    return num-1;
    }
    
    }
    }
    }
const float Lspeedpercent=150;
global script onstart {
   void run() {
float    Lspeed=Lspeedpercent/100;
     int x=Link->X;
     int y=Link->Y;
     int curmap=-1;
     int curscreen=-1;
    bool pressdL=false;
    int downtime=-1;
Game->Counter[CR_SCRIPT10]=1;
    //one time things go here
    while(true) {
  if(Game->Counter[CR_SCRIPT10]==1){  //make input false when item wasnt lifted yet
   Link->InputL=false;
  }
        if(curscreen!=Game->GetCurScreen()&&curmap==Game->GetCurMap()){
            Waitframes(10);
            curscreen=Game->GetCurScreen();
            x=Link->X;
            y=Link->Y;
        }
        if(curmap!=Game->GetCurMap()&&curscreen==Game->GetCurScreen()){
            Waitframes(10);
            curmap=Game->GetCurMap();
            x=Link->X;
            y=Link->Y;
        }
        if(curmap!=Game->GetCurMap()&&curscreen!=Game->GetCurScreen()){
            Waitframes(10);
            curscreen=Game->GetCurScreen();
            curmap=Game->GetCurMap();
            x=Link->X;
            y=Link->Y;
        }    

        if(Link->InputL&&downtime<0){ //checkj if L pressed if so toggle between running and not running state
            pressdL=!pressdL;
            downtime=10;  
        }
        if(downtime>-1){  // the downtime makes sure there are no glitches by the toggle button like toggle between running and not running too fast
            downtime-=1;
        }

        if(pressdL){ //Test if L was pressed

            Link->InputA=false;

            Link->InputB=false;
            Link->X+=round((Lspeed-1)*(Link->X-x));
            Link->Y+=round((Lspeed-1)*(Link->Y-y));
        }
        
        x=Link->X;
        y=Link->Y;
          Waitframe();
        
    }
   }
  
  //functions go here
}


here a demoquest with that version:

http://www.mediafire...5nv4r7rb8kjposx

Finally now a version of the script that has only B disabled when in running state:

CODE



int round(float f){
    
    if(f<0.5&&f>-0.5){
        return 0;
    }else{
    int diff=f;
    int num=0;
    if(diff>0){
    while(diff>1){
    diff-=1;
    num+=1;
    }
    if(diff<0.5){
    return num;
    }else{
    return num+1;
    }
    }else{
        while(diff<-1){
    diff+=1;
    num-=1;
    }
    if(diff>-0.5){
    return num;
    }else{
    return num-1;
    }
    
    }
    }
    }
const float Lspeedpercent=150;
global script onstart {
   void run() {
float    Lspeed=Lspeedpercent/100;
     int x=Link->X;
     int y=Link->Y;
     int curmap=-1;
     int curscreen=-1;
    bool pressdL=false;
    int downtime=-1;
Game->Counter[CR_SCRIPT10]=1;
    //one time things go here
    while(true) {
  if(Game->Counter[CR_SCRIPT10]==1){  //make input false when item wasnt lifted yet
   Link->InputL=false;
  }
        if(curscreen!=Game->GetCurScreen()&&curmap==Game->GetCurMap()){
            Waitframes(10);
            curscreen=Game->GetCurScreen();
            x=Link->X;
            y=Link->Y;
        }
        if(curmap!=Game->GetCurMap()&&curscreen==Game->GetCurScreen()){
            Waitframes(10);
            curmap=Game->GetCurMap();
            x=Link->X;
            y=Link->Y;
        }
        if(curmap!=Game->GetCurMap()&&curscreen!=Game->GetCurScreen()){
            Waitframes(10);
            curscreen=Game->GetCurScreen();
            curmap=Game->GetCurMap();
            x=Link->X;
            y=Link->Y;
        }    

        if(Link->InputL&&downtime<0){ //checkj if L pressed if so toggle between running and not running state
            pressdL=!pressdL;
            downtime=10;  
        }
        if(downtime>-1){  // the downtime makes sure there are no glitches by the toggle button like toggle between running and not running too fast
            downtime-=1;
        }

        if(pressdL){ //Test if L was pressed
   Link->InputB=false;
            Link->X+=round((Lspeed-1)*(Link->X-x));
            Link->Y+=round((Lspeed-1)*(Link->Y-y));
  
        }
        
        x=Link->X;
        y=Link->Y;
          Waitframe();
        
    }
   }
  
  //functions go here
}




I wont put a demoquest for the last one because its obvious. All of them should work as intended



Edited by aaa2, 12 September 2011 - 05:39 AM.


#3 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 12 September 2011 - 01:27 PM

wow! thanks a lot! I imagine this should be everything I need to accomplish my goal

EDIT:
Question: Can I use a string control code to remove this "item" at a later point during the game?
Don't bother to change it, I might not need this function.

Edited by Cukeman, 12 September 2011 - 06:06 PM.


#4 aaa2

aaa2

    Wizard

  • Banned

Posted 13 September 2011 - 01:56 AM

Lets see if i got what you mean. you want another item to deactivate the script again? So L cannot be used anymore? If so you can create a second item that uses this script for pickup:

CODE


item script deactivateL{
    void run(int m){
        Game->Counter[CR_SCRIPT10]=1;
    }
}




it should work just as fine as the script for activating the running.

Also the same could be done with an ffc:

CODE


ffc script deactivateL{
    void run(int m){

if(Distance(Link->X,Link->Y,this->X,this->Y)<9){
        Game->Counter[CR_SCRIPT10]=1;

        }
    }
}






#5 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 13 September 2011 - 11:15 AM

thanks icon_smile.gif


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users