It looks like you're new here. If you want to get involved, click one of these buttons!

[EDIT]

fixed the decimal issue <<$height>>cm <<print (($height * 0.39370 / 12).toFixed(2))>> (see first comment for more info)

I am still looking for a neater way to show height in CM and in feet... but I suspect that the simplest answer will be to enter the info in Inches and then convert to feet and CM...

Incidently, is it possible to divide the inch-result by 12, then subtract that result to leave the remaining inches.

EG: 121 inches becomes 10 and 1?

I'm going to keep grinding at it... but any assistance is appreciated. I'm very new to programming and am liable to make all kinds of space-taking mistakes haha

[/EDIT]

I am trying to show a characters height ($height) and want to show a vague cm-in conversion. At least getting the right number of feet.

I'm currently using:

Height: <<$height>>cm <<print $height * 0.39370>>in

Trying to apply your <<set $var3 to Number(($var1 / $var2).toFixed(1))>> has sadly fried my tiny little brain... Programming isn't something I am that skilled with (proud to have gotten this far) but I think it should be possible to at least divide the result of the 'inches' result by 12... but then I need to limit the decimal places.

Of course, I'd love to know if there's a better way of converting these numbers.

The 'player' enters the height themselves (two inches tall? ok. if you want...) and I want to be able to use it for comparisons later (larger than, less than. print 'you hooge!' or 'puny lill playerperson!')

thanks in advance for any help

## Comments

I have a fix for the decimal issue!

Managed to McGuyver a solution from: http://twinery.org/forum/discussion/comment/12948/#Comment_12948

<<$height>>cm <<print (($height * 0.39370 / 12).toFixed(2))>>

(thanks to TheMadExile for the code)

Putting them both together might look something like the following: (assumes $height is in inches) Which should look like the following: (assuming $height is 121)

I'm sorry to say, that went a bit over my head...

I have managed to cobble this mess together:

Height: <<print (($heightin / 12).toFixed(0))>>'<<print $heightin - (($heightin / 12).toFixed(0)) * 12>>" (<<print (($heightin * 2.54).toFixed(0))>>cm)

to output:

Height: 10'1" (307cm)

I was following the examples you provided up to "′".

I confess... I'm a little unsure about truncation as well (This, I put down to a lack in vocabulary). From what I understand, it means 'shorten by deleting the end', but I am not certain.

I have been reading through the wiki and can't find much on the 'math.' function...

Is there another place I should be looking?

thank you so much for replying, even if I didn't understand as much as I wanted to.

In this case, truncating a floating point number means to return the integral part of the number by removing any fractional digits (i.e. drop any fraction, returning only the whole/integer part).

Suggested reading: JavaScript reference @ MDN. Specifically, the Math object and, even more specifically, the Math.trunc() method.

Actually, looking at some of your example code, you must be using one of the Twine 1 vanilla story formats. In that case, you probably should not use Math.trunc() since those story formats do not guarantee its existence. Instead replace it with the Math.floor() method: Which, for positive numbers, yields the same result as using Math.trunc() (one would think that it's safe to assume that the PC's height should always be positive).

I'm not using a template, but I am all but copy-and-pasting from the wiki...

These links are pretty heavy-going for me, but some of it makes sense! Thanks for the reading (and brain-melting) material. These might just keep me from making an even bigger fool of myself XD

I can't get to grips with Twine 2 and don't feel safe using it... so for now, I'm stuck in 1.4. But it seems to be suiting my learning-curve so far

(I have a question about adding 'dummy' text to a radio button. The button says "grab the gun" but the variable would be changed to "2" or something... Should I post another question, or can I pick your astonishing brain here?)

A new question would probably be better. We go off the rails plenty enough around here already.

Thankfully, I'm doing relatively well using the simpler (probably less powerful) stuff I am finding in the wiki.

Thanks for your help and patience

(I figured out the bulletpoints! Proud of myself now haha)