Help with integers.

SnowyOxygen
Hello, I am trying to make a script for maxHealth so that the health does not surpass the maxHealth.
I've added two attributes:
-Health, type: integer, value: 100, changes often
-MaxHealth, type: integer, value: 100, only changes on level up or with equipment.
I also added a turn script, I tried this:

if (player.health = > maxHealth) {
set (player, "health", maxHealth)
}

But it returned this error:
Error running script: Error compiling expression 'player.health = > maxHealth': SyntaxError: Unexpected token ">"; expected one of "-", <INTEGER>, <REAL>, <STRING_LITERAL>, "True", "False", <HEX_LITERAL>, <CHAR_LITERAL>, "null", <DATETIME>, <TIMESPAN>, "(", <IDENTIFIER>, "if", or "cast"Line: 1, Column: 26

Could someone please help me fix this or help me with making a script that doesn't let the health surpass the max-health, but at the same time, the maxHealth can change?

jaynabonne
Try:

if (player.health >= maxHealth) {
set (player, "health", maxHealth)
}

It's ">=", not "= >".

Or even:

if (player.health >= maxHealth) {
player.health = maxHealth
}

SnowyOxygen
Actually I fixed it a while ago sorry, I forgot some of the quotations.

HegemonKhan
I know you already figured it out, but here's some code for you (or anyone) to look at, if you're (or anyone is) interested:

<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<turns type="int">0</turns>
<statusattributes type="simplestringdictionary">turns =</statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<curhp type="int">250</curhp>
<maxhp type="int">500</maxhp>
<current_hit_points type="int">999</current_hit_points>
<maximum_hit_points type="int">999</maximum_hit_points>
<maxhp type="int">500</maxhp>
<hp type="string">0/0</hp>
<strength type="int">100</strength>
<endurance type="int">100</endurance>
<agility type="int">100</agility>
<hit_points type="string">0/0</hit_points>
<statusattributes type="simplestringdictionary">hp = ;hit_points =!;strength =;endurance = !;agility = Your agility is !</statusattributes>
</object>
</object>
<turnscript name="turns_turnscript">
<enabled />
<script>
player.hp = player.curhp + "/" + player.maxhp
player.hit_points = "HP: " + player.current_hit_points + "/" + player.maximum_hit_points
game.turns = game.turns + 1
</script>
</turnscript>
</asl>

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

Support

Forums