Adding health/hunger/thirst etc.?
LeDirt
20 Jun 2015, 09:29Is there a possibility to add stats to "player", like hunger, health or thirst, which would be displayed to the player?
Which decrease by 1 in each turn?
Which could be increased if you for example "use medkit" or "eat meat".
And once you reach zero in one of them, its game over?
Which decrease by 1 in each turn?
Which could be increased if you for example "use medkit" or "eat meat".
And once you reach zero in one of them, its game over?
adammadam
20 Jun 2015, 10:12yes you click on the player object on the lefthand side, then click on the attributes tab across the top, then you have an option to add attribute, you can name them hunger, health, thirst etc. Set them to integer and give them the value you want.
To make them reach zero you need a command like in this question viewtopic.php?f=10&t=5290
And for a turn counter you can see this part of the tutorial http://docs.textadventures.co.uk/quest/ ... ripts.html
I guess what you have to do is type into that instead of player.turns = player.turns + 1, player.health = player.health-1 and that might reduce it each turn.
To make them reach zero you need a command like in this question viewtopic.php?f=10&t=5290
And for a turn counter you can see this part of the tutorial http://docs.textadventures.co.uk/quest/ ... ripts.html
I guess what you have to do is type into that instead of player.turns = player.turns + 1, player.health = player.health-1 and that might reduce it each turn.
adammadam
20 Jun 2015, 10:14oh and then an object like eating some meat, you'd have a script on the meat which is "set variable or attribute" (this is one of the many options which pop up when you click on add script), and you'd put in
player.health = expression player.health + 30
or whatever number you want it to increase by
player.health = expression player.health + 30
or whatever number you want it to increase by
adammadam
20 Jun 2015, 10:30here is adding attributes to the player



adammadam
20 Jun 2015, 10:30here is healing meat, losing health every turn (I think it will work), and player death again I think/hope it's right.





LeDirt
20 Jun 2015, 15:43Thank you, this did help 

HegemonKhan
20 Jun 2015, 17:10great job adammadam, the only thing I'd add is to not have two (global) Turnscripts, but only one (global) Turnscript. Have your 'death' Script(s) added first, and then your 'losing health' Script(s) added aferwards (and I don't know if he~she wants the 'losing health' to be conditional, 'if (xxx) { player.health=player.health-1 } else if (xxx) { scripts } else { scripts }', or not).
~ OR you can have your 'losing health' Script(s) first, and then your 'death' Script(s) ... I'm not sure which is the better design~practice to do (and it also depends on the rest of your game design too, such as: if you got a party~team and can revive dead party~team members), lol ~
<turnscript name="global_turnscript">
<enabled />
<script><![CDATA[
if (player.health <= 0) {
msg ("You died or were killed.")
msg ("GAME OVER")
finish
} else {
player.health=player.health-1
}
]]></script>
</turnscript>
~OR, an example of a conditional for your losing health ~
<turnscript name="global_turnscript">
<enabled />
<script><![CDATA[
if (player.health <= 0) {
msg ("You died or were killed.")
msg ("GAME OVER")
finish
} else {
if (player.status_effect = "poisoned") {
player.health=player.health-1
}
}
]]></script>
</turnscript>
~ OR you can have your 'losing health' Script(s) first, and then your 'death' Script(s) ... I'm not sure which is the better design~practice to do (and it also depends on the rest of your game design too, such as: if you got a party~team and can revive dead party~team members), lol ~
<turnscript name="global_turnscript">
<enabled />
<script><![CDATA[
player.health=player.health-1
if (player.health <= 0) {
msg ("You died or were killed.")
msg ("GAME OVER")
finish
}
]]></script>
</turnscript>
~OR, an example of a conditional for your losing health ~
<turnscript name="global_turnscript">
<enabled />
<script><![CDATA[
if (player.status_effect = "poisoned") {
player.health=player.health-1
}
if (player.health <= 0) {
msg ("You died or were killed.")
msg ("GAME OVER")
finish
}
]]></script>
</turnscript>