creating maximum values for hunger/thirst etc.
fatcrow
12 Dec 2015, 00:45I have just started with using Quest and I have run into a problem. I have made a system where as you walk around, you lose nutrition and hydration, and if you eat food or drink water, you gain nutrition and hydration. The problem arises when i try to stop the values from exceeding 100. I have tried using the script
edit: new values are now being turned into Boolean. This time it was a string value
if (player.Nutrition > player.Max_Value) {
player.Nutrition = player.Nutrition = player.Max_Value
}
with player.Max_Value being 100 In multiple places including after eating food and as a turn script. Every time i try this, for whatever reason player.Nutrition becomes Boolean and is set to false. I apologize if this is just a stupid mistake but I have rewritten this over and over without success and I would like to sort this out.edit: new values are now being turned into Boolean. This time it was a string value

OurJud
12 Dec 2015, 00:53I'm afraid I can't solve your problem, fatcrow, but I shall be following with interest as I too am making a game which requires the player to eat and drink.
My problem is that I like an extremely minimalist design to my games - nothing but the descriptions on screen - so how I allow my player to monitor their health is something I would have to think about. Maybe on a key press.
Anyway, not here to hijack so I'll leave it for someone else to answer.
My problem is that I like an extremely minimalist design to my games - nothing but the descriptions on screen - so how I allow my player to monitor their health is something I would have to think about. Maybe on a key press.
Anyway, not here to hijack so I'll leave it for someone else to answer.
HegemonKhan
12 Dec 2015, 07:41make sure you created~added~set'ted your 'Nutrition' and 'Max_Value' Attributes on your 'player' Player Object are indeed both set to an 'int' Attribute Type:
'player' Player Object -> 'Attributes' Tab -> Attributes -> (at the bottom, is the box containing your Attributes, find your two Attributes, 'Nutrition' and 'Max_Value', and click on them, then make sure that the little drop down box below, for both, is Attribute Type of: [integer~int], and while here, you might as well make sure that your 'Max_Value' is indeed set to: 100, as well)
--------
also, this is wrong:
this is correct:
in this wrong code:
// let's say: player.Nutrition = 25
// and: player.Max_Value = 100
player.Nutrition = player.Nutrition = player.Max_Value
(not used yet =) player.Nutrition = player.Max_Value
(not used yet =) player.Nutrition (25) <==== player.Max_Value (100)
(not used yet =) player.Nutrition (100)
player.Nutrition = player.Nutrition
player.Nutrition <==== player.Nutrition (100)
player.Nutrition = 100
see how it's redundent? So, you only need:
player.Nutrition = player.Max_Value
player.Nutrition <==== player.Max_Value (100)
player.Nutrition = 100
------------
remember, in Programming, you're ASSIGNING (=) the Value_or_Expression on the right side of the ASSIGNMENT OPERATOR (=) to~into being STORED by the VARIABLE on the left side of the ASSIGNMENT OPERATOR (=). Think Algebra and Algebraic Substitution:
x = 10
we're ASSSIGNING '10' to~into being STORED by the VARIABLE 'x', like this:
x <==== 10
and then we can use the VARIABLE:
msg ("The number is: " + x)
// outputs: The number is: 10
'player' Player Object -> 'Attributes' Tab -> Attributes -> (at the bottom, is the box containing your Attributes, find your two Attributes, 'Nutrition' and 'Max_Value', and click on them, then make sure that the little drop down box below, for both, is Attribute Type of: [integer~int], and while here, you might as well make sure that your 'Max_Value' is indeed set to: 100, as well)
--------
also, this is wrong:
if (player.Nutrition > player.Max_Value) {
player.Nutrition = player.Nutrition = player.Max_Value
}
this is correct:
if (player.Nutrition > player.Max_Value) {
player.Nutrition = player.Max_Value
}
in this wrong code:
// let's say: player.Nutrition = 25
// and: player.Max_Value = 100
player.Nutrition = player.Nutrition = player.Max_Value
(not used yet =) player.Nutrition = player.Max_Value
(not used yet =) player.Nutrition (25) <==== player.Max_Value (100)
(not used yet =) player.Nutrition (100)
player.Nutrition = player.Nutrition
player.Nutrition <==== player.Nutrition (100)
player.Nutrition = 100
see how it's redundent? So, you only need:
player.Nutrition = player.Max_Value
player.Nutrition <==== player.Max_Value (100)
player.Nutrition = 100
------------
remember, in Programming, you're ASSIGNING (=) the Value_or_Expression on the right side of the ASSIGNMENT OPERATOR (=) to~into being STORED by the VARIABLE on the left side of the ASSIGNMENT OPERATOR (=). Think Algebra and Algebraic Substitution:
x = 10
we're ASSSIGNING '10' to~into being STORED by the VARIABLE 'x', like this:
x <==== 10
and then we can use the VARIABLE:
msg ("The number is: " + x)
// outputs: The number is: 10
fatcrow
12 Dec 2015, 09:25Thank you for replying but the issue is still there. The problem is that the values are initially set as integers but become Boolean once the mentioned script is activated. Something even stranger is that now one of my string values is set to false as well. So if you have made your character an Orc and you look at yourself you get this peculiar message "You are a Male Orc of medium build. You have False medium length hair that is tied into a ponytail" where False should be "coarse black".
fatcrow
12 Dec 2015, 09:35Never mind. Somehow being tired and trying random things sorted out my problem. I don't know what i did or if i did anything but it worked.
edit: upon further inspection the redundancy in the code acctually was what was making the values become Boolean
edit: upon further inspection the redundancy in the code acctually was what was making the values become Boolean