Twine 2.8: Harlowe 3.3: Macros: Example: Health and Mana

Dan Cox
1 Feb 202410:57

Summary

TLDRThis video tutorial demonstrates how to utilize the float box macro in Twine 3.3 to create a 'Health and Mana' user interface that floats outside the standard passage area. The presenter shows how to position elements on a web page, use the display macro to include content from other passages, and manage variables like health and mana. The example illustrates updating the UI after encounters, ensuring players see real-time changes in their stats, highlighting the float box macro's power for creating dynamic, out-of-bounds HUDs in interactive storytelling.

Takeaways

  • 📚 The video is a tutorial on using the 'float box' macro in Twine, specifically within the context of a game called 'Harlo 3.3'.
  • 🎲 The 'float box' macro is used to position elements within a web page, allowing for the creation of user interfaces outside of the standard passage area.
  • 🔑 The script demonstrates setting up 'Health' and 'Mana' as key elements to be tracked throughout the game experience.
  • 📐 The use of 'open and close curly brackets' is highlighted as a method to collapse white space, making the code more compact and readable.
  • 🔄 The 'display macro' is used to include the contents of one passage within another, which helps in managing complex code by breaking it into smaller, more manageable parts.
  • 📊 The 'check health and Mana' passage includes conditional logic to ensure that 'Mana' does not go negative and 'Health' triggers a 'lose' passage if it reaches zero.
  • 🎯 The 'encounter' passage uses the 'random macro' to simulate a dice roll and adjust 'Health' and 'Mana' based on the outcome, enhancing the game's interactivity.
  • 🔗 The 'link macro' and 'goto macro' are used to create navigation within the game, allowing players to move between passages seamlessly.
  • 🖥️ The 'float box' macro is strategically positioned in the top right corner of the page to avoid covering important UI elements, showcasing the importance of placement.
  • 🛡️ The video emphasizes the importance of updating the 'user interface' passage last, after all calculations have been made, to ensure players see the most current information.
  • 🌐 The tutorial concludes by emphasizing the versatility and power of the 'float box' macro for creating custom user interfaces and displaying dynamic information in various settings.

Q & A

  • What is the main purpose of the 'health and Mana' example in the video?

    -The 'health and Mana' example demonstrates how to use the float box macro within Twine's Harlo 3.3 to create a user interface for tracking health and mana statistics in a web-based interactive story.

  • How does the float box macro help in positioning elements within a web page?

    -The float box macro allows elements to be positioned in specific areas of a web page, outside the normal passage area, enabling the creation of user interfaces or HUDs that can be updated across different passages.

  • What is the significance of using open and close curly brackets in the script?

    -Open and close curly brackets are used to collapse white space in the script, which helps in keeping the code compact and organized, taking up a single line within a passage.

  • Can you explain the use of the display macro in the 'Adventure' passage?

    -The display macro is used to include the contents of another passage within the current passage. This helps in breaking down complicated code into smaller, more manageable parts that can be displayed or included as needed.

  • What is the purpose of the 'check health and Mana' passage?

    -The 'check health and Mana' passage contains code to ensure that Mana does not go below zero and that if Health reaches zero, the player is taken to the 'lose' passage, indicating the end of the game.

  • How does the 'encounter' passage simulate a random event?

    -The 'encounter' passage uses the random macro to generate a number between 1 and 20, simulating the roll of a 20-sided dice. Based on the outcome, it adjusts the Health and Mana values and displays a corresponding message.

  • What is the role of the 'user interface' passage in the script?

    -The 'user interface' passage is where the health and Mana values are displayed to the player. It is updated after each encounter to reflect the current status of the player's health and mana.

  • Why is it important to update the 'user interface' passage after all calculations?

    -Updating the 'user interface' after all calculations ensures that the player sees the most current information. If the update were to occur before the calculations, the player might see outdated information.

  • What is the purpose of using the link macro and goto macro together in the 'Adventure' passage?

    -The link macro and goto macro are used together to create a link that returns the player to the 'Adventure' passage after an action is completed, allowing for a seamless continuation of the game.

  • Can the float box macro be used to create a subsection of a passage in any part of the page?

    -Yes, the float box macro can be used to create a subsection of a passage in any part of the page. However, care must be taken to avoid overlapping with other elements or hiding important parts of the passage.

  • How does the video script utilize the float box macro for creating a heads-up display (HUD)?

    -The script uses the float box macro to create a HUD by defining a subsection of a passage and positioning it in a specific area of the web page, allowing the display of important information like health and Mana that updates as the player progresses.

Outlines

00:00

📐 Utilizing Float Box Macro in Twine

This paragraph introduces a video tutorial focused on the 'health and Mana' example using the float box macro within Twine 3.3. The tutorial demonstrates how to position elements within a web page for a more interactive experience. It explains the use of macros to track statistics like health and Mana, and how to collapse white space for cleaner code. The video will guide viewers through setting up the macros and show the example in action.

05:02

🔄 Implementing Health and Mana Tracking

The second paragraph delves into the specifics of setting up health and Mana tracking in Twine. It discusses the use of the 'display' macro to include content from other passages, the 'float box' macro for positioning elements outside the normal passage area, and the 'link' and 'goto' macros for navigation. The paragraph also covers the conditional logic for health and Mana adjustments based on encounters with enemies, emphasizing the importance of updating the user interface after all calculations are made.

10:02

🎮 Enhancing User Experience with Float Box Macro

The final paragraph wraps up the video script by emphasizing the power of the float box macro for creating user interfaces and heads-up displays in Twine. It illustrates how the macro can be used to display updated information across multiple passages, enhancing the user experience in various settings like fantasy or sci-fi games. The paragraph concludes by highlighting the versatility of the float box macro in conjunction with other macros for creating dynamic and engaging content.

Mindmap

Keywords

💡Twine

Twine is an open-source tool for telling interactive, nonlinear stories. It allows authors to create text-based games and stories with a simple, web-based interface. In the video, Twine is the platform on which the 'health and Mana' example is built, showcasing how to create interactive experiences within a web page.

💡Float Box Macro

The Float Box Macro is a feature within Twine that enables the positioning of elements within a web page. It is used in the video to place UI elements, such as health and Mana indicators, in specific locations outside the normal passage area, enhancing the user experience by providing a heads-up display.

💡Health and Mana

Health and Mana are common game mechanics representing a character's vitality and magical power, respectively. In the video, they are tracked as key statistics for the player, demonstrating how to visually represent and update these stats within the story using Twine macros.

💡Macro

In the context of Twine, a macro is a reusable piece of code that performs a specific function within a story. The video discusses various macros, such as 'display', 'if', and 'random', to manipulate the story flow and update the game's statistics.

💡Display Macro

The Display Macro in Twine is used to include the content of one passage within another. In the video, it is used to modularize complex code, making the story more organized and easier to manage by breaking it into smaller, thematic sections.

💡User Interface (UI)

The User Interface, or UI, refers to the visual elements that allow users to interact with a system. In the video, the UI is implemented using the Float Box Macro to create a space for displaying health and Mana stats, providing players with real-time information.

💡White Space Collapsing

White Space Collapsing is a technique used in Twine to minimize the visual clutter of code by reducing extra spaces and lines. The video demonstrates how to use open and close curly brackets to collapse white space, making the code cleaner and more readable.

💡Goto Macro

The Goto Macro in Twine is used to direct the story to a different passage. In the video, it is used in conjunction with the Link Macro to create navigation within the story, allowing players to return to the 'Adventure' passage after updates.

💡Random Macro

The Random Macro is used to generate random numbers, simulating events like dice rolls in games. In the video, it is employed to determine encounters, where a random number dictates whether the player loses health and Mana.

💡Conditional Statements

Conditional statements, such as 'if', are used to make decisions in code. In the video, they are used to check the player's health and Mana levels, triggering different outcomes like losing the game or encountering enemies.

💡Link Macro

The Link Macro in Twine creates clickable links within passages. In the video, it is used to connect different parts of the story, such as returning to the 'Adventure' passage after an encounter or updating stats.

Highlights

Introduction to an extended example of 'Health and Mana' using the float box macro within Harlo 3.3.

Explanation of how the float box macro can be used to position elements within a web page.

Demonstration of using open and close curly brackets to collapse white space in macros.

Use of the display macro to include content from other passages within the current passage.

Positioning of float box elements in the top right corner of the web page for the user interface.

The importance of updating health and mana values after all calculations are completed.

Utilization of the random macro to simulate a 20-sided dice roll for encounters.

Conditional logic to adjust health and mana based on the outcome of the dice roll.

Incorporation of the link and goto macros to navigate back to the Adventure passage.

The setup of the 'check health and Mana' passage to prevent negative values and trigger the 'lose' passage.

Use of the float box macro to create a user interface or heads-up display for players.

Discussion on the strategic placement of the float box to avoid covering important passage elements.

The float box macro's power for creating user interfaces and displaying extra information in various settings.

Combining the float box with other macros like set, if, and display for complex interactions.

The potential for using the float box macro in fantasy or sci-fi settings for dynamic user experiences.

Final summary of the float box macro's utility in enhancing the storytelling and gameplay experience.

Transcripts

play00:02

welcome to a JV on twine in this video

play00:04

I'm going to show an extended example of

play00:06

called health and Mana that works with

play00:09

the float boox macro within harlo

play00:12

3.3 So based on our knowledge of the

play00:14

float boox macro we can position things

play00:17

within the page within a web page so

play00:20

instead of being things within the

play00:22

browser or that is within the passage we

play00:24

can position things within the web

play00:26

browser within the page this allows us

play00:28

to put things outside of the normal

play00:30

passage area however I'm setting up a

play00:33

bunch of different things a bunch of

play00:34

different macro usages within this to

play00:36

show where this can be particularly

play00:38

useful if we want to show statistics

play00:40

things like health and Mana it's the

play00:41

name of this example to show what they

play00:43

look like to players or users as they

play00:46

play through an experience so let's go

play00:48

ahead and I'm going to move through all

play00:50

these passages and then I'll play it for

play00:52

you so the first thing I'm doing here is

play00:55

setting up health and Mana that will be

play00:57

the two main things we will track um

play00:59

notice I'm using open and close open and

play01:02

closing curly brackets um this is

play01:04

collapsing whites space as a review if

play01:07

we have multiple macros each usage will

play01:09

take up a single line within a passage

play01:12

where we can collapse all of that extra

play01:14

space which we call White Space by using

play01:17

open and closing curly brackets around

play01:19

them and it will collapse everything

play01:21

that's within that instead of it taking

play01:22

up extra space you may see depending on

play01:25

what resolution you're using some little

play01:27

tiny dots uh between the line here to

play01:30

where this macro starts um that is a tab

play01:32

I have tabbed in all of these just so

play01:34

they're a little easier to read keep in

play01:37

mind when it collapses white space any

play01:39

extra spaces so pressing space bar or

play01:41

tabbing all this will be collapsed

play01:43

totally up to you how you want to

play01:44

position your own code I find this

play01:45

slightly easier for me to read so we're

play01:48

setting up health and mana and then

play01:50

we're going to Adventure so let's jump

play01:52

over here to Adventure which is doing

play01:54

multiple different things so it's first

play01:57

using the display macro to include the

play02:00

contents of one passage and another so

play02:02

as a review of the display macro

play02:04

sometimes we find ourselves in

play02:05

situations where we have lots of

play02:07

complicated code within harlo or

play02:10

potentially other story formats we're

play02:12

using in harlo we use display macro to

play02:15

display the content of another passage

play02:17

in the current passage how this applies

play02:20

to code is that sometimes we got lots of

play02:22

complicated code but we can break it

play02:23

into small parts and then display it or

play02:26

include it as

play02:27

needed so in this case I have a p is

play02:30

called check health and Mana that's

play02:32

acting as its own sort of set of code

play02:33

which we'll go look at here in just a

play02:35

moment and then I'm moving down here

play02:36

display encounter which is doing its own

play02:38

set of code and then I'm using the float

play02:41

box macro right here and then notice

play02:43

again when we use float box we use x

play02:46

marks the spot for horizontal y marks

play02:49

the spot for vertical so in this case I

play02:52

want it all the way over here on the for

play02:55

right and then I want it up here in the

play02:58

top part of it so keep in mind y or X

play03:02

and Y that is start from the top left so

play03:04

this is moved all the way over to the

play03:06

right and this is all the way at the top

play03:09

so the top right is what we'll see it

play03:11

and then inside here I'm doing an

play03:13

additional use of the display macro to

play03:15

include the contents of another passage

play03:18

Inside the Box defined by the float back

play03:21

the float box that is hook so I'm

play03:24

including something from another passage

play03:27

as right here the part of the user

play03:29

interface

play03:30

and then I'm using the link macro to

play03:32

create a link that's then using the goto

play03:34

macro to go back to Adventure which is

play03:36

me just being a little bit of extra here

play03:37

I could have also just used a link uh to

play03:39

connect this back to itself so let's go

play03:42

look at check health and Mana so keep in

play03:44

mind I'm using displ macro to break up

play03:46

complicated code into sets of code that

play03:49

are a little more

play03:50

thematically um appropriate for each

play03:53

section so reusing right here collapsing

play03:56

whites space this just says hey if Mana

play03:59

ever drops below zero set it back to

play04:01

zero just so we don't have negative and

play04:03

if Health ever drops to zero go to lose

play04:06

immediately L is over here you faint and

play04:09

are then transported back to the local

play04:11

end which is basically the one ending of

play04:13

this experience so let's go over here to

play04:15

user interface we see health and Mana

play04:18

okay let's come down here to encounter

play04:20

encounter is doing a few different

play04:22

things again using that collapsing white

play04:24

space right here so we don't care about

play04:25

any of the stuff that's within it it's

play04:26

going to be collapsed back down which

play04:28

allows us to space things out make a

play04:30

little easier to read if we want to do

play04:32

it that way again I have tabbed these in

play04:34

but you could also use spaces or

play04:36

whatever you want again it will be

play04:37

collapsed so space doesn't really matter

play04:39

as much and I'm using the random macro

play04:43

to get a number between 1 and 20 as if

play04:46

you were going to roll a 20-sided Dice

play04:48

and then I'm checking to say hey if the

play04:50

temporary variable notice the use of the

play04:52

underscore for temporary if the

play04:54

temporary variable rle is less than or

play04:56

equal to 10 so about a 50% chance right

play04:59

here or a 50% chance then go ahead and

play05:02

adjust Health by 20 so set Health to

play05:05

health whatever the current value is

play05:06

subtract 20 from it do the same right

play05:08

here the Mana and then put the tax you

play05:11

encounter an enemy and lose health and

play05:13

Mana so keep in mind the little bit of

play05:15

tricky thing when we use content or we

play05:17

use text within the collapsing white

play05:20

space so the open and closing curly

play05:22

brackets that we generally need to align

play05:24

it all the way over here because it will

play05:26

then be collapsed back together so so we

play05:29

want this to kind of be on a lines by

play05:32

itself and when this is collapsed it

play05:34

will then be together and then

play05:36

alternatively the El smack right down

play05:38

here says you see nothing of note so if

play05:40

it's 10 or less than 10 right here we

play05:43

will these things will trigger if it

play05:45

isn't we will see nothing of note so

play05:48

let's come back to

play05:49

Adventure so what is happening every

play05:52

time we come to this passes is it's

play05:54

checking to say hey if health is less

play05:57

than or equal to zero that which is to

play06:00

say we've dropped below whatever Health

play06:01

threshold we set we will immediately go

play06:04

to the lose passage if that's not the

play06:06

case we will keep on and move to the

play06:08

next thing the next thing in sequence is

play06:10

the encounter and this will roll or do

play06:12

the equivalent of rolling a 20-sided die

play06:15

we say pick a number between one and 20

play06:17

and if it's Le if it's 10 or less than

play06:19

10 then go ahead and subtract 20 from

play06:22

health and 20 from MAA and then show us

play06:25

a message if it's not then we will see

play06:27

nothing of note then we're updating

play06:30

right here from the user interface

play06:32

passage right over here health and Mana

play06:35

now the reason why this is last is

play06:37

because we want to do all of the math

play06:39

and then update whatever information

play06:41

we're showing to the player or user so

play06:43

keep that in mind do all your

play06:45

calculations and then update those

play06:47

values to then show people because

play06:49

otherwise if we flip this and float box

play06:51

was first we would show them information

play06:54

and then change that information they

play06:55

wouldn't see those changes so do all the

play06:57

changes then update finally we provide a

play07:00

link that just sends us right back here

play07:02

we could have also done a link but I'm

play07:04

literally using the link macro and the

play07:06

goto macro one more time so let's see

play07:09

this in

play07:11

action so we start the adventure with

play07:14

perfect health and a pull of Mana

play07:16

Adventure notice we have a user

play07:18

interface over here again the use of the

play07:20

float box macro so the Box macro within

play07:24

Haro allows us to define a subsection

play07:27

float box extends that we're def find a

play07:29

subsection somewhere on the page

play07:32

extending out of the part that we

play07:33

normally have a displaying of passages

play07:36

so we have this way over here now a

play07:38

little bit of note here about why I

play07:41

chose this part of the screen so I chose

play07:43

this way over here because if you put it

play07:45

over here keep in mind a box defines a

play07:48

section A subsection of a passage if we

play07:51

do a float box in the upper leftand

play07:53

corner and we're not careful we can

play07:55

literally hide this undo thing it will

play07:57

take up all of this and depending on how

play07:59

how big you make it may also take up

play08:01

sections of this passage right here so I

play08:02

stuck it far over here in the corner by

play08:04

itself so that is a little bit of caveat

play08:06

we need to be careful of we've got lots

play08:08

of things going on when we're working

play08:10

with the flirp Box macro but otherwise

play08:13

we have health and mana and we see

play08:14

nothing of no so again 50% chance each

play08:17

time so let's Adventure nothing of not

play08:20

ah we lost some health lost some am

play08:22

let's Adventure again uh we lost down to

play08:25

60 okay nothing happened 40 40 40 20

play08:33

zero H and I fainted

play08:36

finally so lots of different things

play08:39

going on in this example but the real

play08:42

core of it is evolving around the float

play08:44

box macro again float box allow us to

play08:47

float a box a subsection of a passage to

play08:50

different parts of the page outside of

play08:52

the normal part that we would Define for

play08:54

a passage if we're using it sister the

play08:57

Box we defining things horizontally for

play08:59

using float box we are floating a

play09:01

subsection floating a box to other parts

play09:04

of the page in situations like this that

play09:07

is incredibly useful we can kind of

play09:09

stick a user interface or what might be

play09:11

called a heads up display or a hood of

play09:14

information that a player or user might

play09:16

want to see across multiple passages we

play09:19

can kind of Define it in one place and

play09:21

use things like a float box combined

play09:24

with the display macro to display

play09:26

information in a particular section of

play09:28

the screen

play09:30

and then as they're moving to passages

play09:32

keep having that updated information

play09:34

again as I did down here in adventure do

play09:36

all the calculations then update the

play09:39

display in fact if I wanted to I could

play09:41

have moved all of these things into a

play09:44

second passage and then dis displayed

play09:47

that included that content in this

play09:48

passage so lots of different things

play09:51

going on all previous macros I have

play09:54

covered in other videos using the set

play09:56

macro to change the value of variables

play09:59

the if macro to check various conditions

play10:02

less than greater than things like that

play10:04

and then using the display macro to

play10:06

include the contents of one passage and

play10:08

another and combining it now all

play10:10

together with the float box macro to

play10:13

float a section or or a subsection of a

play10:16

page I should say within a different a

play10:19

subsection of a passage and a different

play10:20

part of a page I should I should say and

play10:23

arranging that the way we want it so

play10:25

float box can be incredibly powerful for

play10:27

things like user interfaces

play10:29

heads up displays sometimes called Huds

play10:31

and various other encounters we want to

play10:33

display that extra information just

play10:36

outside of the normal passage area that

play10:38

will be updated for things like

play10:39

adventures and a potential fantasy

play10:41

setting or sci-fi setting or other

play10:43

things really really useful for those

play10:45

use cases thanks for watching this video

play10:48

on harlo

play10:56

3.3

Rate This

5.0 / 5 (0 votes)

الوسوم ذات الصلة
Twine MacrosInteractive StorytellingHealth TrackingMana SystemFloat BoxHarlo 3.3Web Page DesignUser InterfaceMacro TutorialCoding TechniquesGame Development
هل تحتاج إلى تلخيص باللغة الإنجليزية؟