Reference:
0 inches = 0 feet
12 inches = 1 foot
24 inches = 2 feet
36 inches = 3 feet
48 inches = 4 feet
60 inches = 5 feet
72 inches = 6 feet
84 inches = 7 feet
96 inches = 8 feet
108 inches = 9 feet
120 inches = 10 feet
<function name="height_function"><![CDATA[
msg ("What is your height (in inches)?")
get input {
if (IsInt (result) and result >= 0 and result <= 120) {
player.inch_height_integer_attribute = result
player.feet_height_integer_attribute = player.inch_height_integer_attribute / 12
player.remaining_inches_integer_attribute = player.inch_height_attribute % 12
player.height_string_attribute = "Height: You are " + player.feet_height_integer_attribute + " feet and " + (player.remaining_inches_integer_attribute + " inches tall"
} else {
msg ("Wrong input, try again")
height_function
}
}
]]></function>
<function name="height_function"><![CDATA[
msg ("What is your height?")
msg ("(Type in your feet first, then you'll be asked again, for your inches)")
msg ("")
msg ("Feet?")
get input {
if (IsInt (result) and result >= 0 and result < 10) {
player.feet_height_integer_attribute = result
msg ("Inches?")
get input {
if (IsInt (result) and result >= 0 and result < 12) {
player.inches_height_integer_attribute = result
player.height_string_attribute = "Height: You are " + player.feet_height_integer_attribute + " feet and " + player.inches_integer_attribute + " inches tall"
} else {
msg ("Wrong input, try again")
height_function
}
} else {
msg ("Wrong input, try again")
height_function
}
}
]]></function>
game.height_stringlist_attribute = split ("1.0; 2.0; 3.0; 4.0; 5.0", ";")
<game name="xxx">
<attr name="height_stringlist_attribute" type="simplestringlist">1.0; 2.0; 3.0; 4.0; 5.0</attr>
</game>
game.height_stringlist_attribute = split ("index number 0 position; index number 1 position; index number 2 position; index number position 3; index number 4 position", ";")
<game name="xxx">
<attr name="height_stringlist_attribute" type="simplestringlist">index number 0 position; index number 1 position; index number 2 position; index number 3 position; index number 4 position</attr>
</game>
"1.0" <----> index number 0 position
"2.0" <----> index number 1 position
"3.0" <----> index number 2 position
"4.0" <----> index number 3 position
"5.0" <----> index number 4 position
------
http://docs.textadventures.co.uk/quest/ ... lists.html
http://docs.textadventures.co.uk/quest/ ... titem.html
StringListItem (Object_name.Stringlist_Attribute_name, index_number_position)
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, 0)
// player.height_string_attribute = "1.0"
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, 1)
// player.height_string_attribute = "2.0"
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, 2)
// player.height_string_attribute = "3.0"
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, 3)
// player.height_string_attribute = "4.0"
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, 4)
// player.height_string_attribute = "5.0"
z = 3
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, z)
// player.height_string_attribute = "4.0"
show menu ("Number?", split ("0; 1; 2; 3; 4", ";"), false) {
// for example, you choose 1
// result = 1
}
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, result)
// player.height_string_attribute = "2.0"
msg ("Type in a number from 0 to 4")
get input {
// for example, you type: 2
// result = 2
}
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, result)
// player.height_string_attribute = "3.0"
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, GetRandomInt (0, 4) )
// player.height_string_attribute = StringListItem (game.height_stringlist_attribute, randomly it will select: 0 or 1 or 2 or 3 or 4 )
// player.height_string_attribute = (based on whatever the random choosen index number is, it will be the matching~corresponding: "1.0" or "2.0" or "3.0" or "4.0" or "5.0")
x = GetRandomInt (0, 4)
// for example, let's say it randonly chooses: 4
// x = 4
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, x )
// player.height_string_attribute = "5.0"
player.feet_integer_attribute = 3
// you drink a weak height potion (+1 feet): player.feet_integer_attribute = player.feet_integer_attribute + 1
// player.feet_integer_attribute = 4
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, player.feet_integer_attribute)
// before you drank the weak height potion: player.height_string_attribute = "4.0"
// after you drank the weak height potion: player.height_string_attribute = "5.0"
Why not have the integer as the height in inches?
I would use the integer as the primary attribute, and set a string attribute based on that. If you want to be fancy, set up a change script on the integer to automatically update the string.
viewtopic.php?f=18&t=5307&p=36709#p36709
Script to convert the integer to a string:
player.heightasstring = "" + player.height / 12 + "'" + player.height % 12
in scripting:
game.shopping_list = split ("eggs;milk;bread;meat", ";")
------------ and~or --------------------------
as 'creation' tag block:
horizontal, type="simplestringlist", is better for only single word items, such as our shopping list:
<game name="xxx">
<attr name="shopping_list" type="simplestringlist">eggs;milk;bread;meat</attr>
</game>
or
vertical, type="stringlist", is better when you got long sentences for your items, for an example:
<game name="xxx">
<attr name="race_description_list" type="stringlist">
<value>Human Race Description: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah</value>
<value>Dwarf Race Description: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah</value>
<value>Elf Race Description: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah</value>
</attr>
</game>
though you can certainly use vertical for single word items too if you like
here is our shopping list vertically:
<game name="xxx">
<attr name="shopping_list" type="stringlist">
<value>eggs</value>
<value>milk</value>
<value>bread</value>
<value>meat</value>
</attr>
</game>
game.shopping_list = split ("bread;meat;milk;eggs", ";")
------- and~or -------------------------------
<game name="xxx">
<attr name="shopping_list" type="simplestringlist">bread;meat;milk;eggs</attr>
</game>
or
<game name="xxx">
<attr name="shopping_list" type="stringlist">
<value>bread</value>
<value>meat</value>
<value>milk</value>
<value>eggs</value>
</attr>
</game>
show menu ("Number?", split ("0;1;2;3", ";"), false) {
// let's say you selected: 1
// result = 1
player.grociery_bag = StringListItem (game.shopping_list, result)
}
msg ("Type in the number of the item you want")
DisplayList (game.shopping_list, true)
get input {
// let's say you typed in: 4
// result = 4
if (IsInt (result) and result >= 1 and result <= ListCount (game.shopping_list) ) {
player.grociery_bag = StringListItem (game.shopping_list, ToInt (result) - 1)
// this will work, due to the 'ToInt (result) - 1', this code is a bit more advanced, so study it, or ask for help
// hint1: ListCount (List_name) ~~ gets~returns the total number of items in your list, ie: 4 (remember: that this 4th~last item's index number is: 3)
// hint2: ListCount (List_name) - 1 ~~ total number of items in your list - 1 = a correct index number of an item in your list
}
}
VARIABLE = StringListItem (List_name, index number)
msg ("Type in the number of the item that you want to buy")
DisplayList (game.shopping_list, true)
get input {
if (IsInt (result) and result >= 0 and result <= ListCount (game.shopping_list) - 1) {
player.grociery_bag = StringListItem (game.shopping_list, result)
msg ("You bought: " + player.grociery_bag)
} else {
msg ("Wrong input, try again")
}
}
<object name="fulldata">
<attr name="height_list" type="simplestringlist">0.0; 0.5; 1.0; 1.5; 2.0; 2.5; 3.0; etc</attr>
</attr>
neonayon wrote:player.height = StringListItem (fulldata.height_list + 2) for example, if I wanted a player to move up plus two steps.....like saying if they had a height of 5.2 feet...and I used + 2 right there, it would move them up to 5.4 feet?
neonayon wrote:Also, I was curious to know about "height_list" ...do I put "height_list" or do I match it to player.height? Or does "height_list" help the Quest Stringlists to identify that it's pulling from a list?
neonayon wrote:It's been a long week in class. Ugh.
//this is the players height rating
player.height_rating = 4
//this will set the displayed height value to the equivalent from your master list
player.height = ListItem(fulldata.height_list, player.height_rating)
//to modify this alter the players built in height rating then resync with the master list value
player.height_rating = player.height_rating + 2
player.height = ListItem(fulldata.height_list, player.height_rating)
player.height = StringListItem (fulldata.height_list + 2) for example, if I wanted a player to move up plus two steps.....like saying if they had a height of 5.2 feet...and I used + 2 right there, it would move them up to 5.4 feet?
//racial list dictionary attribute is fulldata.racial_list
dictionary add (fulldata.racial_list, snake_person, Naga)
//repeat with other races to build the list if not inputting directly into the actual attribute
//something happens to change player race
player.race = "snake_person"
//set the display name from the master list
display.player_race = DictionaryItem (fulldata.racial_list, player.race)
//your display value for player_race is now whatever you want the actual players to see
TinFoilMkIV wrote:basically there are two parts to the solution that fits your problem.
#1: the height index value, the integer that refers to the current height
#2: the actual height value to be displayed such as 5'6"
value #1 makes the most sense to save as a player attribute as this tells the game the value to look at whenever you want the players current height. Value #2 is what you pull from the master list of heights when you want to actually display it. You can either save this to another player attribute or just reference it directly whenever you want it displayed, that's up to you.
player.race = dwarf
msg("Like all " + player.race.plural + " you have blue hair.")
player_race = player.race.name
player_race = player.race.plural
//etc
Like all {player_race.plural} you have blue hair.
//this is the players height rating
player.height_rating = 4
//this will set the displayed height value to the equivalent from your master list
player.height = ListItem(fulldata.height_list, player.height_rating)
//to modify this alter the players built in height rating then resync with the master list value
player.height_rating = player.height_rating + 2
player.height = ListItem(fulldata.height_list, player.height_rating)
player.height = ListItem(fulldata.height_list, player.height_rating)
player.height_rating = player.height_rating + 2
player.height = ListItem(fulldata.height_list, player.height_rating)
height_as_array = Split(result, ".")
player.height_rating = ToInt(StringListItem(height_as_array, 0)) * 12 + ToInt(StringListItem(height_as_array, 1))
player.height_rating = player.height_rating + 2
return ("" + player.height_rating / 12 + "'" + player.height_rating % 12)
player.height = GetHeight()
msg("You are now " + GetHeight() + " tall!")
Neonayon wrote://this is the players height rating
player.height_rating = 4
//this will set the displayed height value to the equivalent from your master list
player.height = ListItem(fulldata.height_list, player.height_rating)
//to modify this alter the players built in height rating then resync with the master list value
player.height_rating = player.height_rating + 2
player.height = ListItem(fulldata.height_list, player.height_rating)
Okay. So just to be clear (I'm a beginner still so bare with me)...
So on the player.object, I go to Attributes and add height_rating for example, as an integer value. Now the problem is, the player gets to choose their height in the beginning of the game (separate object called creation.object, which doesn't have to be messed with), among other traits. What number would I put for.... player.height_rating = # in that case?
[quote]player.height = ListItem(fulldata.height_list, player.height_rating)
player.height_rating = player.height_rating + 2
player.height = ListItem(fulldata.height_list, player.height_rating)
//function name : Change_Height
//parameters: change
// to call this function in code will look like this
//Change_Height(#)
player.height_rating = player.height_rating + [u]change[/u]
player.height = ListItem(fulldata.height_list, player.height_rating)
Well, as far as when you first create the attribute in the editor I'd just leave it at 0 or whatever you want the default value to be. As far as changing it in the character creator, the easiest method would be to just give the player some preset options.
So you would list some choices and when the player selects a starting height from those choices you would code it to just set player.height_rating to the integer value of that height in the master list.
basically whenever you change the player.height_rating you then have to recalculate the player.height, otherwise the game wont actually show the height change since the player.height is what the player will see.
And at the same time you should only ever need to calculate the player.height when you change the player.height_rating, as it should be correct as long as the rating wasn't changed.
This way when you want to do something like say add 2 to your height rating, you can just call Change_Height (2), and for a height decrease you simply use a negative number.
<object name="creator">
<attr name="creation_height_list" type="simplestringlist">5.0; 5.2; ... ; 5.10; 6.0</attr>
</object>
<object name="fulldata">
<attr name="full_height_list" type="simplestringlist">3.0; 3.2; ... ; 6.10; 7.0</attr>
</object>
<object name="player">
<attr name="alias" type="string">unknown</attr>
<attr name="sex" type="string">unknown</attr>
// etc Attributes
<attr name="height" type="string">unknown</attr>
<attr name="height_rating" type="int">0</attr>
<attr name="statusattributes" type="simplestringdictionary">height = Height: !; alias = Name: !; sex = Sex: !; etc_etc_etc</attr>
</object>
<object name="creator">
<attr name="creation_height_list" type="simplestringlist">5.0; 5.2; ... ; 5.10; 6.0</attr>
</object>
object name="player">
<changedheight_rating type="script">
player.height = StringListItem (fulldata.full_height_list, player.height_rating)
</changedheight_rating>
</object>
<turnscript name="xxx">
<enabled>
<script>
player.height = StringListItem (fulldata.full_height_list, player.height_rating)
</script>
</turnscript>
Neonayon wrote:So you would list some choices and when the player selects a starting height from those choices you would code it to just set player.height_rating to the integer value of that height in the master list.
Not sure what you mean. Kind of have to dumb it down for me, cause I'm really slow apparently lol.
So first, I go to the player.object where the height attribute is (which is currently a stringlist), then I create an integer attribute called height_rating and set it to 0?
//display options for player to choose
//player chose 5'6"
player.height = 5'6"
player.height_rating = 7
[quote]And at the same time you should only ever need to calculate the player.height when you change the player.height_rating, as it should be correct as long as the rating wasn't changed.
[quote]This way when you want to do something like say add 2 to your height rating, you can just call Change_Height (2), and for a height decrease you simply use a negative number.
No problem, I like looking at this kind of stuff. Considerably less convoluted then half the code I end up putting myself through, heh. Helps me to step back and make sure I'm not building one giant mess with my own code.((Also, thank you Pixie and Tin so far on helping me, I really appreciate your patience))
<attr name="height" type="string">unknown</attr>
<attr name="height_rating" type="int">0</attr>
neonayon wrote:Creation
player.height: "string list": 5.0, 5.2, 5.4, 5.6, --- 6.0
Full Data
player.height: "string list": 3.0 --- 7.0
Object Name: player)
Attribute Name: height
Attribute Type: string
Attribute Value: unknown // (or whatever you want for the initial display, such as '0.0' or whatever, before it is set~selected by your character creation section at the start of the game play)
(Object Name: player)
Attribute Name: height_rating
Attribute Type: int (integer)
Attribute Value: (this is an issue... Stringdictionary usage would fix it... but I doubt you want to get into learning dictionaries when you're still learning lists)
actually... when I get the time (hopefully sometime in the next week or two ... well if I don't have tests to study for...hmm), I'll guide you step by step through a design that'll work and you'll be able to (hopefully) understand easily.
As what you got right now... has a few issues with it to get it working... so, it'll be better to create a slightly change in setup, than trying to correct your current setup to work fully.
if you want to learn Dictionaries, that would make all of this much easier!, though we'd have to re-create a new setup, but it shouldn't be too bad to do.
Dictionaries actually aren't too much different from Lists, but they can be a bit harder to grasp~understand, especially if Lists are still confusing to you.
Neonayon wrote:Okay...I'm not sure why, but neither of you are putting this in simple terms for me. I need it completely broken down! I must be really awful at this.
Why do I need a second list that displays the same exact information? I have...for example...
Creation
player.height: "string list": 5.0, 5.2, 5.4, 5.6, --- 6.0
Full Data
player.height: "string list": 3.0 --- 7.0
Now from what I understand you guys want me to create a second list for these...for example
player.height: "string list": 5.0, 5.2, 5.4, 5.6, --- 6.0
player.height_list: "string list": 5.0, 5.2, 5.4, 5.6, --- 6.0
and
player.height: "string list": 3.0 --- 7.0
player.height_list: "string list": 3.0 --- 7.0
So why am I making that a new (second) list, which is exactly the same? Why can't I use the first lists? Keep in mind I have no idea where to place the "code" for these either...so it'll have to be done in the GUI, I guess.
player.height = ListItem(fulldata.height_list, player.height_rating)
From what I've gathered...
I need these lists...
Creation
player.height: "string list": 5.0, 5.2, 5.4, 5.6, --- 6.0
Full Data
player.height: "string list": 3.0 --- 7.0
player.height = StringListItem (fulldata.full_height_list, player.height_rating)
^--- I know this is the end result. But why can't it be ....
player.height = StringListItem (fulldata.height, player.height) ?
Essentially all I want to do.....is after the player creates their character, manipulate that selection from the fulldata list. I have a creation list....and a fulldata list. The fulldata list is an expansion directly from the creation list.
I just want to be able to make a player (no matter what they chose) to become taller or shorter, tanner or paler, skinnier and more fat, etc
// neonayon's initial limited height selection list *only* for the start of the game (character creation):
// Creation.height = split ("5.0;5.2;5.4;5.6;5.8;5.10;6.0", ";")
// neonayon's full height range list during game play (after the initial limited selection of height of the character creation):
// Full Data.height = split ("3.0;3.2;3.4;3.6;3.8;3.10;4.0;4.2;4.4;4.6;4.8;4.10;5.0;5.2;5.4;5.6;5.8;5.10;6.0;6.2;6.4;6.6;6.8;6.10;7.0", ";")
...index_integer....|..string_value
...(height_rating)..|....(height)
--------------------|-----------------
........0...........|......3.0......
........1...........|......3.2......
........2...........|......3.4......
........3...........|......3.6......
........4...........|......3.8......
........5...........|......3.10.....
........6...........|......4.0......
........7...........|......4.2......
........8...........|......4.4......
........9...........|......4.6......
........10..........|......4.8......
........11..........|......4.10.....
........12..........|......5.0......
........13..........|......5.2......
........14..........|......5.4......
........15..........|......5.6......
........16..........|......5.8......
........17..........|......5.10.....
........18..........|......6.0......
........19..........|......6.2......
........20..........|......6.4......
........21..........|......6.6......
........22..........|......6.8......
........23..........|......6.10.....
........24..........|......7.0......
---------------------|---------------
a qwasi-part of your 'character creation' script block within~for your 'game' Object -> 'script' Tab -> 'start' Script:
showmenu ("Height?", Creation.height, false) {
player.height = ToString (result)
// The fix to deal with the issue of non-set 'player.height_rating=(null or unknown)', see below:
if (player.height = "5.0") {
player.height_rating = 12
} else if (player.height = "5.2") {
player.height_rating = 13
} else if (player.height = "5.4") {
player.height_rating = 14
} else if (player.height = "5.6") {
player.height_rating = 15
} else if (player.height = "5.8") {
player.height_rating = 16
} else if (player.height = "5.10") {
player.height_rating = 17
} else if (player.height = "6.0") {
player.height_rating = 18
}
}
// and because of the fix above, now your 'player.height_rating' is correctly set (after~from the character creation) and thus won't cause any issues with your global Turnscript:
<turnscript name="xxx">
<enabled />
<script>
player.height = StringListItem(Full Data.height, player.height_rating)
</script>
</turnscript>
// during game play, the full height range is the 'Full Data.height' Stringlist Attribute, from 3.0 to 7.0, by 2 inch intervals
// for example, neonayon has a 'height_growth_potion' that can be drunk during game play:
player.height_rating = player.height_rating + 2
// which then her global Turnscript kicks-in, changing her 'player.height'
if (player.current_life_integer > player.maximum_life_integer) {
player.current_life_integer = player.maximum_life_integer
}
The Pixie wrote:Why not use JavaScript for the character creation?
http://textadventures.co.uk/games/view/ ... r-neonayon
return ("" + player.height_rating / 12 + "'" + player.height_rating % 12)
// Returns the index of the given item in the given list, or -1 if it is not found
count = 0
msg ("looking for " + item)
foreach (o, lst) {
if (o = item) {
return (count)
}
msg ("not " + o)
count = count + 1
}
return (-1)
player.height = GetHeight()
height_as_array = Split(result, ".")
player.height_rating = ToInt(StringListItem(height_as_array, 0)) * 12 + ToInt(StringListItem(height_as_array, 1))
player.height_rating = player.height_rating + 2
return ("" + player.height_rating / 12 + "'" + player.height_rating % 12)
player.height = GetHeight()
Neonayon wrote:"The Pixie"
Why not use JavaScript for the character creation?
http://textadventures.co.uk/games/view/ ... r-neonayon
Pix, you cray cray if you think I can program in Java script!! I can barely use Quest! That looks fantastic though. But I think I'm too much of a newbie to do any substantial work like that. I still have to figure out a basic combat system, and items that affect the characters appearance. Maybe once I figure out those backbones I'll be able to Java.