Jump to content

Photo

tango.zh


  • Please log in to reply
398 replies to this topic

#166 xenomicx

xenomicx

    Zelda Arcade

  • Members
  • Location:Chi-town

Posted 06 October 2015 - 12:54 PM

It's because of the string control code. \25 is actually stored as 26, so that's what I used. 10 would be control code 9, go to if Triforce count.

How do I change the color of the text? I tried using string codes (example: \1\1\5) and I've tried to use tango code (example: @cset(6)@color(8) ) to give me a green color. However, the text just ends right where the code is entered.



#167 Saffith

Saffith

    IPv7 user

  • Members

Posted 06 October 2015 - 01:23 PM

String control codes other than \25 are disabled by default. In the main file, import stringControlCode.zh instead of stringControlCodeDisabled.zh to enable them. (I might change that. Seems kind of silly now.)
@cset and @color are variables, not functions. Use @set(@cset 6) and @set(@color 8) instead.

#168 xenomicx

xenomicx

    Zelda Arcade

  • Members
  • Location:Chi-town

Posted 06 October 2015 - 04:08 PM

String control codes other than \25 are disabled by default. In the main file, import stringControlCode.zh instead of stringControlCodeDisabled.zh to enable them. (I might change that. Seems kind of silly now.)
@cset and @color are variables, not functions. Use @set(@cset 6) and @set(@color 8) instead.

Got it...absolutely loving this!

Here is another problem I'm running into: I copied the Custom Variables you used in the TangoDemo because I liked the idea of @talkcount. However I thought the count would reset with each new FFC. I'm trying to make it possible for each NPC I have, to say more than one message. The first string for the NPC's looks like this:

@inc(@talkcount 1)@if(@greater(@talkcount 1)@append(20))@elseif(@greater(@talkcount 0)@append(19))

So basically the first time this runs, the NPC will play string 19, and the next time will play string 20. I can keep adding @elseif statement all day long, so the NPC will always say something different, and maybe I'll even have it loop back to the beginning with some of them. Possiblities are endless! But @talkcount never resets back to 0. So if I go to another NPC and talk to them, they respond as if I have already spoke to them once before. How would I change this to reset with new NPC's. I can't have it reset each time otherwise it would never reach the second message...right? Here is the code in tango.zh


Edited by xenomicx, 06 October 2015 - 04:09 PM.


#169 Deedee

Deedee

    Small Pixie Dragon

  • Administrators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 06 October 2015 - 04:31 PM

For some reason, my menu doesn't understand what pressing down means. When I press left or right, it moves to the next choice, but it won't move to the choice associated with down. Help?

                Link->PressStart = false; //begin code snip
		Link->InputStart = false;
		Tango_InitializeMenu();
		Tango_AddMenuChoice(1, 48, 64);
		Tango_AddMenuChoice(2, 96, 64);
		Tango_AddMenuChoice(3, 144, 64);
		Tango_AddMenuChoice(4, 192, 64);
		Tango_AddMenuChoice(5, 48, 112);
		Tango_AddMenuChoice(6, 220, 64);
		Tango_SetMenuCursor(33712, 11);
		Tango_SetMenuSFX(5, 25, 40);
		Tango_ActivateMenu(true);
	}
	else if (Tango_MenuIsActive() == true)
	{
		int Hello = Tango_GetMenuCursorPosition();
		
		if (Hello == 1)
		{
			if (Link->PressRight == true)
			{
				Tango_SetMenuCursorPosition(2);
			}
			else if (Link->PressLeft == true)
			{
				Tango_SetMenuCursorPosition(4);
			}
			else if (Link->PressDown == true)
			{
				Tango_SetMenuCursorPosition(5);
			}
		} //end code snip


#170 Saffith

Saffith

    IPv7 user

  • Members

Posted 06 October 2015 - 05:03 PM

Here is another problem I'm running into: I copied the Custom Variables you used in the TangoDemo because I liked the idea of @talkcount. However I thought the count would reset with each new FFC. I'm trying to make it possible for each NPC I have, to say more than one message.

There are a couple of ways you could do that. If you're okay with the count resetting every time you leave the screen, you could use ffc->Misc[]. It's only slightly tricky; you need to keep track of the active one globally, but you can't have a global ffc pointer. You'd have to do something like this:
int CurrentFFC;

void SetCurrentFFC(ffc this)
{
    for(int i=1; i<=32; i++)
    {
        ffc f=Screen->LoadFFC(i);
        if(f==this)
        {
            CurrentFFC=i;
            return;
        }
    }
}

ffc GetCurrentFFC()
{
    return Screen->LoadFFC(CurrentFFC);
}
 
Then the variable implementation would look like this:
    // get
    if(var==VAR_TALKCOUNT)
    {
        ffc f=GetCurrentFFC();
        return f->Misc[IDX_TALKCOUNT];
    }
    
    // set
    if(var==VAR_TALKCOUNT)
    {
        ffc f=GetCurrentFFC();
        f->Misc[IDX_TALKCOUNT]=value;
    }
 
If you want them to keep track after you leave the screen, you'd need Screen->D[] or a global array or something, but the general idea would be the same. You just need some global indicator to keep track of which one's active.
 

I'm trying to make it possible for each NPC I have, to say more than one message. The first string for the NPC's looks like this:

 
@inc(@talkcount 1)@if(@greater(@talkcount 1)@append(20))@elseif(@greater(@talkcount 0)@append(19))

You'll probably want to use sprintf() to automate that. In case you don't know how, that'd be something like:
void MultiMessage(int slot, int msg1, int msg2)
{
    int format[]="@inc(@talkcount 1)@if(@greater(@talkcount 1)@append(%d))@elseif(@greater(@talkcount 0)@append(%d))";
    int buffer[256];
    sprintf(buffer, format, msg1, msg2);
    Tango_ClearSlot(slot);
    Tango_LoadString(buffer);
}
 
 

For some reason, my menu doesn't understand what pressing down means. When I press left or right, it moves to the next choice, but it won't move to the choice associated with down. Help?

I'm not quite sure what you're doing. Are you trying to handle input yourself? You don't need to do that; it's all automatic. All you need to do is wait until Tango_MenuIsActive() return false.

#171 Deedee

Deedee

    Small Pixie Dragon

  • Administrators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 06 October 2015 - 05:42 PM

I removed the code thing. It still moves left and right, but it won't move down (choice 5 is south from 1, same x position). What am I doing wrong?

 

if (Link->PressStart == true && Tango_MenuIsActive() == false)
	{
		
		Link->PressStart = false;
		Link->InputStart = false;
		Tango_InitializeMenu();
		Tango_AddMenuChoice(1, 48, 64);
		Tango_AddMenuChoice(2, 96, 64);
		Tango_AddMenuChoice(3, 144, 64);
		Tango_AddMenuChoice(4, 192, 64);
		Tango_AddMenuChoice(5, 48, 112);
		Tango_AddMenuChoice(6, 220, 64);
		Tango_SetMenuCursor(33712, 11);
		Tango_SetMenuSFX(5, 25, 40);
		Tango_ActivateMenu(true);
	}
	else if (Tango_MenuIsActive() == true)
	{
		Screen->DrawLayer(6, 1, 0x71, 0, 0, 0, 0, 128);
		Screen->FastTile(6, 48, 64, 63841, 0, OP_OPAQUE);
		Screen->FastTile(6, 96, 64, 63855, 0, OP_OPAQUE);
		Screen->FastTile(6, 144, 64, 64174, 0, OP_OPAQUE);
		Screen->FastTile(6, 192, 64, 981, 8, OP_OPAQUE);
		
		int Numbero = 48;
		Screen->FastCombo(6, Numbero, 112, 30764, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 112, 30766, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero, 128, 30772, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 128, 30774, 0, OP_OPAQUE);
		Numbero = 80;
		Screen->FastCombo(6, Numbero, 112, 30764, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 112, 30766, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero, 128, 30772, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 128, 30774, 0, OP_OPAQUE);
		Numbero = 112;
		Screen->FastCombo(6, Numbero, 112, 30764, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 112, 30766, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero, 128, 30772, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 128, 30774, 0, OP_OPAQUE);
		Numbero = 144;
		Screen->FastCombo(6, Numbero, 112, 30764, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 112, 30766, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero, 128, 30772, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 128, 30774, 0, OP_OPAQUE);
		Numbero = 176;
		Screen->FastCombo(6, Numbero, 112, 30764, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 112, 30766, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero, 128, 30772, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 128, 30774, 0, OP_OPAQUE);
		
		Screen->FastCombo(6, 56, 120, 32929, 6, OP_OPAQUE);
		if (Link->Item[157] == true)
		{
			Screen->FastCombo(6, 88, 120, 32933, 0, OP_OPAQUE);
		}
		if (Link->Item[158] == true)
		{
			Screen->FastCombo(6, 120, 120, 32937, 0, OP_OPAQUE);
		}
		if (Link->Item[159] == true)
		{
			Screen->FastCombo(6, 152, 120, 32941, 0, OP_OPAQUE);
		}
		if (Link->Item[160] == true)
		{
			Screen->FastCombo(6, 184, 120, 32945, 0, OP_OPAQUE);
		}
	}


#172 xenomicx

xenomicx

    Zelda Arcade

  • Members
  • Location:Chi-town

Posted 06 October 2015 - 06:18 PM

There are a couple of ways you could do that. If you're okay with the count resetting every time you leave the screen, you could use ffc->Misc[]. It's only slightly tricky; you need to keep track of the active one globally, but you can't have a global ffc pointer. You'd have to do something like this:

I'm ok with the counter resetting...just in case something important is said at first, the player can return and have the message repeat. However, I don't know where this code is suppose to go. In my global script? My global script is script.zh in the ghost_zh folder.

 

Then the variable implementation would look like this:

I'm not sure where this goes either...in tango.zh? Do I replace the code you made for @talkcount? And these variables are undeclared so I don't know if they are float or int.

 

You'll probably want to use sprintf() to automate that. In case you don't know how, that'd be something like:

I really don't want to use something like this. Some NPC's will use 2 messages, some 3, some 4, some 100 when I'm done. So I really can't pass 100 arguments in a function can I?



#173 Saffith

Saffith

    IPv7 user

  • Members

Posted 06 October 2015 - 06:37 PM

I removed the code thing. It still moves left and right, but it won't move down (choice 5 is south from 1, same x position). What am I doing wrong?

Nothing obvious. Could there be another script unpressing down before it updates? Try checking it just before Tango_Update1().


 

I'm ok with the counter resetting...just in case something important is said at first, the player can return and have the message repeat. However, I don't know where this code is suppose to go. In my global script? My global script is script.zh in the ghost_zh folder.

Outside of any script. The NPC script should call SetCurrentNPC(this) just before it displays a message.
 
 

I'm not sure where this goes either...in tango.zh? Do I replace the code you made for @talkcount? And these variables are undeclared so I don't know if they are float or int.

Yes, those would replace the corresponding code in Tango_GetCustomVar() and Tango_SetCustomVar().
 

I really don't want to use something like this. Some NPC's will use 2 messages, some 3, some 4, some 100 when I'm done. So I really can't pass 100 arguments in a function can I?

You can make different versions that take different numbers of arguments. For larger numbers, you can put as many as you want in an array. The string writing logic would be a bit trickier, though. Assuming you'll only have a few that use larger numbers, it might be more reasonable to use a separate script for those.
You could also simplify things by ensuring that a given NPC's messages are consecutive numbers.

ffc script NPC
{
    void run(int firstMessage, int numMessages)
    {
        if(/* talking */)
            ShowMessage(firstMessage+Min(this->Misc[IDX_TALKCOUNT], numMessages-1));
    }
}
That might be a bit of a pain to update if you decide to add another message, however.
Long @if(...)@elseif(...) chains work fine, but keep in mind that you'll have to have enough room in Tango_Buffer[].

#174 Deedee

Deedee

    Small Pixie Dragon

  • Administrators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 06 October 2015 - 07:02 PM

Yeah, it's not getting unpressed... It's getting pressed before Tango when I use my "detect pressed buttons" function, but not after Tango. So I think Tango's the problem.



#175 xenomicx

xenomicx

    Zelda Arcade

  • Members
  • Location:Chi-town

Posted 06 October 2015 - 07:17 PM


Long @if(...)@elseif(...) chains work fine, but keep in mind that you'll have to have enough room in Tango_Buffer[].

So just to be clear, I set up these custom variable under the code already there like this:

IDX_TALKCOUNT is still undefined though. And what is a safe buffer size? Should I just double it to Tango_Buffer[2048]? And that should be SetCurrentFFC(this); right? Not SetCurrentNPC(this); either way I'm not getting the message to show up now.


Edited by xenomicx, 06 October 2015 - 07:26 PM.


#176 Saffith

Saffith

    IPv7 user

  • Members

Posted 06 October 2015 - 07:53 PM

Yeah, it's not getting unpressed... It's getting pressed before Tango when I use my "detect pressed buttons" function, but not after Tango. So I think Tango's the problem.

Oh, I bet I know. Did you ever set __TANGO_MAX_MENU_ITEMS? There's a limit of 4 menu items by default. If you haven't increased the limit, items 5 and 6 will be ignored.
 

IDX_TALKCOUNT is still undefined though.

That was just a placeholder. You can define it as a constant or replace it with a number. Doesn't matter what it is.
 

And what is a safe buffer size? Should I just double it to Tango_Buffer[2048]?

Depends on what you're doing. The default should be fine in most cases, though. If you overdo it, the string won't print correctly and an error will be logged, so you could just wait until you run into problems before making any changes. You might want to use full error logging; edit the main file to import loggingFull.zh instead of loggingMinimal.zh to do that.
@if(@greater(@talkcount 1) @append(20)) takes, if I remember correctly, 15 elements of the array. Each subsequent @elseif() is the same. If you're only doing three or four messages, there's plenty of room. You'd have to increase the buffer quite a bit for a hundred, but I expect the processing time would become a problem long before the buffer size.
 

And that should be SetCurrentFFC(this); right? Not SetCurrentNPC(this); either way I'm not getting the message to show up now.

Oops, yes.

#177 xenomicx

xenomicx

    Zelda Arcade

  • Members
  • Location:Chi-town

Posted 06 October 2015 - 08:37 PM

I can't get any of the tango codes to work now. If has to be within the if statement in the Custom Variables section we set up...or maybe the I need to return ffc f? I'm just going to keep it at a max of 5 messages, and want to use this (because I have already set up around 20 of them(x 5 appended messages)):

@inc(@talkcount 1)@if(@greater(@talkcount 1)@append(20))@elseif(@greater(@talkcount 0)@append(19))@elseif(@greater(@talkcount 2)@append(21))@elseif(@greater(@talkcount 50)@append(22))@elseif(@greater(@talkcount 100)@append(23))

I'm kind of lost now...so you might want to baby step me through this.



#178 Deedee

Deedee

    Small Pixie Dragon

  • Administrators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 06 October 2015 - 08:41 PM

Yeah, turns out I didn't set that. Now I have a new problem. When I press up or down on any menu item, orpres right or left on the rightmost or leftmost ones respectively, the cursor goes to the topleft corner. and there only appears to be one menu item there, as when I press any direction key after that, it goes back to the 4 menu items I had before. PS: I set the max menu limit to 12.

 

if (Link->PressStart == true && Tango_MenuIsActive() == false)
	{
		
		Link->PressStart = false;
		Link->InputStart = false;
		Tango_InitializeMenu();
		Tango_AddMenuChoice(1, 48, 48);
		Tango_AddMenuChoice(2, 96, 48);
		Tango_AddMenuChoice(3, 144, 48);
		Tango_AddMenuChoice(4, 192, 48);
		Tango_AddMenuChoice(5, 48, 80);
		Tango_AddMenuChoice(6, 96, 80);
		Tango_AddMenuChoice(7, 144, 80);
		Tango_AddMenuChoice(8, 192, 80);
		Tango_SetMenuCursor(33712, 11);
		Tango_SetMenuSFX(5, 25, 40);
		Tango_ActivateMenu(true);
	}
	else if (Tango_MenuIsActive() == true)
	{
		Screen->DrawLayer(6, 1, 0x71, 0, 0, 0, 0, 128);
		Screen->FastTile(6, 48, 64, 63841, 0, OP_OPAQUE);
		Screen->FastTile(6, 96, 64, 63855, 0, OP_OPAQUE);
		Screen->FastTile(6, 144, 64, 64174, 0, OP_OPAQUE);
		Screen->FastTile(6, 192, 64, 981, 8, OP_OPAQUE);
		
		Screen->FastTile(6, 48, 96, 65003, 0, OP_OPAQUE);
		Screen->FastTile(6, 96, 96, 65002, 0, OP_OPAQUE);
		Screen->FastTile(6, 144, 96, 65000, 0, OP_OPAQUE);
		Screen->FastTile(6, 192, 96, 65001, 8, OP_OPAQUE);
		
		int Numbero = 48;
		Screen->FastCombo(6, Numbero, 112, 30764, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 112, 30766, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero, 128, 30772, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 128, 30774, 0, OP_OPAQUE);
		Numbero = 80;
		Screen->FastCombo(6, Numbero, 112, 30764, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 112, 30766, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero, 128, 30772, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 128, 30774, 0, OP_OPAQUE);
		Numbero = 112;
		Screen->FastCombo(6, Numbero, 112, 30764, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 112, 30766, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero, 128, 30772, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 128, 30774, 0, OP_OPAQUE);
		Numbero = 144;
		Screen->FastCombo(6, Numbero, 112, 30764, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 112, 30766, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero, 128, 30772, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 128, 30774, 0, OP_OPAQUE);
		Numbero = 176;
		Screen->FastCombo(6, Numbero, 112, 30764, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 112, 30766, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero, 128, 30772, 0, OP_OPAQUE);
		Screen->FastCombo(6, Numbero + 16, 128, 30774, 0, OP_OPAQUE);
		
		Screen->FastCombo(6, 56, 120, 32929, 6, OP_OPAQUE);
		if (Link->Item[157] == true)
		{
			Screen->FastCombo(6, 88, 120, 32933, 0, OP_OPAQUE);
		}
		if (Link->Item[158] == true)
		{
			Screen->FastCombo(6, 120, 120, 32937, 0, OP_OPAQUE);
		}
		if (Link->Item[159] == true)
		{
			Screen->FastCombo(6, 152, 120, 32941, 0, OP_OPAQUE);
		}
		if (Link->Item[160] == true)
		{
			Screen->FastCombo(6, 184, 120, 32945, 0, OP_OPAQUE);
		}
	}


#179 Saffith

Saffith

    IPv7 user

  • Members

Posted 06 October 2015 - 09:21 PM

I can't get any of the tango codes to work now. If has to be within the if statement in the Custom Variables section we set up...or maybe the I need to return ffc f? I'm just going to keep it at a max of 5 messages, and want to use this (because I have already set up around 20 of them(x 5 appended messages)):

@inc(@talkcount 1)@if(@greater(@talkcount 1)@append(20))@elseif(@greater(@talkcount 0)@append(19))@elseif(@greater(@talkcount 2)@append(21))@elseif(@greater(@talkcount 50)@append(22))@elseif(@greater(@talkcount 100)@append(23))
I'm kind of lost now...so you might want to baby step me through this.

Couldn't say. Try enabling full error logging. That's the last setting in the main tango.zh file; comment out the line that imports loggingMinimal.zh and uncomment the line that imports loggingFull.zh. That'll log errors and some other information in allegro.log, so maybe it'll tell you what went wrong.

That line needs to be done differently, though. If you only use @greater(), you have to go from the highest to the lowest. You can do it like this:
@inc(@talkcount 1)@if(@greater(@talkcount 100) @append(23))@elseif(@greater(@talkcount 50) @append(22))@elseif(@greater(@talkcount 2) @append(21))@elseif(@greater(@talkcount 1) @append(20))@else(@append(19))

You could also use @equal() and @less() to go from first to last, which would probably be more natural.
@inc(@talkcount 1)@if(@equal(@talkcount 1) @append(19))@elseif(@equal(@talkcount 2) @append(20))@elseif(@less(@talkcount 50) @append(21))@elseif(@less(@talkcount 100) @append(22))@else(@append(23))

I know it's hard to parse a single, long line like that, but ZC doesn't give you much choice. :P



 

Yeah, turns out I didn't set that. Now I have a new problem. When I press up or down on any menu item, orpres right or left on the rightmost or leftmost ones respectively, the cursor goes to the topleft corner. and there only appears to be one menu item there, as when I press any direction key after that, it goes back to the 4 menu items I had before. PS: I set the max menu limit to 12.

Did you increase the size of __Tango_Data[], too? It needs to be big enough for all the menu data. For 12 items, it needs to be bumped up to 60.

#180 xenomicx

xenomicx

    Zelda Arcade

  • Members
  • Location:Chi-town

Posted 06 October 2015 - 10:10 PM

Well this is what I have for my NPC script.

This is what tango.zh looks like:

The string I'm using now is this:

...and allegro.log is this

 

Says its loading it just fine; no errors. So I don't know LOL. This kind of puts me on hold BIG TIME for my quest. I'm currently changing ALL text over to use tango. I want to use it to its full potential but not very good at debugging. I usually just go with the least efficient way of doing things and as of right now, I'll just make up 20 different variables of talkcount derivatives (ie. @abeicount, @goriyacount, @amacount, @merchantcount, @moblincount etc) and have each one keep their own count so they don't interfere with each other.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users