Setting a Maximum for an Attribute?
chaosdagger
03 Jun 2015, 10:33Having trouble again and I can't find the answer in the how to pages, although one page said "this could also be used to set a max on an attribute" it didn't exactly say HOW to do that.
Basically I'm having two issues, one is with the player's HP. I know how to increase the number, but is there a way that would stop it at a certain number but it still editable of which that max number is? For example let's say the max HP is 10 and the character is down to 5, but eats a healing item that restores 10 HP. How can I have the item increase the attribute by 10 but stop the HP from going higher than the Max? That way in this case he/she would only heal 5 points, but later on how can I make it that his max then becomes twenty so if he/she is in the same situation they would now heal the full 10 points giving them 15?
The second issue is with a clock I was trying to get to work and I'm thinking whatever way to set max would help as it is displaying alright except when it gets past 00:59. It switches to 00:60 before jumping to 01:01 when it should skip 00:60 and become 01:00 instead...
Basically I'm having two issues, one is with the player's HP. I know how to increase the number, but is there a way that would stop it at a certain number but it still editable of which that max number is? For example let's say the max HP is 10 and the character is down to 5, but eats a healing item that restores 10 HP. How can I have the item increase the attribute by 10 but stop the HP from going higher than the Max? That way in this case he/she would only heal 5 points, but later on how can I make it that his max then becomes twenty so if he/she is in the same situation they would now heal the full 10 points giving them 15?
The second issue is with a clock I was trying to get to work and I'm thinking whatever way to set max would help as it is displaying alright except when it gets past 00:59. It switches to 00:60 before jumping to 01:01 when it should skip 00:60 and become 01:00 instead...
HegemonKhan
03 Jun 2015, 13:00hopefully this works (HK crosses his fingers)
(let me know if this doesn't work, also, if you're using quest version '560', then you got to change the code line '<asl version="550">' below to '<asl version="560">' instead)
create a new game file, open it up with a text software (notepad, wordpad, notepad++, apple: text editor, etc), highlight and delete it's entire code, then copy and paste my code below into your new game file, save it, and then play~test~study it.
----------
you use the 'modulous' OPERATOR: %
it's simply a division operation, but it gets (outputs~returns) *ONLY* the remainder value, unlike a division operation: /
for example (conceptualization only):
60 sec / 60 = 1 min
60 sec % 60 = R0 = 0 sec
// correct: 60 sec = 1 min and 0 sec
90 sec / 60 = 1 min
90 sec % 60 = R30 = 30 sec
// correct: 90 sec = 1 min and 30 sec
60 interval (such as for doing seconds, minutes, etc), conceptualization only:
value modulus_operator interval_dividing_value = R (remainder) # (0 through 59)=output_value~return_value (aka the remainder value)
12 or 24 intervals (such as for doing 12 hrs or 24 hrs):
value % 12 = (0 through 11)
~OR~
value % 24 = (0 through 23)
etc etc etc
--------------------
if you want to see a super convoluted way of doing a countdown timer without the modulous operator... (laughs):
viewtopic.php?f=18&t=4162
it took me forever to get this to work, laughs
(let me know if this doesn't work, also, if you're using quest version '560', then you got to change the code line '<asl version="550">' below to '<asl version="560">' instead)
create a new game file, open it up with a text software (notepad, wordpad, notepad++, apple: text editor, etc), highlight and delete it's entire code, then copy and paste my code below into your new game file, save it, and then play~test~study it.
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="testing game stuff">
<gameid>b073bbfb-0e99-45d3-9786-bb395a6bc6b0</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<attr name="current_life_integer_attribute" type="int">250</attr>
<attr name="maximum_life_integer_attribute" type="int">500</attr>
<attr name="life_string_attribute" type="string">250/500</attr>
<statusattributes type="simplestringdictionary">life_string_attribute = Life: !</statusattributes>
</object>
</object>
<object name="life_50_potion_1">
<inherit name="editor_object" />
<parent type="object">room</parent>
<alias>life 50 potion</laias>
<consume type="script"><![CDATA[
if (player.current_life_integer_attribute < maximum_life_integer_attribute) {
player.current_life_integer_attribute = player.current_life_integer_attribute + 50
msg ("You consume the potion, restoring back 50 life.")
if (player.current_life_integer_attribute > player.maximum_life_integer_attribute) {
player.current_life_integer-attribute = player.maximum_life_integer-attribute
}
}
]]></consume>
<displayverbs type="simplestringlist">look;take;consume</displayverbs>
<inventoryverbs type="simplestringlist">look;drop;consume</inventoryverbs>
</object>
<object name="life_100_elixir_1">
<inherit name="editor_object" />
<parent type="object">room</parent>
<alias>life elixir</alias>
<consume type="script"><![CDATA[
if (player.maximum_life_integer_attribute < 999) {
player.maximum_life_integer_attribute = maximum_life_integer_attribute + 100
msg ("You drink the elixir, increasing your maximum life by 100.")
if (player.maximum_life_integer_attribute > 999) {
player.maximum_life_integer_attribute = 999
}
} else {
msg ("You already have the total maximum life, at~of 999, so you can't increase it any more.")
}
]]></consume>
<displayverbs type="simplestringlist">look;take;consume</displayverbs>
<inventoryverbs type="simplestringlist">look;drop;consume</inventoryverbs>
</object>
<verb>
<property>consume</property>
<pattern>consume</pattern>
<defaultexpression>You can't consume that.</defaultexpression>
</verb>
<turnscript name="global_turnscript">
<enabled />
<script>
player.life_string_attribute = player.current_life_integer_attribute + "/" + player.maximum_life_integer_attribute
</script>
</turnscript>
</asl>
----------
you use the 'modulous' OPERATOR: %
it's simply a division operation, but it gets (outputs~returns) *ONLY* the remainder value, unlike a division operation: /
for example (conceptualization only):
60 sec / 60 = 1 min
60 sec % 60 = R0 = 0 sec
// correct: 60 sec = 1 min and 0 sec
90 sec / 60 = 1 min
90 sec % 60 = R30 = 30 sec
// correct: 90 sec = 1 min and 30 sec
60 interval (such as for doing seconds, minutes, etc), conceptualization only:
value modulus_operator interval_dividing_value = R (remainder) # (0 through 59)=output_value~return_value (aka the remainder value)
0%60=R0=0
1%60=R1=1
2%60=R2=2
3%60=R3=3
...
59%60=R59=59
60%60=R0=0
61%60=R1=1
...
119%60=R59=59
120%60=R0=0
121%60=R1=1
....
12 or 24 intervals (such as for doing 12 hrs or 24 hrs):
value % 12 = (0 through 11)
~OR~
value % 24 = (0 through 23)
etc etc etc
--------------------
if you want to see a super convoluted way of doing a countdown timer without the modulous operator... (laughs):
viewtopic.php?f=18&t=4162
it took me forever to get this to work, laughs
chaosdagger
03 Jun 2015, 13:22Thanks for the info! I'll give this a shot later when I get home!
The Pixie
03 Jun 2015, 14:39Have two attributes, player.hp and player.max_hp Whenever hit points can increase, just add the increase, say inc, then check if the new value is over the max, and if it is, set to the max:
player.hp = player.hp + inc
if (player.hp > player.max_hp) {
player.hp = player.max_hp
}
chaosdagger
06 Jun 2015, 09:16Alright so mostly all of that was quite helpful. The only thing I'm not understanding right now is what value to I use for the hours. Like I have the minutes working by having a turn counter. Basically game.turns gets plus 1 each turn (obviously lol) and game.minutes=game.turns%60
However which value should I use to add hours to the clock then?
However which value should I use to add hours to the clock then?
HegemonKhan
06 Jun 2015, 11:00the below is JUST~ONLY for 'clock time' displayment, if you want the total seconds~minutes~hours~etc, we need to do some different and~or extra stuff. (If you want~need to get or also get the 'total time' then let me know, as your setup which I respond to in this post, only deals with 'clock time', and not 'total time').
// conceptually (civilian: am~pm): 0 to 11 hrs + 0 to 59 minutes + 0 to 59 seconds
// and~OR
// conceptually (military): 0 to 23 hrs + 0 to 59 minutes + 0 to 59 seconds
the simpliest (which your setup, of '1 turn = 1 second', is already set up for nicely, hehe):
game.total_hours = game.turns / 3600
// 1 hour = 60 minutes * 60 seconds = 3600 seconds~turns
// 1 hour = 60 (game.minutes=game.turns / 60) = 60 game.minutes = game.turns / 3600
// game.total_minutes = game.turns / 60
but if you want 'clock time' (and not just 'stop watch' total hours of counting up or down), you'll need this extra part on it too:
game.civilian_12_am_pm_hours = (game.turns / 3600) % 12
// conceptually: game.civilian_hours = game.total_hours % 12
// AND~OR:
game.military_24_hours = (game.turns / 3600) % 24
// conceptually: game.civilian_hours = game.total_hours % 24
------
however, there's lots of options~methods~means~configurations of doing time, as well as it also depends on exactly what~how you want to do the use and~or design of the involvement of time, aka how simple vs complex is your time usage~involvement within your game.
-------
TOTAL TIME:
game.turns = 0
game.turns = game.turns + 1
game.total_minutes = game.turns / 60
game.total_hours = game.turns / 3600 // OR // game.total_hours = game.total_minutes / 60
--------
P.S.
I forgot to mention that there's Pixie's Clock (Time, Date, and etc) Library:
viewtopic.php?f=18&t=2580 (Pixie's older~original Clock Library)
HK EDIT (I'm not hallucinating!): Pixie's new'er Clock Library: viewtopic.php?f=18&t=5233
-------
@Pixie:
maybe I'm getting old and hallucinating~imagining things, but didn't you make a new'er Clock Library somewhat recently (or you made~upgraded some other library of yours somewhat recently, but just not your Clock library ~ HK memory confusion but not hallucinating at least, lol) ???
HK EDIT: woot, I'm not hallucinating, you indeed did make a new clock library, lol: viewtopic.php?f=18&t=5233
// conceptually (civilian: am~pm): 0 to 11 hrs + 0 to 59 minutes + 0 to 59 seconds
// and~OR
// conceptually (military): 0 to 23 hrs + 0 to 59 minutes + 0 to 59 seconds
the simpliest (which your setup, of '1 turn = 1 second', is already set up for nicely, hehe):
game.total_hours = game.turns / 3600
// 1 hour = 60 minutes * 60 seconds = 3600 seconds~turns
// 1 hour = 60 (game.minutes=game.turns / 60) = 60 game.minutes = game.turns / 3600
// game.total_minutes = game.turns / 60
but if you want 'clock time' (and not just 'stop watch' total hours of counting up or down), you'll need this extra part on it too:
game.civilian_12_am_pm_hours = (game.turns / 3600) % 12
// conceptually: game.civilian_hours = game.total_hours % 12
// AND~OR:
game.military_24_hours = (game.turns / 3600) % 24
// conceptually: game.civilian_hours = game.total_hours % 24
------
however, there's lots of options~methods~means~configurations of doing time, as well as it also depends on exactly what~how you want to do the use and~or design of the involvement of time, aka how simple vs complex is your time usage~involvement within your game.
-------
TOTAL TIME:
game.turns = 0
game.turns = game.turns + 1
game.total_minutes = game.turns / 60
game.total_hours = game.turns / 3600 // OR // game.total_hours = game.total_minutes / 60
--------
P.S.
I forgot to mention that there's Pixie's Clock (Time, Date, and etc) Library:
viewtopic.php?f=18&t=2580 (Pixie's older~original Clock Library)
HK EDIT (I'm not hallucinating!): Pixie's new'er Clock Library: viewtopic.php?f=18&t=5233
-------
@Pixie:
maybe I'm getting old and hallucinating~imagining things, but didn't you make a new'er Clock Library somewhat recently (or you made~upgraded some other library of yours somewhat recently, but just not your Clock library ~ HK memory confusion but not hallucinating at least, lol) ???
HK EDIT: woot, I'm not hallucinating, you indeed did make a new clock library, lol: viewtopic.php?f=18&t=5233
HegemonKhan
06 Jun 2015, 12:53err... I got confused in my above post (I think ~ I really hate time and date stuff, so confusing... and math heavy, I hate math!)... the modulus operator (%) still causes me confusion, laughs...
your 'game.minutes=game.turns%60' Attribute, is actually saying: 1 turn = 1 minute, which if this is what you want, then change out my '3600' to just '60'.
if you want: 1 turn = 1 second, then change your Attribute of 'game.minutes=game.turns%60' to 'game.minutes=(game.turns/60)%60' or to 'game.seconds=game.turns%60'
your 'game.minutes=game.turns%60' Attribute, is actually saying: 1 turn = 1 minute, which if this is what you want, then change out my '3600' to just '60'.
if you want: 1 turn = 1 second, then change your Attribute of 'game.minutes=game.turns%60' to 'game.minutes=(game.turns/60)%60' or to 'game.seconds=game.turns%60'
chaosdagger
06 Jun 2015, 14:03Thank you very much. Yes I am doing 1 turn = 1 minute as although not all actions would actually take a minute, a single second per turn would make the day/night cycle run way too long. I'll give it a shot with how you have described and let you know if it works for what I need. Thank you again.
Edit: Yes it worked perfectly for my clock. Which looks like this...
Edit: Yes it worked perfectly for my clock. Which looks like this...
game.turns = game.turns+1
game.minutes = game.turns%60
game.hours = (game.turns/60)%24
if (game.minutes<10) {
game.clockMinutes = "0"+game.minutes
}
else {
game.clockMinutes = game.minutes
}
if (game.hours<10) {
game.clockHours = "0"+game.hours
}
else {
game.clockHours = game.hours
}
game.Time = game.clockHours+":"+game.clockMinutes
HegemonKhan
06 Jun 2015, 23:19the site's code box is nice for code (as it keeps the indenting~'nesting' formatting intact) and~or for walls of text (as it's confined to the code box, which can scroll up and down to see all of it, thus keeping your post small~smaller, which is nice).
this is the code tag for the code box:
[code.]your_contents_here_code_or_text_wall
but without the periods in the brackets, which will produce this:
and if you want to do the quote tag box:
[.quote="quoted_user's_name"]the_quote[/quote.]
-------
[.quote="HK"]the_quote[/quote.]
again, without the periods in the brackets, producing this:
------
or, without the quoted user's name (though it nulls the purpose of a quote, in not giving the required credit, laughs):
[.quote]the_quote[/quote.]
again, without the periods in the brackets, producing this:
this is the code tag for the code box:
[code.]your_contents_here_code_or_text_wall
but without the periods in the brackets, which will produce this:
your_contents_here_code_or_text_wall
and if you want to do the quote tag box:
[.quote="quoted_user's_name"]the_quote[/quote.]
-------
[.quote="HK"]the_quote[/quote.]
again, without the periods in the brackets, producing this:
HK wrote:the_quote
------
or, without the quoted user's name (though it nulls the purpose of a quote, in not giving the required credit, laughs):
[.quote]the_quote[/quote.]
again, without the periods in the brackets, producing this:
the_quote
chaosdagger
07 Jun 2015, 01:17And thank you once again!