Jump to content

Photo

tango.zh


  • Please log in to reply
398 replies to this topic

#226 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 24 December 2015 - 10:46 PM

My Tango.zh file is pre-set with additional style, slot, and menu choice defs. I'll post that in a little bit, when I finish eating.
 
 
[ or, apparently, when I wake ]
 
Here you are, this is what I use, with six styles, five slots, forty max menu items. Note that the array is primed for only five slots, despite defining the rest of the values for six. To add a sixth, you merely need to add another segment to the array that holds the offscreen bitmap coordinates,  and string index positions.
 
These are marked 0 through 4, at present, and are defined for the sizes of my menu boxes. The maximum distance offscreen is -214747 to +214747,  X and Y. If you have any other defined bitmap drawing functions, you will want to ensure that you exclude whatever space that they occupy.
 
It also includes the present 'TANGO_SLOT_NORMAL' defs, for the purpose of compatibility; but I use 'TANGO_SLOT_WINDOW'. Thus, these two will have overlaps, and will need separate offsets. I should fix that, and add six total slots of both types, and add the additional styles (six slots of each), for general dist.

--
 

[ ... ]


If I expand Tango_D[] to a size of 214747, will I be able to use @d* up to an index value of 214747A, or is the data accessor token not set up for that?

I don't see an actual valid reason to set such a low value for the array size, as if people want to expand it mid-game-development, it might cause problems. The default should at least be 256, or 1024, IMO. The only reason I know not to set arrays like this to a size of MAX_INT, is to keep them optimised in for loops.

Edited by ZoriaRPG, 25 December 2015 - 03:52 AM.


#227 C-Dawg

C-Dawg

    Magus

  • Members

Posted 27 December 2015 - 09:39 PM

Menus and Tango!

 

So, I'm trying to figure out how to use Tango to make menus.  I want to enable branching conversations eventually, but for now, I'm just trying to code a simple shop.  I started with one of your scripts in the demo file and tried to make it at least allow the player to see each of the items for sale.  Once I get the player's choice, making the transaction occur should be pretty easy.

 

But, all that I get is a message displaying saying "Text Sample:"   I've posted the offending functions below; if you need to see more depth, follow yon Drop Box link to see the current version.

 

void Shop(int message, int item1_id, int item1_price, int item2_id, int item2_price, int item3_id, int item3_price)
    {
        int talkSlot;
        int choiceSlot=TANGO_INVALID;
        int currentChoice;
        int lastChoice=-1;
        int first_choice = get_item_name(item1_id);
        int second_choice = get_item_name(item2_id);
        int third_choice = get_item_name(item2_id);

        int choiceX[]={ 192, 160, 176 };
        int choiceY[]={ 80, 96, 112 };
        int choiceStrings[]={ first_choice, second_choice, third_choice };
        
        talkSlot=ShowMessage(message, TANGO_SLOT_NORMAL, STYLE_PLAIN, 32, 32);
        
        // The string will call @sync(1) when the menu should start
        Tango_Sync(1);
        
        // Set up the menu
        Tango_InitializeMenu();
        Tango_SetMenuCursor(706, 0, 2, 2);
        Tango_SetMenuSFX(66, 67, 0);
        for(int i=0; i<3; i++)
            Tango_AddMenuChoice(i+1, choiceX[i], choiceY[i]);
        
        Tango_ActivateMenu(false);
        
        // Show a second string with whatever the cursor is currently on
        while(Tango_MenuIsActive())
        {
            // In this menu, the value of each choice is one greater than
            // the corresponding array position
            currentChoice=Tango_GetCurrentMenuChoice()-1;
            if(currentChoice!=lastChoice)
            {
                // The cursor has moved or the menu was just activated;
                // load up the new string
                if(choiceSlot!=TANGO_INVALID)
                    Tango_ClearSlot(choiceSlot);
                choiceSlot = ShowMessage(choiceStrings[currentChoice], TANGO_SLOT_NORMAL, STYLE_PLAIN, 72, 104);
                lastChoice=currentChoice;
            }
            Waitframe();
        }
        
        if(choiceSlot!=TANGO_INVALID)
            Tango_ClearSlot(choiceSlot);
        
        // Load the value to pass to @string
        Tango_SetSlotVar(talkSlot, TANGO_VAR_A0,
          choiceStrings[Tango_GetLastMenuChoice()-1]);
        
        while(Tango_SlotIsActive(talkSlot))
            Waitframe();
}//end Shop

int get_item_name(int item_id){
    // Used with the shop function

    if(item_id == 150){ int name[] = "Mint"; return name;}
    if(item_id == 151){ int name[] = "Ginger"; return name;}
    if(item_id == 152){ int name[] = "Orchid"; return name;}
    if(item_id == 153){ int name[] = "Claw"; return name;}

}// end of get_item_name


#228 Saffith

Saffith

    IPv7 user

  • Members

Posted 27 December 2015 - 10:35 PM

get_item_name() can't return a string; you have to pass in an output array and use strcpy().

There's another way to do it. Tango_LoadString() takes an optional argument that lets you specify a character indicating the start of the text to load. Using that, you could put the display names right in the item names.
In your ShowString() function, if you change
Tango_LoadString(slot, string);
to
Tango_LoadString(slot, string, '%');
Then you name your items, for instance,
Ingredient - Mint %Mint
And then you can just use itemdata->GetName() and display the result of that. Names without % in them will be displayed in full.
 

If I expand Tango_D[] to a size of 214747, will I be able to use @d* up to an index value of 214747A, or is the data accessor token not set up for that?

It could be done, but it wouldn't be straightforward. The converted value of the name jumps at each power of ten; @d9 would be 0.0064, and @d10 would be 0.0419.

#229 KCJV

KCJV

    Newbie

  • Members
  • Real Name:Killian
  • Location:Reims, France

Posted 28 December 2015 - 03:23 PM

Just two questions: is there an easy way to change the tiles used for the text box?

And how do I make a NPC solid? (because I tested the script on my own project but the NPC wasn't solid)


Edited by KCJV, 28 December 2015 - 05:28 PM.


#230 Saffith

Saffith

    IPv7 user

  • Members

Posted 28 December 2015 - 07:45 PM

Just two questions: is there an easy way to change the tiles used for the text box?

That's part of the style settings. If you're looking at the demo, check styles.zh. The first group of settings for each style set the backdrop.
 

And how do I make a NPC solid? (because I tested the script on my own project but the NPC wasn't solid)

The FFCs themselves aren't solid; they're just placed on top of solid tiles.

#231 Gégé

Gégé

    Senior

  • Members
  • Real Name:Gérard
  • Location:France

Posted 29 December 2015 - 04:44 AM

Hello, I just noticed that the popup message disappear when Link changes screen and the next message popup, it waits a while to show up.
I made a mistake somewhere ?

#232 KCJV

KCJV

    Newbie

  • Members
  • Real Name:Killian
  • Location:Reims, France

Posted 29 December 2015 - 06:11 AM

Thanks Saffith :) I succeeded to fix it



#233 Saffith

Saffith

    IPv7 user

  • Members

Posted 29 December 2015 - 02:16 PM

Hello, I just noticed that the popup message disappear when Link changes screen and the next message popup, it waits a while to show up.
I made a mistake somewhere ?

Does the style have TANGO_FLAG_CARRY_OVER set?

#234 Gégé

Gégé

    Senior

  • Members
  • Real Name:Gérard
  • Location:France

Posted 29 December 2015 - 05:18 PM

Thank you, I have forgotten it :love: .


Edited by Gégé, 29 December 2015 - 05:18 PM.


#235 C-Dawg

C-Dawg

    Magus

  • Members

Posted 30 December 2015 - 12:13 AM

Okay, I've made progress.  Now, when the shop menu pop up, I do at least get a prompt message and I am able to put the menu cursors in the right place.  But, for some reason, the item names don't show up; indeed, the whole second Tango window where they should be doesn't appear.  I've updated the DropBox if you wanna see it in action (you need to talk to Sasparilla twice to get the shop to open for business.)  Also, note that I moved all tango-specific functions to "common.c."

 

Here's the new shop code:

void Shop(int message, int item1_id, int item1_price, int item2_id, int item2_price, int item3_id, int item3_price)
    {

        // You need to add "@synch(1) to the message string you pass into this function
        // If you want the menu to appear.

        int talkSlot;
        int choiceSlot=TANGO_INVALID;
        int currentChoice;
        int lastChoice=-1;

        int choiceX[]={ 78, 78, 78 };
        int choiceY[]={ 110, 136, 152 };

        itemdata first_item;
        first_item->Family = item1_id;
        first_item->Level = 1;
        int buffer1;
        first_item->GetName(buffer1);

        itemdata second_item;
        second_item->Family = item2_id;
        second_item->Level = 1;
        int buffer2;
        second_item->GetName(buffer2);

        itemdata third_item;
        second_item->Family = item2_id;
        second_item->Level = 1;
        int buffer3;
        third_item->GetName(buffer3);

        int choiceStrings[]={ buffer1, buffer2, buffer3};

        talkSlot=ShowString(message, TANGO_SLOT_NORMAL, STYLE_PLAIN, 32, 16);
              
        // The string will call @sync(1) when the menu should start
        Tango_Sync(1);
        
        // Set up the menu
        Tango_InitializeMenu();
        Tango_SetMenuCursor(13829, 0, 1, 1);
        Tango_SetMenuSFX(66, 67, 0);
        for(int i=0; i<3; i++) Tango_AddMenuChoice(i+1, choiceX[i], choiceY[i]);
        
        Tango_ActivateMenu(false);
        
        // Show a second string with whatever the cursor is currently on
        while(Tango_MenuIsActive())
        {
            // In this menu, the value of each choice is one greater than
            // the corresponding array position
            currentChoice=-1;
            if(currentChoice!=lastChoice)
            {
                // The cursor has moved or the menu was just activated;
                // load up the new string
                if(choiceSlot!=TANGO_INVALID)
                    Tango_ClearSlot(choiceSlot);

                choiceSlot = ShowMessage(choiceStrings[currentChoice], TANGO_SLOT_NORMAL, STYLE_PLAIN, 72, 88);
                lastChoice=currentChoice;
            }
            Waitframe();
        }
        
        if(choiceSlot!=TANGO_INVALID)
            Tango_ClearSlot(choiceSlot);
        
        // Load the value to pass to @string
        Tango_SetSlotVar(talkSlot, TANGO_VAR_A0,
          choiceStrings[Tango_GetLastMenuChoice()-1]);
        
        while(Tango_SlotIsActive(talkSlot))
            Waitframe();
}//end Shop

 

Along the same lines, I was using TangoAnySlotActive() to have the NPC check when to return to waiting status.  But, that never seems to trigger.  Do I need to declare a tango slot and check that slot specifically?  When does Tango automatically inactivate slots?



#236 Saffith

Saffith

    IPv7 user

  • Members

Posted 30 December 2015 - 02:27 AM

You need to be declaring buffer1, buffer2, and buffer3 as arrays of size 65, and you should have
choiceSlot = ShowString(choiceStrings[currentChoice-1], TANGO_SLOT_NORMAL, STYLE_PLAIN, 72, 88);
Also, I'm not sure setting up an itemdata that way works; use Game->LoadItemData() for that.

A slot is active as long as it's visible, even if it's suspended. Do you mean that checking if a specific slot is active worked, but checking if any was active didn't? I hope I'm misunderstanding, because that would be very weird.

#237 C-Dawg

C-Dawg

    Magus

  • Members

Posted 30 December 2015 - 09:59 AM

What I mean is that TangoAnySlotActive does not appear to be returning false when the message window closes automatically. You can see the application in the NPC.c script for Sasparilla.\

 

 

You need to be declaring buffer1, buffer2, and buffer3 as arrays of size 65, and you should have
choiceSlot = ShowString(choiceStrings[currentChoice-1], TANGO_SLOT_NORMAL, STYLE_PLAIN, 72, 88);

 

So, do you mean that I cannot use ShowMessage to display the choiceStrings?


Edited by C-Dawg, 30 December 2015 - 02:15 PM.


#238 Saffith

Saffith

    IPv7 user

  • Members

Posted 30 December 2015 - 03:47 PM

Ah, took me a bit, but I see the problem...
if(!Tango_AnySlotIsActive()) state == N_NORMAL;
You'll also need to check for state_counter>2 so that doesn't trigger before the string is displayed.

ShowMessage() is used for messages defined in Quest -> Strings in ZQuest. ShowString() is for ZScript strings.

#239 C-Dawg

C-Dawg

    Magus

  • Members

Posted 30 December 2015 - 04:04 PM

Oh.  So I just goofed on the assign statement?  That's embarrassing.   

 

I wonder if the white Russian I drank before coding last night had anything to do with these stupid little errors? 


Edited by C-Dawg, 30 December 2015 - 04:05 PM.


#240 Saffith

Saffith

    IPv7 user

  • Members

Posted 03 January 2016 - 08:52 PM

I'm thinking of renaming TANGO_STYLE_MENU_CURSOR_WIDTH next version. The name's slightly misleading - it actually controls text indentation - and I want to add a cursor width setting to allow background color cursors.

It's a simple thing to fix, obviously. I just don't want to change things without warning.

(Edit: Well, it's not much warning, but whatever.)


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users