[Library] Hedgewars Typewriter
Hedgewars Typewriter
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.
Installation
Take the desired release here in form ofTypewriter_v*.hwp
file, which is recommended for loading addon in Hedgewars. Inside the user directory find folder Data
and place downloaded *.hwp
there.
Demo
You might wanna try Typewriter without custom script now, so here isTypewriter_Demo_v*.hwp
. Just place it near by Typewriter_v*.hwp
file and open in game: Singleplayer Missions → Scenarios → Typewriter Demo
.
Usage
Public functions belong to Typewriter namespace. You can place them at demand: between, before, or after other animations added withAddAnim
.
Keep in mind that flow of animation is asynchronous from the code you call in. To perform actions after animation is complete, use eitherAddAnim
orAddFunction
. Though you always can chain animation after animation in order of execution as expected.
AddMissionAnim
Add whole typewriter animation for mission panelHedgewarsScriptLoad("/Scripts/Typewriter.lua") function onGameStart() Typewriter.AddMissionAnim({ caption = "Hello World", subcaption = "<3", text = "This is just working, alright?" }) endOptions set is not limited to sole visuals: address to Typewriter.lua for more verbose information.
Everything's optional (including icon)
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).
Customize or disable sounds
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.
Change behavior on animations' end
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.
Set delays
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 = 2000This particular example guarantees irritatingly slower experience for player.
However, you can find more optimal values based on your mission's setting. These are available even per one command.
Mission panel as cinematic monologue
By default, all mission panels are intended to be important to look at, so you won't miss the last one after skipping animation withSetAnimSkip
. 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 })
Hello, I am author of Typewriter Hedgewars Lua library.
Will be happy to contribute in some HW campaign or mission!
Nice!
Star'd
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
Someone has fun with our Lua API.
That's interesting.
Do you plan to use this library for something?
Hi, I am a Hedgewars developer.
I plan to reuse it for multiplayer action, since it requires a lot of concentration, and animations help to deliver information with precision.
Hello, I am author of Typewriter Hedgewars Lua library.
Will be happy to contribute in some HW campaign or mission!
Introducing Typewriter Demo, testing scenario mission!
Check out latest release: it containsTypewriter_v*.hwp
addon and demo packageTypewriter_Demo_v*.hwp
. Place them together inData
directory and you are ready to go!Hello, I am author of Typewriter Hedgewars Lua library.
Will be happy to contribute in some HW campaign or mission!