Jump to content

Photo

tango.zh


  • Please log in to reply
398 replies to this topic

#136 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 08 July 2015 - 08:03 AM

Friends, my question about the OneTimeMessage script is because of this error:
 
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Building symbol tables
Pass 4: Type-checking/Completing function symbol tables/Constant folding
tangoBR/scripts.z, line 29: Error T21: Could not match type signature ShowMessage(float).
 
 
edit: I found the problem to the error above (a conflict with the NPC script that uses the "int ShowMessage()" from the tangodemo.qst) but now the OneTimeMessage script doesn't work with the ShowMessage(id) function.


Revert whatever changes you made to the Tango.zh demo scripts, if you removed another function, et. al., then do this:
 
bool stringnewloc[256];

ffc script OneTimeMessage_NewLocations
{
    void run(int message, int boolean){
        if(!stringnewloc[boolean]){
            TangMessage(message);
            stringnewloc[boolean] = true;
        }
    }
}

int TangMessage(int message)
{
    int slot=Tango_GetFreeSlot(TANGO_SLOT_ANY);
    if(slot==TANGO_INVALID)
        return TANGO_INVALID;
    
    Tango_ClearSlot(slot);
    Tango_LoadMessage(slot, message);
    Tango_SetSlotStyle(slot, STYLE_PLAIN);
    Tango_SetSlotPosition(slot, 56, 32);
    Tango_ActivateSlot(slot);
    
    return slot;
}
All I did there, was rename the function, and make the function call match. That will prevent conflicts of that sort, although the base ShowMessage() accepts more args, and it should compile with both.

I can't dissect anything that you don't post though. What exactly is the nature of the problem you are encountering?

Are you intending to use the Tango Demo NPC script?

More important: Exactly what Tango version are you using? The slot defs are different in some builds.

Perhaps, just use this, instead...
//Args
// D0: Message ID
// D1 ScreenD[reg] to use.
// D2 Value to set ScreenD[reg]. Must be at least 0.0001, and integer values will work too. 

ffc script TangMessage{
	void run (int message, int reg, float dat){
		int thisScreen = Game->GetCurScreen();
		curDat = GetScreenD(curScreen,reg);
		int state = 1;
		int newDat = curDat + dat;
		if ( dat && curDat != dat ) {
			while( state > 0 ){
				int slot = Tango_GetFreeSlot(TANGO_SLOT_ANY);
				if ( slot == TANGO_INVALID ) Waitframe();
				SetScreenD(curScreen,reg,newDat);
				Tango_ClearSlot(slot);
				Tango_LoadMessage(slot, message);
				Tango_SetSlotStyle(slot, STYLE_PLAIN);
				Tango_SetSlotPosition(slot, 56, 32);
				Tango_ActivateSlot(slot);
				if ( Link->PressA || Link->PressB || Link->InputA || Link->InputB ) state = 0;
				Waitframe();
			}
		}
		this->X = -32768;
		this->Y = -32768;
		this->Data = 0;
		return;
	}
}

Edited by ZoriaRPG, 08 July 2015 - 08:21 AM.


#137 Saffith

Saffith

    IPv7 user

  • Members

Posted 08 July 2015 - 10:25 AM

If you change the OneTimeMessage script to this, it should work.
 
ffc script OneTimeMessage
{
    void run(int message, int boolean){
        if(!stringnewloc[boolean]){
            ShowMessage(message, TANGO_SLOT_NORMAL, STYLE_PLAIN, 32, 32);
            stringnewloc[boolean] = true;
        }
    }
}


#138 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 08 July 2015 - 11:18 AM

If you change the OneTimeMessage script to this, it should work.
 

ffc script OneTimeMessage
{
    void run(int message, int boolean){
        if(!stringnewloc[boolean]){
            ShowMessage(message, TANGO_SLOT_NORMAL, STYLE_PLAIN, 32, 32);
            stringnewloc[boolean] = true;
        }
    }
}

The main reason I didn't suggest that, is because he already removed that version of the function, or so it seems by reading the post. I honestly have no idea what he's changed either, to make it compile. :shrug:

 

I just slapped together an FFC that does the message, and doesn't need a global array; especially considering that the index size doesn't make much sense. He'd be limited to 256 screens with messages, but that's not the big flaw. Keeping track of the last number used, and remembering which one is where, can be tedious.

 

If anyone wants to use a global array for it, it'd be better to store a value equal to the ( map number * screen number ). That way, you don't need to enter any value in the FFC arg. it just runs once per possible screen, and flags the screen value in one large array.



#139 accela2me

accela2me

    Illustrious

  • Members
  • Real Name:Juliano
  • Location:Minas Gerais, Brazil

Posted 08 July 2015 - 03:53 PM

People, what I mean is that the OneTimeMessage script doesn't work with the ShowMessage(message). Nothing happens. So I need to know is if something is missing/wrong with the script below. By the way, I'm using the latest tango version.

 

edit: ZoriaRPG, I tried to use the TangMessage script, but "curDat" and "curScreen" are undeclared :/

import "std.zh"
import "string.zh"
import "tango.zh"

const int STYLE_PLAIN = 0;
bool linkAlreadyTalking;

// -----------------------------------------------------------------------------------------------------------------------

global script Slot_2
{
    void run(){

        SetUpStyles();
        Tango_Start();
        linkAlreadyTalking=false;

        while(true){
        
            if(Link->Action==LA_SCROLLING)
                linkAlreadyTalking=false;

            Tango_Update1();

            Waitdraw();

            Tango_Update2();

            Waitframe();

        }
    }
}

// -----------------------------------------------------------------------------------------------------------------------

void SetUpStyles()
{
    SetUpPlainStyle();
}

// Returns true if Link is trying to talk to this NPC.
bool StartTalking(ffc this)
{
    if(!Link->PressA || linkAlreadyTalking)
        return false;
    
    bool talk=false;
    
    if(Link->Dir==DIR_UP)
    {
        if(Abs(Link->X-this->X)<8 && Abs(Link->Y-8-this->Y)<8)
            talk=true;
    }
    else if(Link->Dir==DIR_DOWN)
    {
        if(Abs(Link->X-this->X)<8 && Abs(Link->Y+16-this->Y)<8)
            talk=true;
    }
    else if(Link->Dir==DIR_LEFT)
    {
        if(Abs(Link->X-16-this->X)<8 && Abs(Link->Y-this->Y)<8)
            talk=true;
    }
    else
    {
        if(Abs(Link->X+16-this->X)<8 && Abs(Link->Y-this->Y)<8)
            talk=true;
    }
    
    if(talk)
    {
        linkAlreadyTalking=true;
        return true;
    }
    else
        return false;
}

// Free up Link to talk to other NPCs.
void StopTalking()
{
    linkAlreadyTalking=false;
}

// -----------------------------------------------------------------------------------------------------------------------

import "tango/font/GUI.zh"

void SetUpPlainStyle()
{
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_BACKDROP_TYPE, TANGO_BACKDROP_TILE);
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_BACKDROP_TILE, 520);
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_BACKDROP_CSET, 2);
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_BACKDROP_WIDTH, 10);
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_BACKDROP_HEIGHT, 4);

Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_TEXT_FONT, TANGO_FONT_GUI);
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_TEXT_X, 8);
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_TEXT_Y, 6);
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_TEXT_WIDTH, 144);
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_TEXT_HEIGHT, 52);
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_TEXT_CSET, 0);
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_TEXT_COLOR, 1);
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_TEXT_SPEED, 3);
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_TEXT_SFX, 18);

Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_FLAGS,
TANGO_FLAG_ENABLE_SPEEDUP | TANGO_FLAG_ENABLE_SUPER_SPEED);

Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_MORE_COMBO, 793);
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_MORE_CSET, 2);
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_MORE_X, 160);
Tango_SetStyleAttribute(STYLE_PLAIN, TANGO_STYLE_MORE_Y, 48);    
}

// -----------------------------------------------------------------------------------------------------------------------

// Uses Tango to display a ZC message (Quest > Strings). Returns the number of
// the text slot used or TANGO_INVALID if the message could not be displayed.
int ShowMessage(int message)
{
    int slot=Tango_GetFreeSlot(TANGO_SLOT_ANY);
    if(slot==TANGO_INVALID)
        return TANGO_INVALID;
    
    Tango_ClearSlot(slot);
    Tango_LoadMessage(slot, message);
    Tango_SetSlotStyle(slot, STYLE_PLAIN);
    Tango_SetSlotPosition(slot, 56, 32);
    Tango_ActivateSlot(slot);
    
    return slot;
}

// -----------------------------------------------------------------------------------------------------------------------

ffc script NPC
{
    void run(int message){
        while(true){
            if(StartTalking(this)){
                int slot=ShowMessage(message);

                if(slot!=TANGO_INVALID){
                    while(Tango_SlotIsActive(slot))
                    Waitframe();
                }
                StopTalking();
            }
            Waitframe();
        }
    }
}


bool stringnewloc[256];

ffc script OneTimeMessage
{
    void run(int message, int boolean){
        if(!stringnewloc[boolean]){
            ShowMessage(message);
            stringnewloc[boolean] = true;
        }
    }
}

Edited by accela2me, 08 July 2015 - 04:04 PM.


#140 Saffith

Saffith

    IPv7 user

  • Members

Posted 08 July 2015 - 04:14 PM

Ah, okay. But the NPC script works? There's nothing obviously wrong. Are you using an old save, perhaps?

#141 accela2me

accela2me

    Illustrious

  • Members
  • Real Name:Juliano
  • Location:Minas Gerais, Brazil

Posted 08 July 2015 - 05:13 PM

Yes, the NPC script works very well.

Here the updated test file:
https://dl.dropboxus...472/tangoBR.rar

 

 

 



#142 Saffith

Saffith

    IPv7 user

  • Members

Posted 09 July 2015 - 03:18 PM

Actually, I think I've dealt with this before. It seems to be that a script like that doesn't work with a screen opening animation, meaning it won't work on the first screen or after certain types of warps. It should work if you add a Waitframe:
ffc script OneTimeMessage
{
    void run(int message, int boolean){
        Waitframe();
        if(!stringnewloc[boolean]){
            ShowMessage(message);
            stringnewloc[boolean] = true;
        }
    }
}


#143 accela2me

accela2me

    Illustrious

  • Members
  • Real Name:Juliano
  • Location:Minas Gerais, Brazil

Posted 09 July 2015 - 05:07 PM

It's working now! Thanks, Saffith :)



#144 Moosh

Moosh

    The Mush

  • Moderators

Posted 24 July 2015 - 04:01 PM

Would you happen to have a working example of a simple Yes/No/Other option lying around? I just want to have a string that plays normally and then another text box pops up with the yes/no prompt. What I'm finding currently is that the Yes/No cursor is showing up but I have no clue how to assign strings to the options. I'm hoping once I figure out how this feature works it'll be easier than what I was doing beforehand.

 

Also is there any good way to have scaling string backgrounds? It feels awful annoying to have to create a new background tile block for every new size of string instead of doing what ZC does and copying parts of a 2x2 block. It'd also be cool if width and height could be written to on a per string basis instead of being defined in the style. Maybe it's all right there and I'm just too dumb to see it, maybe I ask too much.



#145 Saffith

Saffith

    IPv7 user

  • Members

Posted 24 July 2015 - 04:54 PM

Would you happen to have a working example of a simple Yes/No/Other option lying around? I just want to have a string that plays normally and then another text box pops up with the yes/no prompt.

If you want the menu in a separate window, it's easiest to use a custom function to launch it. You could do something like this:
float __Tango_RunCustomFunction(float function, float args)
{
    if(function==FUNC_SHOWMENU)
    {
        // Arg 0: Message to show as a menu
        // Args 1-3: Next message if corresponding option is picked
        Tango_D[0]=args[1];
        Tango_D[1]=args[2];
        Tango_D[2]=args[3];
        ShowMenuMessage(args[0]); // Shows the message in the menu style
    }
    
    return 0;
}
The menu messages would look like
@choice(@d0)Yes@26@choice(@d1)No@26@choice(@d2)Maybe@domenu()

And the message displaying it would be something like
Pick an option!@showmenu(3 10 11 12)@menuwait()@goto(@chosen)

That would show message 3 as the menu and switch to message 10, 11, or 12 depending on the selection.

If you want an example quest, I can throw one together.
 
 

Also is there any good way to have scaling string backgrounds? It feels awful annoying to have to create a new background tile block for every new size of string instead of doing what ZC does and copying parts of a 2x2 block.

There isn't anything built in. You could do something with CopyTile(), perhaps.

#146 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 24 July 2015 - 07:16 PM

I'd suggest including annotated sample menus, and dialogue boxes, and such, in your next dist. package.
 
I set up a special branched package of b.1.0.0, that has some of that, and is set up to allow six slots, cascading menus, and the like. Perhaps I will eventually make it 'round to producing some extensive docs, but it's not my chief priority, particularly because my use of Tango is a bit specialised.



#147 Cereal Guy

Cereal Guy

    Senior

  • Members
  • Location:Concepción, CHL

Posted 12 August 2015 - 07:01 PM

please i need a video-tutorial for how to configure this :( I just need to set the aLttP font 



#148 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 12 August 2015 - 07:38 PM

please i need a video-tutorial for how to configure this :( I just need to set the aLttP font


Do you have it working, without that font?

#149 xenomicx

xenomicx

    Zelda Arcade

  • Members
  • Location:Chi-town

Posted 15 September 2015 - 05:44 PM

Are there updated versions of "navi.z", "npc.z", and "zelda.z" used in the demo? They are currently using fucntions StartTalking() and StopTalking...both of which I don't see in the Tango 1.0.0 release.

Also, I'm trying to figure out how to animate, or add a animated combo. Example, have Links mouth moving when text is typing.


Edited by xenomicx, 15 September 2015 - 06:46 PM.


#150 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 15 September 2015 - 09:30 PM

I think Start/StopTalking() are in the Tango demo code, not Tango itself.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users