Need help with health code

So.. I am trying to make sort off rpg gamebook.
And when I try to substract orc hp at page 1 (game.orchealth=20// game.orchealth= game.orchealth - 5 // or like that) next page it resets to 20...

And ideas?


K.V.
game.orchealth=20// game.orchealth= game.orchealth - 5

I think everything after // will be considered a note.

So that would really be:

game.orchealth=20
//NOTE (does nothing):  game.orchealth= game.orchealth - 5

EDIT (sorry, I started off on my phone)

It looks like you might want:

if (game.orchealth = 20){
  game.orchealth = game.orchealth - 5
}

Sorry you misunderstood me. By that () I meant like to explain it a little what I am trying to do. So..lets say player have 30 hp (player.health = 30) and that orc hit him and on that page it is displayed like: msg Orc hit you for 2 damage.
(And code player.health = player.health - 2)
And then there is option to go on next page.
On that next page players health restores to 30, but why?


K.V.

Hrmm...

Does that next page have a script that involves player.health?

Or is there a turn script that does?


It is like this.
Page 1
msg You find an orc charging at you, you somehow managed to dodge it.
Battle begins!

msg "Your Health: " + player.health
msg "Orcs Health: " + game.orchealth

Options: Attack

Page 2
msg Orc parried your attack and cut you to leg.
You suffered 2 damage.
player.health = player.health - 2

msg "Your Health: " + player.health
msg "Orcs Health: " + game.orchealth

Options: Continue

Page 3
msg {random:You're looking into orcs red eyes.:Orc smiled at you. You can see his yellow teeth}

msg "Your Health: " + player.health
msg "Orcs Health: " + game.orchealth

And on page 3 player have 30 health


K.V.

(KV scratches his chin.)

Hrmm...

If you post the game's code, I bet we can fix you up.


I am now going home so later I will post it.

(Kamiru thinks for a moment.)
Just asking but... cant it be because I chose at begining clear for each page or like that?


K.V.

Clearing the page shouldn't effect the attributes, but it's probably something like that.


Ok I have it buuut....

  1. Msg's are in czech (hope it wont be difficult)
  2. For some notebook problems I am not even able to open it... so I am sending you link https://mega.nz/#!btkg0KDB
    I hope it will be enough.

K.V.

It asks for an encryption key.


You can enter Code View, then copy that text and paste it here.

Just put three of these ` before and after it, like this:

```

code goes here

```


That gives you:

code goes here

Here's an example game, with links that explain what will happen when you click them:

<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="GamebookCore.aslx" />
  <game name="Gamebooking">
    <gameid>189f91eb-4ea0-435b-8f5d-568950b7cf08</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
    <roomenter type="script">
    </roomenter>
    <clearlastpage />
  </game>
  <object name="Page1">
    <inherit name="scripttext" />
    <description>Your health: {player.health}</description>
    <options type="stringdictionary">
      <item>
        <key>Page2</key>
        <value>This link goes to page 2</value>
      </item>
      <item>
        <key>Page3</key>
        <value>And this link goes to page 3</value>
      </item>
    </options>
    <script type="script">
      player.health = 30
    </script>
    <object name="player">
      <inherit name="defaultplayer" />
    </object>
  </object>
  <object name="Page2">
    <inherit name="scripttext" />
    <description><![CDATA[A hobgoblin suddenly appears and kicks you square in the butt!<br/><br/>Your health: {player.health}]]></description>
    <script type="script">
      player.health = player.health - 2
    </script>
    <options type="stringdictionary">
      <item>
        <key>Page3</key>
        <value>Continue</value>
      </item>
    </options>
  </object>
  <object name="Page3">
    <description>Your health is now: {player.health}</description>
    <options type="stringdictionary">
      <item>
        <key>Page2</key>
        <value>If you click here, the hobgoblin will kick you again, and your health will decrease!</value>
      </item>
      <item>
        <key>Page1</key>
        <value>If you click this, you will go back to page one, and your health will reset to 30!</value>
      </item>
    </options>
  </object>
</asl>

I just checked that code and compare it to my code... and.. I found that problem very quickly so thank you very much! ^^


K.V.

You are very welcome!


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

Support

Forums