Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Custom tag callbacks

A topic by draque created 5 days ago Views: 47 Replies: 5
Viewing posts 1 to 6
(5 edits)

Hello again! I am working to integrate SuperTextMesh more fundamentally into my game and take advantage of more of its features. I am hoping that it's possible to do the two following things without modifying the source code for STM itself.

1) Receive a callback/notification on the printing of each character which includes which character was printed

2) Receive callbacks for custom tags consumed by SuperTextMesh, which will not be printed to the screen.

The first ties into my speech generation system (custom bleeps and bloops) and the second ties into a system which plays custom animations, updates character expressions, etc. in time with the text. Please let me know if there's a way to do this or if there are any plans to integrate features like this. Conversely, if there is a way for me to simply extend the class in a way that achieves this, I am 100% open to that as well. I'm no stranger to coding and if I can just drop something into place that pre-consumes necessary elements, passing others up to super, I will do that as well.

And again, thank you for making a killer product! :3


EDIT

Ok, I have been exploring ''string ParseText(string myText)'' a bit. Here's something I can think of that would let me do what I need, and it hinges on the code which handles tags, ''switch(ParseText_myTag){'' (line 2640 in the build I am using).

Create an interface for a handler class which is called to each time an unrecognized tag leads to the switch's default statement. If a class which implements this interface is handed to the SuperTextMesh, will will call out to a method ''bool UnrecognizedTag(string ParseText_myTag, string ParseText_myString)''. The return value will be used to set ''clearAfter'' and in the case that there was no handler class provided, it would default ''clearAfter'' to false.

I feel like something very similar could be done by using another method in the same handler class to communicate back each time a character was printed to the textbox.

If you have a repo for STM and you would like me to implement/submit this myself, I would be happy to contribute to a project like yours!

ADDITIONAL EDIT: I'm actually working on implementing this in the SuperTextMesh code now... I will just hand you any code that I create for use in the official project if you would like it!

EDIT X3: Alright... so this still leaves the issue of timing. The tags are parsed immediately, rather than at the point where they would be encountered while printing text... still looking for a way around that.

Developer

Hello!

I'm going to be away for most of the month so I'll try to help while I can!

1) To get the last character printed, you can use the OnPrint event, and then use... hyphenedText[latestNumber] (I need to come up with a quick, better-named way for users to grab this value...) to get the last character printed.

Do you mean the custom event tag? (<e=myEvent>, <e2=myEvent> for repeating) There's a "links" sample scene that shows how to use these in an effective way with custom tags! Event tags are called as text reads out, so that sounds like what you're after.

Ahh, I will explore those, thanks! I will need to see whether there's a good way for me to get passable parameters into the tags in a way that I'm able to use, but I think I can figure something out there. The OnPrint() event coupled with that method for pulling the last character should work as well...

Anyhow, have a good trip and thanks for typing this out before you headed off! It absolutely saved me a ton of trouble!

All your suggestions are great! One suggested addition to the SuperTextMesh class:


public void ClearAllEvents()
{
onCompleteEvent.RemoveAllListeners();
OnCompleteEvent = null;
onUndrawnEvent.RemoveAllListeners();
OnUndrawnEvent = null;
onRebuildEvent.RemoveAllListeners();
OnRebuildEvent = null;
onPrintEvent.RemoveAllListeners();
OnPrintEvent = null;
onCustomEvent.RemoveAllListeners();
OnCustomEvent = null;
onVertexMod.RemoveAllListeners();
OnVertexMod = null;
onPreParse.RemoveAllListeners();
OnPreParse = null;
}

Developer

For passable parameters, I think I do this somewhere in the example but you can do <e=myEvent,variable> and then string.Split(",") 

(1 edit)

Yup, I've made a parameterized system that works very similarly to this!

Last question, but when I <pause> (which I used to do via something custom), calling stm.Continue() only moves things forward by one aditional character. How do I tell it to start reading normally again? I have some text with multiple pauses in it. What I'm doing is making a custom tag that calls continue in X seconds via a coroutine, then hitting the <pause> tag. It pauses, but when Continue() is called, it prints a single character without returning to normal auto reading cadence.


EDIT: Alright! Figured this one out on my own. I had been handing delay float values, which causes it to be ignored, but it accomplishes exactly what I was. looking for. Thank for all the help here!