Jump to content

Photo

Periodic reduction to a counter


  • Please log in to reply
49 replies to this topic

#16 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 15 December 2014 - 08:26 PM

I just copy/pasted my entire global script... since that's the only thing I have in my global



also, it IS on slot 2 I just called it slot1 because I spaced.



#17 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 15 December 2014 - 08:26 PM

I edited my post with a possible solution.



#18 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 15 December 2014 - 08:34 PM

Oh,yeah, the while(true) loop was definitely missing.... But... now that I added it, it freezes the game at startup. This is what I've got:

global script Slot2{
            //Drunk script
           void run(){
               while(true)
     if (Game->Counter[CR_SCRIPT1] > 0 ){ 
         Link->Drunk = Game->Counter[CR_SCRIPT1] * 3600;
         Game->Counter[CR_SCRIPT1] = 0;
     }
     if(Link->Drunk>0){
        Link->InputL = false;
        Link->InputR = false;
     }
            Waitframe();
           }
    }


#19 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 15 December 2014 - 08:43 PM

loops don't work that way.

while(true)
{
code to be looped
Waitframe(); //most important part
}


#20 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 15 December 2014 - 08:48 PM

Oh, right... I forgot the curly braces. Now it loads, and the drunk effect works, but now the counter just stays at 0. Do I need to move the counter reset to outside of the loop?


Edited by Lineas, 15 December 2014 - 08:48 PM.


#21 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 15 December 2014 - 08:55 PM

This is logically what is happening...

 

SCRIPTCOUNTER1 > 0

DO STUFF

SET SCRIPTCOUNTER 0

 

When do you want to reset the counter?



#22 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 15 December 2014 - 08:56 PM

After the drunk effect finishes counting down



#23 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 15 December 2014 - 08:58 PM

if(Link->Drunk==0) Game->Counter[CR_SCRIPT1] = 0;



#24 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 15 December 2014 - 09:05 PM

 //Drunk script
           void run(){
               while(true) {
     if (Game->Counter[CR_SCRIPT1] > 0 ){ 
         Link->Drunk = Game->Counter[CR_SCRIPT1] * 3600;
         if(Link->Drunk==0) Game->Counter[CR_SCRIPT1] = 0;
     }
     if(Link->Drunk>0){
        Link->InputL = false;
        Link->InputR = false;
     }
            Waitframe();
           }
    }
} 

And now it's not counting down. Either that, or it's never reaching 0 because the items are still in my inventory, so it's continually resetting the timer to max.


Edited by Lineas, 15 December 2014 - 09:06 PM.


#25 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 15 December 2014 - 09:06 PM

Are you making the items consumable?

 

Yup just checked and it's setting it to max. Hmm... Trickier then it looks.

Not sure how to get around that, let me think for a moment.


Edited by Freya, 15 December 2014 - 09:09 PM.


#26 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 15 December 2014 - 09:11 PM

No, that's why I need to be able to reset the counter, or figure out how to make the game auto-consume one every minute.

 

EDIT: Lol, why is it everything I want to do is always trickier than it looks. Oh,well, at least this quest will be fairly light on scripts beyond this and the one for a right handed sword


Edited by Lineas, 15 December 2014 - 09:16 PM.


#27 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 15 December 2014 - 09:13 PM

 //Drunk script
           void run(){
               while(true) {
     if (Game->Counter[CR_SCRIPT1] > 0 ){ 
         Link->Drunk = Game->Counter[CR_SCRIPT1] * 3600;
         //BINGO THIS AINT EVEN RUNNING // if(Link->Drunk==0) Game->Counter[CR_SCRIPT1] = 0;
     }
     if(Link->Drunk>0){
        Link->InputL = false;
        Link->InputR = false;
     }
     else if(Link->Drunk==0) Game->Counter[CR_SCRIPT1] = 0; //Let's put it here instead
            Waitframe();
           }
    }
} 


#28 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 15 December 2014 - 09:23 PM

Still no reset, my guess is it's still keeping the timer at max.



#29 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 15 December 2014 - 09:28 PM

//Drunk script
           void run(){
               while(true) {
     if (Game->Counter[CR_SCRIPT1] > 0 && Link->Drunk==0){
         Link->Drunk = Game->Counter[CR_SCRIPT1] * 3600;
     }
     if(Link->Drunk>0){
        Link->InputL = false;
        Link->InputR = false;
     }
     else if(Link->Drunk==0) Game->Counter[CR_SCRIPT1] = 0; //Let's put it here instead
            Waitframe();
           }
    }
}

Can he drunk any other way before this initiailizes, if not that should work hopefully.



#30 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 15 December 2014 - 09:31 PM

So, I changed Link->Drunk = Game->Counter[CR_SCRIPT1] * 3600; to Link->Drunk == Game->Counter[CR_SCRIPT1] * 3600; and I think it worked, sorta. It seems that now it's resetting the counter as soon as I pick up the item, causing Link to only be drunk for 1 frame (this is just conjecture, because Link turned on his own upon picking the item up, but then was not drunk)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users