Typewriter Hedgewars Lua library, which wraps up text visuals in Hedgewars with typewriter animations.
Typewriter harnesses Animate Hedgewars library. Right now, the only function supported is Typewriter.AddMissionAnim
. It adds ability to draw mission panel with caption, subcaption and text animated in typewriter sequence. See its action in this video:
It's not a secret that animations bring more attention than static panels. You may find it useful for embedding in your campaigns, missions and even multiplayer game styles.
I plan to add more typewriting animations of tags and other GUI with dynamic text, so stay in touch: press "Watch" here, give a star and/or fork repository! We also have discussion at Hedgewars Forums.
Take the desired release here in form of Typewriter_v*.hwp
file, which is recommended for loading addon in Hedgewars. Inside the user directory find folder Data
and place downloaded *.hwp
there.
You might wanna try Typewriter without custom script now, so here is Typewriter_Demo_v*.hwp
. Just place it near by Typewriter_v*.hwp
file and open in game: Singleplayer Missions → Scenarios → Typewriter Demo
.
Public functions belong to Typewriter namespace. You can place them at demand: between, before, or after other animations added with AddAnim
.
Keep in mind that flow of animation is asynchronous from the code you call in. To perform actions after animation is complete, use either
AddAnim
orAddFunction
.
Add whole typewriter animation for mission panel.
HedgewarsScriptLoad("/Scripts/Typewriter.lua")
function onGameStart()
Typewriter.AddMissionAnim({
caption = "Hello World",
subcaption = "<3",
text = "This is just working, alright?"
})
end
Options set is not limited to sole visuals: address to Typewriter.lua for more verbose information.
Of course, table is here to not confuse order of parameters, it can be ordered however you like. Actually, you can omit everything, because they are optional as long as you have proper globals set up. Here's the example:
Typewriter.Mission.caption = "My Super Campaign"
Typewriter.AddMissionAnim({
text = "Your fort is in danger! | Go place some girders.",
icon = 2
})
This way, only detail text appears animated, caption will be shown instantly as common mark between your missions (same applies to subcaption, here it's empty by default).
You also can set icon passed to ShowMission. Check out ammo types for more icons (these constants require prepended minus sign).
Typewriter.AddMissionAnim({
text = "Collect box on the other side of street",
sound_typing = false,
sound_return = sndMineTick
})
Here we completely disabled typing sound, but also changed another sound that plays when whole animation is considered complete.
Typewriter.AddMissionAnim({
subcaption = "same day, 9:00 PM",
text = "Suppose we have a long text here...",
display_time_after = 5000,
force_display_after = true
})
Usually, we forcedly display mission panel only during animations. When all text was typed, default display time is ~3000ms, and player can easily hide panel by pressing M. But if force_display_after
is truthy, mission panel will be forcedly shown during display_time_after
extra time.
You would probably like to set delays globally, so here is an example:
Typewriter.Mission.delay_caption_start = 1000
Typewriter.Mission.delay_caption_char = 200
Typewriter.Mission.delay_subcaption_start = 500
Typewriter.Mission.delay_subcaption_char = 150
Typewriter.Mission.delay_text_start = 400
Typewriter.Mission.delay_text_char = 100
Typewriter.Mission.delay_return = 2000
This particular example guarantees irritatingly slower experience for a player. 😜
However, you can find more optimal values based on your mission's setting. These are available even per one command.
By default, all mission panels are intended to be important to look at, so you won't miss the last one after skipping animation with SetAnimSkip. But what if you wish to use mission panel as element of monologue or for any reason hide said panel if player skips over it? That's when you set:
Typewriter.AddMissionAnim({
text = "Yeah-yeah, don't listen to me.",
modal = false
})