Question on coding of gamebooks

adrao
Probably a very basic question regarding coding:

I want to display the number of hit points left, so that it goes something like this

msg ("Your last blow knocks your oponent unconcious. Sweating heavily, you congratulate yourself on your win. You took a bit of a beating during the fight, meaning you only have a few Hit Points left, more specifically:")

msg (player.hp)

But this basically means that the number of HP appears on a different line. Is there any way to combine this, or do this in a better way?

Thanks in advance!

Pertex
Did you try this?

msg ("Your last blow knocks your oponent unconcious. Sweating heavily, you congratulate yourself on your win. You took a bit of a beating during the fight, meaning you only have a few Hit Points left, more specifically:" + player.hp)

HegemonKhan
print a message -> [MESSAGE]: text

msg ("Hi, my name is HK.")

outputs: Hi, my name is HK.

---------------

print a message -> [EXPRESSIONS]: text + variables

player.alias = "HK"

msg ("Hi, my name is " + player.alias + ".")

outputs: Hi, my name is HK.

---------------

the secret to writing EXPRESSIONS (text+variables) is to break them into 2 chunks, let's do a more complex 'msg' though:

player.alias = "HK"
player.gender_string = "male"
player.race_string = "human"
player.class_string = "warrior"

msg (player.alias + " is a " + player.gender_string + " " + player.race_string + " " + player.class_string + ".")

which outputs: HK is a male human warrior.

----------

and the 2 chunks:

"text (including a space)"
+ Object_name.Attribute_name (or Variable_name) +

OR

"text (including a space, as a space is a textual character~symbol)"
+
Object_name.Attribute_name (or Variable_name)

---------

the chunks (connected via adding them together, yes you're 'adding, literally~physically putting, strings' together: "4"+"5"="45" or "a"+"b"="ab" or "a"+"b"+"c"="abc", vs 4+5=9, hehe):

player.alias
+
" is a " ~~~~~~~~~~~~~ conceptually: "(space) is (space) a (space)"
+
player.gender_string
+
" " ~~~~~~~~~~~~~~ conceptually: "(space)"
+
player.race_string
+
" " ~~~~~~~~~~~~~~ conceptually: "(space)"
+
player.class_string
+
"." ~~~~~~~~~~~~ conceptually (as it's hard to see it, well for my bad eyes anyways, lol): "(period~dot)"

~OR~

player.alias +
" is a "
+ player.gender_string +
" "
+ player.race_string +
" "
+ player.class_string +
"."

adrao
Thanks guys, much appreciated!!!

jaynabonne
You can also just do:

Your last blow knocks your oponent unconcious. Sweating heavily, you congratulate yourself on your win. You took a bit of a beating during the fight, meaning you only have a few Hit Points left, more specifically: {player.hp}.


in your text field. Or in your msg. (Text processor magic.)

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums