Quote:
Argh, I also got confused as to which parts in the first bit of code I should be changing, based on what items have points allocated to them. :c I left them as 'Person A,' etc. since I wasn't quite sure about it. Would I be changing the 'Person A,' etc. parts and the 'person_a_points' parts to something using 'hunger,' 'drink,' or 'social,' as well? Or do I leave those alone? And the person_points and people_with_highest_points parts, too. I'm not sure if those should change as items change, or if they are general terms and fit whatever items are in the list.
Variables names are names.
Keys values are values (and can be either text, numbers...).
They don't have an inherent meaning. The only words that are inchangeable are the language keywords. (
for,
in,
len,...)
I could take your code and rename everything :
Code:
python:
elements_of_harmony = {
'Apple Bloom': cutie_marks,
'Twilight Sparkle': books,
'Pinkie Pie': balloon_lollipops_streamers
}
and the code would work exactly the same way - the computer don't care for particular names : he just see you use one name for one variable, so that name is the codder access to the value stored.
Given all that, you should always use as variable names and/or as dictionary keys words that makes sense in the context of your code : here, except if i was making MLP:FiM the Visual Novel, it wouldn't mean anything (i.e. it wouldn't help the human coder understand what the variable is used for).
Quote:
Is there a way to set the display of a result to be completely different, and not show 'You picked [result]?' I guess, in the example we've been using, something long the lines of saying "The sandwich was delicious," instead of just saying that they chose to eat.
Yes, yes and yes. There is a fundamental thing in coding that you must understand. Apart from using the same data, and save a few particular cases (that we'll see later, I guess)
a line of code is independant of the one that came before, nor cares for the one that will come after. Basic rule of computing. Learn it.
FOREVER.
So here, we have:
Code:
$ menuitems = [ ("I'll take a sandwich", "eat"), ("I'll rather have a glass of water", "drink") ]
$ result = renpy.display_menu(menuitems)
"You picked the option [result]."
My lesson of "don't care about any code but my own line" applies, so as far as the
ren'py.display_menu is concerned, it looks like.
Code:
# Bunch of code that may or may not have set menuitems to anything
$ result = renpy.display_menu(menuitems)
# Bunch of code that may or may use the 'result' variable
Quote:
Ah, and will the tiebreaker bit of code be able to allocate another point to the specified item, in order to make them the highest value? Or how would that work, for moving on to the next bit of story with that character?
You know what ? I'm gonna be evil and not answer that question.

If you did understand my lesson about the separate nature of codelines, you should be able to figure it out yourself. It will be your homework.
Quote:
Would it look something like this?
Code:
if len(people_with_highest_points) > 1:
renpy.display_menu (items, window_style='menu_window', interact=True, with_none=None):
$ menuitems = [ ("I'll take a sandwich", "eat"), ("I'll rather have a glass of water", "drink") ]
$ result = renpy.display_menu(menuitems)
"You picked the option [result]."
That part is all wrong.
A function call works like this : you have a function (let's call it function) that has parameters (param1 & param2, for example.)
Code:
def function(param1, param2):
#bunch of code that defines a_value from param1, param2, and other things maybe
return a_value
When in your code, you use function, for example,
Code:
$ my_result = function(2, 25)
it will execute all the code in the
def function block, but param1 will be equal to 2, and param2 will be equal to 25.
When the execution of the function blocks reaches
return a_value, it will return the value of
a_value to the original function call. Thus, once the function call is done, the line would have the same effect (to the computer) that the line.
Code:
$ my_result = a_value
but remember that the
a_value's value depends of the parameters that you have given at first.
Thus, if later I code the line
Code:
$ my_other_result = function(58, 33)
,
my_other_result will have a different value than the one you had for
my_result with 2 & 25.
Thus, in your call to renpy.display_menu(...), you must first define the values you'll pass as parameter, thus my
Code:
$ menuitems = [ ("I'll take a sandwich", "eat"), ("I'll rather have a glass of water", "drink") ]
line, and after (and only after) that, you call the function with your parameters and store it into a variable.
Hey, second homework

: try explaining those two lines in "natural language", as I did before

.
Code:
$ menuitems = [ ("The Number Five", 5), ("The Word 'blue'", "blue") ]
$ result = renpy.display_menu(menuitems)