Sharing Some Useful Functions for Weight and Height in Story Games

HotCosmo

Just a guy
Joined
Oct 3, 2023
Posts
42
Hello! Working on my WIP, I created two functions that could be useful for story game writers that want their stories to be international. weight() and height() are simple functions that you can use to have the imperial system or the international system of measures in your game. EDIT: (Version using the international system as reference in my next post)

Code:
=== function height(feet, inch)
~ temp result = 0
{ measure == 1:
    ~ result = feet * 30.48
    ~ result = result + (inch * 2.54)
    ~ result = INT(result)
    ~ return result + " cm"

-else:
    {feet == 0:
        ~return inch + "''"
    }
    ~return feet + "'" + " " + inch + "''"

}
=== function weight(lbs)
~ temp result = 0
{measure == 1:
    ~ res = lbs / 2.205
    ~ res = INT(res)
    ~ return res + " kg"
-else:
    ~ return lbs + " lbs"
}

To let the player select, I usually use the next method, although it can be easily hidden in some initial choices.

Code:
VAR measure = 0
WHAT MEASUREMENTS SYSTEM DO YOU WANT TO PLAY WITH?
+ Imperial System (Feet and inches)
    ~ measure = 0
+ International System (cm)
    ~ measure = 1
-

Using them is really simple (maybe simpler for the people used to the imperial system because you as the writer have to use it in the code).
Code:
He was around {height(5,4)}, shorter than the rest of his teammates.
With a weight of {weight(130)}, all the rivals underestimated him.
But he had a skill that no one knew: his fingers were unusually large.
His middle finger was around {height(0,5)}.

I hope these functions can be helpful for someone. Have a nice day!
 
Last edited:
Now I want to incorporate weight or height into my WIP story.

You have inspired me to do temperature, which would fit in naturally. If I get around to that and figure out how to do it, I will reply back here with the code I come up with.
 
Hello again! I'm sick of the imperial system. I made the first version of these functions like this because the conversion is way simpler from imperial to international, but it's not working for me. I have to use a calculator each time because, although I can make the conversion in my mind, it is all foggy. They worked exactly the same.
Code:
=== function height(cm) ===
{measure == 0:
    ~ temp feet = 0.0
    ~ temp inch = 0.0
    ~ temp res_inch = 0.0
    
    ~ inch = cm * 0.393701
    ~ feet = INT(inch / 12.0)
    ~ res_inch = INT(inch % 12.0)
    
    {feet == 0:
        ~return res_inch + "''"
    }
    ~return feet + "'" + " " + res_inch + "''"

- else:
    ~ return cm + " cm"
}


=== function weight(kg) ===
{measure == 0:
    ~ temp lbs = 0.0
    ~ temp res_lbs = 0.0
    
    ~ lbs = INT(kg * 2.2046)
    ~ res_lbs = (kg * 2.2046) % 1
    
    {res_lbs > 0.5:
        ~ lbs = lbs + 1
        ~ return lbs + " lbs"
    -else:
        ~ return lbs + " lbs"
    }
    

-else:
    ~ return kg + " kg"
}
 
Back
Top