I have a rather strange task I need to learn how to do in Ren'py.
What I need is to convert any alphabet letters to a number and then use that number to extract a result from a List.
So what I am making has a List that has 26 separate strings in it like this example...
Now I am going to have the player input a string in answer to a quiz, and I will be extracting a single letter from that string.
example:
I then want to take the first letter of that string...
Now here's where I get lost. I need to convert
I've looked all over and have found several examples of using the ord (ordinal) command in Python but I can't get that to work within Ren'py. I'm also hitting a wall using a str to get an int and then use that on the list.
Any help would be greatly appreciated!
Thx
What I need is to convert any alphabet letters to a number and then use that number to extract a result from a List.
So what I am making has a List that has 26 separate strings in it like this example...
$ topics = ["string1", "string2", "string3", "string4", "string5", "string6", ... "string26"]
Now I am going to have the player input a string in answer to a quiz, and I will be extracting a single letter from that string.
example:
Python:
e "Do you like Dogs or Cats?"
$ answer = renpy.input("Type your answer...?")
$ answer = answer.strip()
$ answer = answer.capitalize()
e "So you like [answer]? Cool!"
$ first_letter = answer[0]
Now here's where I get lost. I need to convert
[first_letter]
to it's numeric value in the alphabet (either 0-25 or 1-26) and then use that on my topics List above to return the proper string. So, for example, if "A" was the first letter then I would want to convert that to 0 or 1 and then use it to return the proper string.$ result = topics[0]
I've looked all over and have found several examples of using the ord (ordinal) command in Python but I can't get that to work within Ren'py. I'm also hitting a wall using a str to get an int and then use that on the list.
Any help would be greatly appreciated!
Thx