Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wait tag #56

Closed
subsoap opened this issue Jul 29, 2020 · 6 comments
Closed

wait tag #56

subsoap opened this issue Jul 29, 2020 · 6 comments

Comments

@subsoap
Copy link
Contributor

subsoap commented Jul 29, 2020

I added this tag to a custom version of RichText for my needs in a visual novel style project. It would probably be useful for others but I'm not sure if it should be a part of the main project. These are the main changes.

	elseif tag == "wait" then
		settings.wait = tonumber(params)
		if is_empty then
			-- empty tag, ie tag without content
			-- example <br/> and <img=texture:image/>
			local tag_settings = parse_tag(name, params)
			merge_tags(word_settings, tag_settings)
			local add_this_word = ""
			if tag_settings.wait ~= nil and tag_settings.wait > 0 then
				local wait_word = "\226\128\139"
				for i=1, tag_settings.wait do
					add_this_word = add_this_word .. wait_word
				end
			end
			add_word(add_this_word, word_settings, all_words)
		elseif not is_endtag then

Then the tag is used like <wait=30> which inserts 30 zero width characters. This is useful in visual novel projects where you have text appearing once character at a time and you want to add small delays between actions.

@subsoap
Copy link
Contributor Author

subsoap commented Jul 30, 2020

If a wait tag is added similar to this then an action tag should be added too <action=sound:ding/> then these actions can be listened to within timer.delay(), and acted upon when using the truncate feature in games like visual novels. The action:name can be totally arbitrary and up to the project to deal with as it appears.

@britzl
Copy link
Owner

britzl commented Jul 30, 2020

The wait tag is interesting but feels a bit too game specific. Maybe a "repeat" tag that will repeat the enclosed text one or more times?

Or maybe it should be possible to specify a callback function which will be invoked when an unknown tag is encountered while parsing the text. This would allow developers to handle game specific tags while parsing text.

The "action" tag is also quite interesting. The tag could trigger a callback function which would allow developers to react to these actions/events when encountered.

@subsoap
Copy link
Contributor Author

subsoap commented Jul 30, 2020

Callback function methods would be cool as a way to define custom tag behavior / react to action tags. What I am doing in my project is using Broadcast to signal the data that is then used elsewhere. Playing sounds / animations / screen effects as certain text passes by.

<repeat=text:times/> ?

@subsoap
Copy link
Contributor Author

subsoap commented Jul 31, 2020

Another example of how I'm using action tag, when this text is truncated a particlefx is positioned on the char and plays to give an effect to make that text more special.

"<action=particles:text_emitter>Make this pretty</action>"

@britzl
Copy link
Owner

britzl commented Jul 31, 2020

For the repeat tag I was thinking like this:

<repeat=10>&zwsp;</repeat>

@subsoap
Copy link
Contributor Author

subsoap commented Aug 1, 2020

That would work well. Then any tags that overlap would also be applied and repeat on the repeated text?

@britzl britzl closed this as completed in f94a23b Aug 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants