Jump to content

Photo

tango.zh


  • Please log in to reply
398 replies to this topic

#256 Shoelace

Shoelace

    The Shaman of Sexy!

  • Members
  • Real Name:Michael
  • Pronouns:He / Him
  • Location:Arizona

Posted 01 February 2016 - 11:06 PM

I don't know how I missed something so small. I was treating it like it was just a normal boolean... lol  Thanks Saffith, that worked!

 

Thanks C-Dawg, that actually would save a lot of time and headache.  Thanks for the heads up. :D  I definitely am going to be calling it throughout the game. :P



#257 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 05 February 2016 - 11:18 AM

That should be appended after loading the string and before activating the slot, which can't be done with the regular ShowMessage() function. You could make an alternate version:

int ShowMovingMessage(int message, int type, int style, float x) // No need for a Y argument
{
    int slot=Tango_GetFreeSlot(type);
    if(slot==TANGO_INVALID)
        return TANGO_INVALID;
    
    int movement[]="@while(@greater(@y 130) @inc(@y -3))@delay(240)@while(@less(@y 168) @inc(@y 3))";
    Tango_ClearSlot(slot);
    Tango_LoadMessage(slot, message);
    Tango_AppendString(slot, movement);
    Tango_SetSlotStyle(slot, style);
    Tango_SetSlotPosition(slot, x, 168);
    Tango_ActivateSlot(slot);
    
    return slot;
}
You could also handle the movement in ZScript with Tango_SetSlotPosition().

 

 

Does the Tango instruction set in Tango_AppendString(slot, movement) here, not need to be issued before the string contents of Tango_LoadMessage(slot, message) ?
 

I would think that the wait, and speed instructions would need to be first; and the other strings appended to them. Am I mistaken?
 



#258 Saffith

Saffith

    IPv7 user

  • Members

Posted 05 February 2016 - 06:08 PM

Oops, yeah, didn't think about that. The one in the demo is used with a style that displays text instantly, so the timing isn't an issue.
Ideally, it should move on to the screen at the start of the text and off again at the end, so:
int ShowMovingMessage(int message, int type, int style, float x)
{
    int slot=Tango_GetFreeSlot(type);
    if(slot==TANGO_INVALID)
        return TANGO_INVALID;
    
    int movement1[]="@while(@greater(@y 130) @inc(@y -3))";
    int movement2[]="@delay(240)@while(@less(@y 168) @inc(@y 3))";
    Tango_ClearSlot(slot);
    Tango_LoadString(slot, movement1);
    Tango_AppendMessage(slot, message);
    Tango_AppendString(slot, movement2);
    Tango_SetSlotStyle(slot, style);
    Tango_SetSlotPosition(slot, x, 168);
    Tango_ActivateSlot(slot);
    
    return slot;
}
Also, I don't know if you actually want that @delay() in there, but that's easy enough to remove.

#259 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 06 February 2016 - 03:08 AM

Oops, yeah, didn't think about that. The one in the demo is used with a style that displays text instantly, so the timing isn't an issue.
Ideally, it should move on to the screen at the start of the text and off again at the end, so:

int ShowMovingMessage(int message, int type, int style, float x)
{
    int slot=Tango_GetFreeSlot(type);
    if(slot==TANGO_INVALID)
        return TANGO_INVALID;
    
    int movement1[]="@while(@greater(@y 130) @inc(@y -3))";
    int movement2[]="@delay(240)@while(@less(@y 168) @inc(@y 3))";
    Tango_ClearSlot(slot);
    Tango_LoadString(slot, movement1);
    Tango_AppendMessage(slot, message);
    Tango_AppendString(slot, movement2);
    Tango_SetSlotStyle(slot, style);
    Tango_SetSlotPosition(slot, x, 168);
    Tango_ActivateSlot(slot);
    
    return slot;
}
Also, I don't know if you actually want that @delay() in there, but that's easy enough to remove.

 

 

How about this, as an option:

int ShowMovingMessage(int message, int type, int style, float x, int delayvalue)
{
    Tango_D[0] = delayvalue;
    int slot=Tango_GetFreeSlot(type);
    if(slot==TANGO_INVALID)
        return TANGO_INVALID;
    
    int movement1[]="@while(@greater(@y 130) @inc(@y -3))";
    int movement2[]="@delay(@d0)@while(@less(@y 168) @inc(@y 3))";
    Tango_ClearSlot(slot);
    Tango_LoadString(slot, movement1);
    Tango_AppendMessage(slot, message);
    Tango_AppendString(slot, movement2);
    Tango_SetSlotStyle(slot, style);
    Tango_SetSlotPosition(slot, x, 168);
    Tango_ActivateSlot(slot);
    
    return slot;
}

I think it would be nice to expand the TangoD[] array to MAX_INT. by default... Nothijg should ever need to iterate through it as a loop; but even so, making it a size of 256 or greater by default would be useful, unless you already did that,

 

Use the first 8 indices for D* args from ffcs and such, but the rest could be reserved to store other values.

 

Otherwise values must be shifted into a global array first, and if they are values intended to be used only atthe scope of the function, you'd need to store their old value, change it while the functuion runs, then revert it afterward to whatever it was before the function ran, like this:

int ShowMovingMessage(int message, int type, int style, float x, int delayvalue)
{
    int oldD0 = Tango_D[0];
    Tango_D[0] = delayvalue;
    int slot=Tango_GetFreeSlot(type);
    if(slot==TANGO_INVALID)
        return TANGO_INVALID;
    
    int movement1[]="@while(@greater(@y 130) @inc(@y -3))";
    int movement2[]="@delay(@d0)@while(@less(@y 168) @inc(@y 3))";
    Tango_ClearSlot(slot);
    Tango_LoadString(slot, movement1);
    Tango_AppendMessage(slot, message);
    Tango_AppendString(slot, movement2);
    Tango_SetSlotStyle(slot, style);
    Tango_SetSlotPosition(slot, x, 168);
    Tango_ActivateSlot(slot);
    
    Tango_D[0] =int oldD0;
    return slot;
}

...to preserve the old values, in the event that something else still needs the previous value. This wastes a reg, and a pop.

 

Also, maybe a direct way to access an array local to a function, or read values passed by function args?

 

Something like @locarr(*ptr,index)

Not sure how well that would work, as it'd need to convert a pointer by name?

 

Another thing I'd suggest, is to put all the code for accessing the main array for Tango, and the main array for Ghost, into their own files, so that if users want to merge these and modify the operations, all the accessors are in one place per header.

 

---

 

That aside, I think I'll put together a ticker-tape-style moving text function at some point, for you to include.

 

Too bad that we can't use bitmaps as textures for DrawQuad/DrawQuad3D. If we could, a 'Star Wars' style text crawl would be possible with very little extra work.


Edited by ZoriaRPG, 06 February 2016 - 03:21 AM.


#260 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 07 February 2016 - 07:14 AM

I sent this to Saffith as a PM,a nmd realised at the end that whatever answer he provides might be useful to everyone else, so I'm copying it here.

 

---

 

So, I've modified some things for Shoelace, and tried to debug some issues that he had. I solved all the big things, however, he wanted a way to load multiple messages into one function.

This is one of the modified ShowMovingMessage() functions that I put together, (although the result is what I feared):
 

int ShowMovingMessage(int message, int type, int style, float x, int additional_messages, int init_delay, int second_delay)
{
    Tango_D[0] = init_delay;
    Tango_D[1] = second_delay;
    int slot=Tango_GetFreeSlot(type);
    if(slot==TANGO_INVALID)
        return TANGO_INVALID;
    
    int movement1[]="@delay(@d0)@while(@greater(@y 130) @inc(@y -3))";
    int movement2[]="@delay(@d1)@while(@less(@y 168) @inc(@y 3))";
    Tango_ClearSlot(slot);
    Tango_LoadString(slot, movement1);
    for ( int q = message; q <= message+additional_messages; q++ ) {
            Tango_AppendMessage(slot, q);
    }
    Tango_AppendString(slot, movement2);
    Tango_SetSlotStyle(slot, style);
    Tango_SetSlotPosition(slot, x, 168);
    Tango_ActivateSlot(slot);
    
    return slot;
}

The problem of course, is that the text starts overflowing the buffer, possibly even the tango bitmap. What he says that he sees, is that the next string tarts overwriting the old one, before it completes displaying itself.

What I don't know, is if there is already a pre-built Tango instruction that I could put in the for loop, or maybe even in the string that it's fetching, to force the next string to wait until the first is finished. Maybe some kind of custom control character, that must appear, before the next string loads?

Other than that, it's working, but I'm not sure how to force a delay in that kind of for loop, when fetching multiple strings.

I figured that if the buffer was big enough, that the appended messages would just populate it; but I also feared that they'd overflow because the default buffer is...what..a size of 256?

As fas as I understand, AppendMessage just loads the message into the buffer, via GetMessage(), so would changing the Tango string buffer to a size of 214747 fix this; and would that cause any other problems?

 

Perhaps adding a delay instruction, or some kind of wait instruction as a hardcoded string, between the appended messages might also work. ?


Edited by ZoriaRPG, 07 February 2016 - 07:16 AM.


#261 C-Dawg

C-Dawg

    Magus

  • Members

Posted 07 February 2016 - 09:09 AM

I'm not sure I understand the desired effect, but if you want to pass a function multiple strings and display them in sequence, why not just have a loop that keeps track of the string being displayed and then loads the next one only after AnySlotIsActive () returns false?

#262 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 07 February 2016 - 09:28 AM

I'm not sure I understand the desired effect, but if you want to pass a function multiple strings and display them in sequence, why not just have a loop that keeps track of the string being displayed and then loads the next one only after AnySlotIsActive () returns false?

 

As I understand, they are meant to be one continuous stream.

 

Shoelace is displaying them in a tiny, scrolling box, on a regular basis. I would use a ticker-tape effect for that sort of thing, but he has the text scrolling on the Y-axis, instead of the X-axis. He's using ZQ strings, from the string editor, that he made in sequence. ordinarily, these would use the 'next string' and 'continued from previous string' settings, but those values are not something that ZScript can read; so I set it up to push all the strings in at once, and display them as one long sequence.

 

I'm pretty sure that all I need to do to fix it, is to edit the tang buffer, which has a size of 256 by default. If that works, fantastic. otherwise, I may need to edit the bitmap size, or, make a secondary buffer that pre-loads, and pushes when the previous string is just about to end.

 

Also, the way he has set this up, AnySlotsActive() won't return false, as that would close the display, and mean I'd need to regenerate it perpetually. I suppose I'll see if augmenting the default buffer fixes it, as it should.


Edited by ZoriaRPG, 07 February 2016 - 09:48 AM.


#263 C-Dawg

C-Dawg

    Magus

  • Members

Posted 07 February 2016 - 12:30 PM

How about making a style with no background and then drawing the tiles for the background outside of tango? That way, you can call stings sequentially and the user won't see the window close.

#264 Saffith

Saffith

    IPv7 user

  • Members

Posted 07 February 2016 - 12:33 PM

The problem of course, is that the text starts overflowing the buffer, possibly even the tango bitmap. What he says that he sees, is that the next string tarts overwriting the old one, before it completes displaying itself.

I don't quite understand what you mean. Could you show me a screenshot or something?
Buffer overflow shouldn't cause the text to be overwritten; it should just refuse to load any more. Exceeding the bitmap limits should result in it not drawing any more.
It looks like there are multiple slots sharing buffer and bitmap space. Any chance that's part of the problem?
 

What I don't know, is if there is already a pre-built Tango instruction that I could put in the for loop, or maybe even in the string that it's fetching, to force the next string to wait until the first is finished. Maybe some kind of custom control character, that must appear, before the next string loads?

I'm still a bit unclear on what you're trying to do. Are you looking for something like @goto()? @sync()?
 

I figured that if the buffer was big enough, that the appended messages would just populate it; but I also feared that they'd overflow because the default buffer is...what..a size of 256?

Assuming it's using the TANGO_SLOT_NORMAL definition he posted before, it's 1024. The maximum length of a single ZC message is 144.
It should detect buffer overflow and stop loading. It doesn't detect bitmap overflow. In any case, you should check if there are any errors logged.
 

As fas as I understand, AppendMessage just loads the message into the buffer, via GetMessage(), so would changing the Tango string buffer to a size of 214747 fix this; and would that cause any other problems?

There's no problem with increasing the size of the buffer, if that is indeed the problem. Just remember that you'll have to change the slot definition, too.

#265 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 07 February 2016 - 01:38 PM

I don't quite understand what you mean. Could you show me a screenshot or something?
Buffer overflow shouldn't cause the text to be overwritten; it should just refuse to load any more. Exceeding the bitmap limits should result in it not drawing any more.
It looks like there are multiple slots sharing buffer and bitmap space. Any chance that's part of the problem?
 
I'm still a bit unclear on what you're trying to do. Are you looking for something like @goto()? @sync()?
 
Assuming it's using the TANGO_SLOT_NORMAL definition he posted before, it's 1024. The maximum length of a single ZC message is 144.
It should detect buffer overflow and stop loading. It doesn't detect bitmap overflow. In any case, you should check if there are any errors logged.
 
There's no problem with increasing the size of the buffer, if that is indeed the problem. Just remember that you'll have to change the slot definition, too.

 

I don't have the quest file, or any screenshots. I'm going by descriptions alone.

 

Perhaps Shoelace can post a few images, or a video to the thread.

 

I don't see a reason that AppendMessage() in a for loop would fail, otherwise, unless I need to append the movement instruction each time I add another message. That is also possible.

 

It can't be using more than one slot though, as all the messages are appended via the function I posted above, before activating the slot. I do not know how many chars in total the messages he's using sum.


Edited by ZoriaRPG, 07 February 2016 - 01:40 PM.


#266 Shoelace

Shoelace

    The Shaman of Sexy!

  • Members
  • Real Name:Michael
  • Pronouns:He / Him
  • Location:Arizona

Posted 07 February 2016 - 11:41 PM

Sorry if I wasn't descriptive enough.  So basically this is what I am trying to do:  I am trying to make a Function where I can call it at any time in any script (e.g. Enemies All Killed -> Play script; walk on this tile for the first time -> Play script; walk into screen -> play script)

 

The script is a cloud that pops up from the bottom, displays the string.  And then when the strings are finished, it waits a second and then the cloud goes back to the bottom finishing the script.  All in the while not messing around with Link's Actions.  So Link can just go on his way and read it optionally.  The problem is I definitely need it so that it uses more than one string. It works up until half way through the second string.

 

I made a video of how it works currently.

https://www.youtube....h?v=4ABO_RCWV7k

 

In the video I set up the script as NPC's.  So when I talk to the first guy, it works good.  It is only one string, so it works great.  However, the second one uses more than 1 string.  At around half way in the 2nd string, it ignores the speed and then runs over itself.



#267 C-Dawg

C-Dawg

    Magus

  • Members

Posted 08 February 2016 - 01:12 AM

How many Tango Slots have you enabled in Tango?



#268 Saffith

Saffith

    IPv7 user

  • Members

Posted 08 February 2016 - 01:14 AM

I think the problem there is that there's not enough space on the bitmap allocated to the pop-up slot. See if increasing the height a bit helps.
 

    // 1
    TANGO_SLOT_CLOUDPOPUP,
    0, 1024,
    256, 64,
    128, 192,


#269 Shoelace

Shoelace

    The Shaman of Sexy!

  • Members
  • Real Name:Michael
  • Pronouns:He / Him
  • Location:Arizona

Posted 09 February 2016 - 09:02 AM

    TANGO_SLOT_CLOUDPOPUP,
    0, 1024,
    256, 64,
    128, 64,

^This is what I had as my buffer.  You were correct, changing the 64 to the 192 fixed it.  I don't have too big of an understanding of buffer and those values, but that definitely did fix it. 

 

That definitely fixed it up to 3 lines which I think at max I will have will be 6.  Since it is still having problems with the buffer, I am guessing I just increase the number even more!?! I am going to work right now, so when I get back, I will try something like that.

 

Thank you so much! :D



#270 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 09 February 2016 - 09:49 AM

    TANGO_SLOT_CLOUDPOPUP,
    0, 1024,
    256, 64,
    128, 64,

^This is what I had as my buffer.  You were correct, changing the 64 to the 192 fixed it.  I don't have too big of an understanding of buffer and those values, but that definitely did fix it. 

 

That definitely fixed it up to 3 lines which I think at max I will have will be 6.  Since it is still having problems with the buffer, I am guessing I just increase the number even more!?! I am going to work right now, so when I get back, I will try something like that.

 

Thank you so much! :D

 

 

I received your Tango.zh file, so, if you want, I'll edit it for you. I tried to send you another codeblock to implement, but it's probably not needed at this point. Increasing the actual buffer would be good. The bitmap area, will probably suffice for this style.

 

Rather than increasing that one, you may want to define additional bitmap regions, and styles, to use with other situations, but if you don;t see a need for them, leave them be, as adding more style slots, is a bit involved, as there are a number of values tied to them.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users