0 votes
by (360 points)

I am fairly new to Twine and I am using Harlowe 2.1.0 

In the game I am trying to make, I am trying to print the name the player gave but from end to front

At one point, I have the player to input their chosen name into $name

and then I have this:

(If: $name's length > 18 and $name's length <20)[(print: $name's 19th)]
(If: $name's length > 17 and $name's length <19)[(print: $name's 18th)]
(If: $name's length > 16 and $name's length <18)[(print: $name's 17th)]
(If: $name's length > 15 and $name's length <17)[(print: $name's 16th)]
(If: $name's length > 14 and $name's length <16)[(print: $name's 15th)]
(If: $name's length > 13 and $name's length <15)[(print: $name's 14th)]
(If: $name's length > 12 and $name's length <14)[(print: $name's 13th)]
(If: $name's length > 11 and $name's length <13)[(print: $name's 12th)]
(If: $name's length > 10 and $name's length <12)[(print: $name's 11th)]
(If: $name's length > 9 and $name's length <11)[(print: $name's 10th)]
(If: $name's length > 8 and $name's length <10)[(print: $name's 9th)]
(If: $name's length > 7 and $name's length <9)[(print: $name's 8th)]
(If: $name's length > 6 and $name's length <8)[(print: $name's 7th)]
(If: $name's length > 5 and $name's length <7)[(print: $name's 6th)]
(If: $name's length > 4 and $name's length <6)[(print: $name's 5th)]
(If: $name's length > 3 and $name's length <5)[(print: $name's 4th)]
(If: $name's length > 2 and $name's length <4)[(print: $name's 3rd)]
(If: $name's length > 1 and $name's length <3)[(print: $name's 2nd)]
(print: $name's 1st) 

I was wondering if I could shorten this or cut it down a bit,

Thanks in advance ( ^ _ ^ )/

2 Answers

+1 vote
by (62.7k points)
selected by
Best answer

Easiest way: 

(print: $name.split('').reverse().join(''))

At least if I understand correctly.

by (360 points)
Yeh, Thats actually what I wanted, Thank you ^_^ /
0 votes
by (360 points)
Nevermind this, I realised my own mistake :3 Thank you
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.