Height library

A while back, I was helping a fellow forumer out with a few things, and player.height was involved.

Pixie had created a library, which had a few functions concerning height, and I based this on that.


heightLib.aslx

<library>
    <object name="height_object">
    <height_list_displayed_US type="stringlist">
      <value>3' 0"</value>
      <value>3' 1"</value>
      <value>3' 2"</value>
      <value>3' 3"</value>
      <value>3' 4"</value>
      <value>3' 5"</value>
      <value>3' 6"</value>
      <value>3' 7"</value>
      <value>3' 8"</value>
      <value>3' 9"</value>
      <value>3' 10"</value>
      <value>3' 11"</value>
      <value>4' 0"</value>
      <value>4' 1"</value>
      <value>4' 2"</value>
      <value>4' 3"</value>
      <value>4' 4"</value>
      <value>4' 5"</value>
      <value>4' 6"</value>
      <value>4' 7"</value>
      <value>4' 8"</value>
      <value>4' 9"</value>
      <value>4' 10"</value>
      <value>4' 11"</value>
      <value>5' 0"</value>
      <value>5' 1"</value>
      <value>5' 2"</value>
      <value>5' 3"</value>
      <value>5' 4"</value>
      <value>5' 5"</value>
      <value>5' 6"</value>
      <value>5' 7"</value>
      <value>5' 8"</value>
      <value>5' 9"</value>
      <value>5' 10"</value>
      <value>5' 11"</value>
      <value>6' 0"</value>
      <value>6' 1"</value>
      <value>6' 2"</value>
      <value>6' 3"</value>
      <value>6' 4"</value>
      <value>6' 5"</value>
      <value>6' 6"</value>
      <value>6' 7"</value>
      <value>6' 8"</value>
      <value>6' 9"</value>
      <value>6' 10"</value>
      <value>6' 11"</value>
      <value>7' 0"</value>
    </height_list_displayed_US>
    <height_list_as_int type="list">
      <value type="int">0</value>
      <value type="int">1</value>
      <value type="int">2</value>
      <value type="int">3</value>
      <value type="int">4</value>
      <value type="int">5</value>
      <value type="int">6</value>
      <value type="int">7</value>
      <value type="int">8</value>
      <value type="int">9</value>
      <value type="int">10</value>
      <value type="int">11</value>
      <value type="int">12</value>
      <value type="int">13</value>
      <value type="int">14</value>
      <value type="int">15</value>
      <value type="int">16</value>
      <value type="int">17</value>
      <value type="int">18</value>
      <value type="int">19</value>
      <value type="int">20</value>
      <value type="int">21</value>
      <value type="int">22</value>
      <value type="int">23</value>
      <value type="int">24</value>
      <value type="int">25</value>
      <value type="int">26</value>
      <value type="int">27</value>
      <value type="int">28</value>
      <value type="int">29</value>
      <value type="int">30</value>
      <value type="int">31</value>
      <value type="int">32</value>
      <value type="int">33</value>
      <value type="int">34</value>
      <value type="int">35</value>
      <value type="int">36</value>
      <value type="int">37</value>
      <value type="int">38</value>
      <value type="int">39</value>
      <value type="int">40</value>
      <value type="int">41</value>
      <value type="int">42</value>
      <value type="int">43</value>
      <value type="int">44</value>
      <value type="int">45</value>
      <value type="int">46</value>
      <value type="int">47</value>
      <value type="int">48</value>
    </height_list_as_int>
    <height_list_US_doubles_string type="list">
      <value type="string">3.0</value>
      <value type="string">3.1</value>
      <value type="string">3.2</value>
      <value type="string">3.3</value>
      <value type="string">3.4</value>
      <value type="string">3.5</value>
      <value type="string">3.6</value>
      <value type="string">3.7</value>
      <value type="string">3.8</value>
      <value type="string">3.9</value>
      <value type="string">3.10</value>
      <value type="string">3.11</value>
      <value type="string">4.0</value>
      <value type="string">4.1</value>
      <value type="string">4.2</value>
      <value type="string">4.3</value>
      <value type="string">4.4</value>
      <value type="string">4.5</value>
      <value type="string">4.6</value>
      <value type="string">4.7</value>
      <value type="string">4.8</value>
      <value type="string">4.9</value>
      <value type="string">4.10</value>
      <value type="string">4.11</value>
      <value type="string">5.0</value>
      <value type="string">5.1</value>
      <value type="string">5.2</value>
      <value type="string">5.3</value>
      <value type="string">5.4</value>
      <value type="string">5.5</value>
      <value type="string">5.6</value>
      <value type="string">5.7</value>
      <value type="string">5.8</value>
      <value type="string">5.9</value>
      <value type="string">5.10</value>
      <value type="string">5.11</value>
      <value type="string">6.0</value>
      <value type="string">6.1</value>
      <value type="string">6.2</value>
      <value type="string">6.3</value>
      <value type="string">6.4</value>
      <value type="string">6.5</value>
      <value type="string">6.6</value>
      <value type="string">6.7</value>
      <value type="string">6.8</value>
      <value type="string">6.9</value>
      <value type="string">6.10</value>
      <value type="string">6.11</value>
      <value type="string">7.0</value>
    </height_list_US_doubles_string>
    <height_list_displayed_meters type="stringlist">
      <value>0.91 m</value>
      <value>0.94 m</value>
      <value>0.97 m</value>
      <value>0.99 m</value>
      <value>1.02 m</value>
      <value>1.04 m</value>
      <value>1.07 m</value>
      <value>1.09 m</value>
      <value>1.12 m</value>
      <value>1.14 m</value>
      <value>1.17 m</value>
      <value>1.19 m</value>
      <value>1.21 m</value>
      <value>1.24 m</value>
      <value>1.27 m</value>
      <value>1.29 m</value>
      <value>1.32 m</value>
      <value>1.34 m</value>
      <value>1.37 m</value>
      <value>1.39 m</value>
      <value>1.42 m</value>
      <value>1.44 m</value>
      <value>1.47 m</value>
      <value>1.49 m</value>
      <value>1.52 m</value>
      <value>1.55 m</value>
      <value>1.58 m</value>
      <value>1.6 m</value>
      <value>1.63 m</value>
      <value>1.65 m</value>
      <value>1.68 m</value>
      <value>1.7 m</value>
      <value>1.73 m</value>
      <value>1.75 m</value>
      <value>1.78 m</value>
      <value>1.8 m</value>
      <value>1.82 m</value>
      <value>1.85 m</value>
      <value>1.88 m</value>
      <value>1.9 m</value>
      <value>1.93 m</value>
      <value>1.95 m</value>
      <value>1.98 m</value>
      <value>2 m</value>
      <value>2.03 m</value>
      <value>2.05 m</value>
      <value>2.08 m</value>
      <value>2.1 m</value>
      <value>2.13 m</value>
    </height_list_displayed_meters>
    <height_list_meters_as_doubles type="list">
      <value type="double">0.91</value>
      <value type="double">0.94</value>
      <value type="double">0.97</value>
      <value type="double">0.99</value>
      <value type="double">1.02</value>
      <value type="double">1.04</value>
      <value type="double">1.07</value>
      <value type="double">1.09</value>
      <value type="double">1.12</value>
      <value type="double">1.14</value>
      <value type="double">1.17</value>
      <value type="double">1.19</value>
      <value type="double">1.21</value>
      <value type="double">1.24</value>
      <value type="double">1.27</value>
      <value type="double">1.29</value>
      <value type="double">1.32</value>
      <value type="double">1.34</value>
      <value type="double">1.37</value>
      <value type="double">1.39</value>
      <value type="double">1.42</value>
      <value type="double">1.44</value>
      <value type="double">1.47</value>
      <value type="double">1.49</value>
      <value type="double">1.52</value>
      <value type="double">1.55</value>
      <value type="double">1.58</value>
      <value type="double">1.6</value>
      <value type="double">1.63</value>
      <value type="double">1.65</value>
      <value type="double">1.68</value>
      <value type="double">1.7</value>
      <value type="double">1.73</value>
      <value type="double">1.75</value>
      <value type="double">1.78</value>
      <value type="double">1.8</value>
      <value type="double">1.82</value>
      <value type="double">1.85</value>
      <value type="double">1.88</value>
      <value type="double">1.9</value>
      <value type="double">1.93</value>
      <value type="double">1.95</value>
      <value type="double">1.98</value>
      <value type="double">2</value>
      <value type="double">2.03</value>
      <value type="double">2.05</value>
      <value type="double">2.08</value>
      <value type="double">2.1</value>
      <value type="double">2.13</value>
    </height_list_meters_as_doubles>
    <height_list_inches_as_int type="list">
      <value type="int">36</value>
      <value type="int">37</value>
      <value type="int">38</value>
      <value type="int">39</value>
      <value type="int">40</value>
      <value type="int">41</value>
      <value type="int">42</value>
      <value type="int">43</value>
      <value type="int">44</value>
      <value type="int">45</value>
      <value type="int">46</value>
      <value type="int">47</value>
      <value type="int">48</value>
      <value type="int">49</value>
      <value type="int">50</value>
      <value type="int">51</value>
      <value type="int">52</value>
      <value type="int">53</value>
      <value type="int">54</value>
      <value type="int">55</value>
      <value type="int">56</value>
      <value type="int">57</value>
      <value type="int">58</value>
      <value type="int">59</value>
      <value type="int">60</value>
      <value type="int">61</value>
      <value type="int">62</value>
      <value type="int">63</value>
      <value type="int">64</value>
      <value type="int">65</value>
      <value type="int">66</value>
      <value type="int">67</value>
      <value type="int">68</value>
      <value type="int">69</value>
      <value type="int">70</value>
      <value type="int">71</value>
      <value type="int">72</value>
      <value type="int">73</value>
      <value type="int">74</value>
      <value type="int">75</value>
      <value type="int">76</value>
      <value type="int">77</value>
      <value type="int">78</value>
      <value type="int">79</value>
      <value type="int">80</value>
      <value type="int">81</value>
      <value type="int">82</value>
      <value type="int">83</value>
      <value type="int">84</value>
    </height_list_inches_as_int>
  </object>
</library>

To set up a random height:

player.height_as_int = height_object.height_list_as_int[GetRandomInt(0,ListCount(height_object.height_list_as_int))]

To Set up US or metric:

//msg (player.height_as_int)
game.myScript => {
  msg ("Are you an American?<br/><br/>You must enter YES or NO.")
  JS.setInterfaceString ("TypeHereLabel", "ENTER YES OR NO")
  get input {
    result = LCase(result)
    result = Mid(result,1,1)
    msg (result)
    if (result = "y") {
      player.height_displayed = height_object.height_list_displayed_US[player.height_as_int]
      msg(player.height_displayed)
      msg(player.height_as_int)
    }
    else if (result = "n") {
      player.height_displayed = height_object.height_list_displayed_meters[player.height_as_int]
      msg(player.height_displayed)
      msg(player.height_as_int)
    }
    else {
      invoke (game.myScript)
    }
    JS.setInterfaceString ("TypeHereLabel", "Type here...")
  }
  
}
invoke (game.myScript)

IncreaseHeight

msg ("Current height: "+player.height_displayed)
msg ("Increasing...")
if (player.height_as_int = ListCount(height_object.height_list_as_int)) {
  msg ("You are already the maximum height.")
  return (false)
}
else {
  player.height_as_int = player.height_as_int+1
  if (player.american) {
    player.height_displayed = height_object.height_list_displayed_US[player.height_as_int]
  }
  else {
    player.height_displayed = height_object.height_list_displayed_meters[player.height_as_int]
  }
  msg ("Current height: "+player.height_displayed)
}

DecreaseHeight

msg ("Current height: "+player.height_displayed)
msg ("Decreasing...")
player.height_as_int = player.height_as_int-1
if (player.height_as_int = 0) {
  msg ("You are already the minimum height.")
  return (false)
}
else {
  if (player.american) {
    player.height_displayed = height_object.height_list_displayed_US[player.height_as_int]
  }
  else {
    player.height_displayed = height_object.height_list_displayed_meters[player.height_as_int]
  }
  msg ("Current height: "+player.height_displayed)
}

If anyone sees any discrepancies, please let me know


By the way, I didn't type all that out. I ran this, then copied the text from the game's save file:

i = 0
inches = NewStringList()
game.height_list_US = NewStringList()
game.height_as_int = NewList()
game.height_list_US_doublestrings = NewList()
game.height_displayed_metric = NewStringList()
game.height_meters = NewList()
game.height_inches_as_int = NewList()
while (i < 12) {
  list add (inches, ToString(i))
  i = i + 1
}
j = 0
for (i, 3, 6) {
  foreach (inch, inches) {
    list add(game.height_inches_as_int, i*12+ToInt(inch))
    list add (game.height_list_US, i+"' "+inch+"\"")
    list add (game.height_list_US_doublestrings, i+"."+inch)
    list add (game.height_as_int, j)
    player.height = i+"."+inch
    feet = i
    inchesnow = ToInt(inch)
    a = floor((feet)*30.48)
    b = ceiling((inchesnow)*2.54)
    s = round(a+b)/100 + " m"
    meters_int = round(a+b)/100
    list add (game.height_displayed_metric, s)
    list add (game.height_meters, meters_int)
    j = j+1
  }
}
list add (game.height_list_US, "7' 0\"")
list add (game.height_list_US_doublestrings, "7.0")
list add (game.height_as_int, ListCount(game.height_as_int))
list add (game.height_displayed_metric, ToString(round(floor((7)*30.48))/100) +" m")
list add (game.height_meters, round(floor((7)*30.48))/100)
list add(game.height_inches_as_int, 84)
create ("height_object")
height_object.height_list_displayed_US = game.height_list_US
height_object.height_list_as_int = game.height_as_int
height_object.height_list_US_doubles_string = game.height_list_US_doublestrings
height_object.height_list_displayed_meters = game.height_displayed_metric
height_object.height_list_meters_as_doubles = game.height_meters
height_object.height_list_inches_as_int = game.height_inches_as_int


(I'm bored this morning.)


I have thought about sizing differences between countries and use body parts for length to describe objects.
It's about the size of your fist.
It's as long as your arm.
or
It is several stories high.
It rises into the sky.
or
Down the road a ways.
After a short distance.
or
After an hour of walking.
After walking most of the morning.
After walking most of the day.
or
Your a tall lanky bastard with red hair. (height)
Your so fat, in school you sat next to everybody. (weight)

I have avoided any local measurements in-game to make all players comfortable. (well, those last two might be a bit overboard in terms of comfort.)

It would be cool to have a conversion function if one needed it.


These are the functions used in the game I'm referencing. (This library is not even included. I created it after the fact.)


Pixie wrote the first function, and I butchered it a little to make it play well with something else in said game.

  <function name="GetHeight" type="string">
    //Function modified by KV
    SetHeightAsInt
    height_in_inches_list = Split(player.height, ".")
    feet = height_in_inches_list[0]
    feet = ToInt(feet)
    inches = height_in_inches_list[1]
    inches = ToInt(inches)
    a = floor((feet)*30.48)
    b = ceiling((inches)*2.54)
    s = floor(feet) + "' " + floor(inches) + "\"(" + round(a+b)/100 + "m)"
    return (s)
  </function>
  
   <function name="SetHeightAsInt"><![CDATA[
    //Function added by KV
    //Called by GetHeight
    //msg("DEBUGGING: "+height.list)
    player.height_as_int = IndexOf(height.list, player.height)
    if (not HasAttribute(player, "height_as_int")){
      error ("SOMETHING WENT WRONG WITH SetHeightAsInt!")
    }
  ]]></function>

I have avoided any local measurements in-game to make all players comfortable.

This is very wise!

>X ROPE
It is made of Longbottom hemp, and its length is about three times your height.

>X TREE
The mighty Oak towers above you, protruding into the clouds. You have no clue as to how tall it truly is, but it's lowest branch is about twice your height from the ground.


Log in to post a reply.

Support

Forums