Jump to content

Photo

How without a guy do I code for string 2 and 3 to appear only once per


  • Please log in to reply
2 replies to this topic

#1 LikeLike888

LikeLike888

    Spicy food lover!!

  • Members
  • Real Name:Jason
  • Location:North America

Posted 18 March 2018 - 04:57 AM

Here is what I figured out so far
import "std.zh"
ffc script Message
{
  void run (int string1)
  {
    if ( Game->GetCurDMap() == 0 )
    {
      if ( Game->GetCurScreen() == 0x00 )
      {
        Screen->Message(string1);
      }
    }
  }
}
But up above coding does not have string1 shown at all on DMap 0 Screen 00
but eventually I want it to where without a guy every time Link visit Screen 00 on DMap 0 String 2 shows up one time and then when String 2 is finished and A weapon button is pressed String 3 shows up and then when String 3 is finished and A weapon button is pressed no more strings on Screen 00 DMap 0 until Link visits DMap 0 Screen 00 again.

#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 19 March 2018 - 03:12 AM

Here's a small ffc script that will show a message only one time for any given screen.

We do this by setting bits in Screen->D[]
The D1 variale is the index of D[] to use, so, if D1 == 5, you will be using Screen->D[5].

The D2 variable is the bit that you are using for the flag, so, if D2 == 9, yoou are using xxxxxxxBxxxxxxxxx (the 10th bit, as the count starts at 0).

To have another string appear after the player pushes A/B to advance from the string on the screen, go to the ZQuest string editor. In the string settings, there is a field for 'Next'. Set that to the string that you wish to display after the current string, when the player presses the button.

Thus, for this script, you could have:
D0: 2
D1: 1
D2: 1

In the String Editor, the 'Next' field for string 2, would be '3', to show string 3 after 2.

As a bonus, I included some debugging functions, and sanity checks in the script, so that you can see how to make that sort of thing.

// D0: ID of ZQ Message String to Display
// D1: Screen register to use. Valid values are 0->7.
// D2: Bit of the register to use for storing a flag. 
//        ---> Valid range of values is 0->16.
// !! Be sure that you select values that are not otherwise being
// !!     used on the same screen by another script!

ffc script OneTimeMessage
{
     void run(int msg, int reg, int bit)
     {
          //Sanity Bounds
          if ( reg < 0 || reg > 7 ) 
          {
               __errorReg(reg); Quit();
          }
          if ( bit < 0 || bit > 16 ) 
          { 
               __errorBit(bit); Quit();
          }
          if ( !GetScreenDBit(reg, bit) )
          {
               SetScreenDBit(reg, bit, true);
               Screen->Message(msg);
          }
          this->Data = 0; Quit();
     }
     void __errorReg(int r)
     {
          int s1[256]="Attempted to use an invalid screen register from script 'OneTimeMessage' on DMap: "; 
          int s2[]=", Screen: ";
          int s3[]=", Register: ";
          int s_scr[8]; int s_dm[8]; int s_reg[2];e
          itoa(s_scr, Game->GetCurScreen());
          itoa(s_dm, Game->GetCurDMap());
          itoa(s_reg, r);
          strcat(s1,s_dm); strcat(s1,s2);
          strcat(s1,s_scr); strcat(s1,s3);
          strcat(s1, s_reg); TraceNL(); TraceS(s1); TraceNL();
     }

     void __errorBit(int r)
     {
          int s1[256]="Attempted to use an invalid screen register bit from script 'OneTimeMessage' on DMap: "; 
          int s2[]=", Screen: ";
          int s3[]=", Bit: ";
          int s_scr[8]; int s_dm[8]; int s_reg[2];e
          itoa(s_scr, Game->GetCurScreen());
          itoa(s_dm, Game->GetCurDMap());
          itoa(s_reg, r);
          strcat(s1,s_dm); strcat(s1,s2);
          strcat(s1,s_scr); strcat(s1,s3);
          strcat(s1, s_reg); TraceNL(); TraceS(s1); TraceNL();
     }
}


#3 LikeLike888

LikeLike888

    Spicy food lover!!

  • Members
  • Real Name:Jason
  • Location:North America

Posted 23 March 2018 - 06:52 AM

Awesome thank you :)


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users