[Library] Hedgewars Typewriter

4 replies [Last post]
vint
vint's picture
User offline. Last seen 3 weeks 5 days ago. Offline
Joined: 2018-07-28
Posts: 31

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. Flying Saucer Hedgehog

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.

Heart

Installation

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.

Demo

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.

Usage

Public functions belong to Typewriter namespace. You can place them at demand: between, before, or after other animations added with AddAnim.

vint allegedly wrote:
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 or AddFunction. Though you always can chain animation after animation in order of execution as expected.

AddMissionAnim

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. Geek

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 = 2000
This particular example guarantees irritatingly slower experience for player. Hellish Hand Grenade

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 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
})





Hello, I am author of Typewriter Hedgewars Lua library.
Will be happy to contribute in some HW campaign or mission!

Wink Smiley

sheepluva
sheepluva's picture
User offline. Last seen 3 weeks 6 days ago. Offline
Joined: 2009-07-18
Posts: 563

Nice!

Star'd Sunglasses!

  sheepluva <- me  my code stats -> 
a Hedgewars Developer


   <- where I'm from  what I speak -> 

Wuzzy
Wuzzy's picture
User offline. Last seen 29 weeks 2 days ago. Offline
Joined: 2012-06-20
Posts: 1304

Someone has fun with our Lua API. Big Grin

That's interesting.

Do you plan to use this library for something?

Hi, I am a Hedgewars developer. Smile

vint
vint's picture
User offline. Last seen 3 weeks 5 days ago. Offline
Joined: 2018-07-28
Posts: 31

Wuzzy allegedly wrote:

Someone has fun with our Lua API. Big Grin

That's interesting.

Do you plan to use this library for something?

I plan to reuse it for multiplayer action, since it requires a lot of concentration, and animations help to deliver information with precision.
Wink Smiley





Hello, I am author of Typewriter Hedgewars Lua library.
Will be happy to contribute in some HW campaign or mission!

Wink Smiley

vint
vint's picture
User offline. Last seen 3 weeks 5 days ago. Offline
Joined: 2018-07-28
Posts: 31

Introducing Typewriter Demo, testing scenario mission!

Check out latest release: it contains Typewriter_v*.hwp addon and demo package Typewriter_Demo_v*.hwp. Place them together in Data 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!

Wink Smiley

User login

Copyright © 2004-2024 Hedgewars Project. All rights reserved. [ contact ]