Hit points


#1

I’m starting something new that is a little more conventionally gamey than The Butler Did It, and I would like to have hit points.

If the player runs out of hit points, I want to immediately jump to another sequence. I could do this by manually running a check every time anything happens that will reduce HP, but I’m wondering if there’s something that will be a little more elegant that I would only have to put in at the beginning of a scene.

Thanks!


#2

It’s a subroutine (and now its even easier with parameters).

startup.txt

*scene_list
  startup
  subroutines
  hospital
  chapter_01
*create hp

Whenever you need to reduce the PC’s HP, call the subroutine.

*choice
  #Hit them with your sword.
    *gosub_scene subroutines hit 10
    blah blah blah assumes that the player stays out of the hospital

Then in subroutines.txt we place the subroutine.

(we do it this way to reduce duplicated text.)

*label hit
*params damage
*set hp - damage
*if hp <= 0
  *set hp 0
  *goto_scene hospital
*else
  *return

#3

Thanks!


#4

Thank you @RETowers. I wish I knew coding as you do.