Ren'Py For i in F sake... (Solved)

GNVE

Active Member
Jul 20, 2018
635
1,118
So I'm kinda stuck and I don't see why I'm getting an unexpected result.
I got the following code which should select the next event to play.

what I expect it to do is the following:
if the currently selected tuple and the comparison are both red see which priority is the lowest number,
if the selected tuple is not red and the comparison is do nothing,
if the selected tuple is red and the comparison is not overwrite the current tuple
if neither is red select the tuple with the lowest number.
And yet it doesn't do that and I don't see why.
Python:
            temptuple = ('','red')
            priority = 100

            for i in self.store['currenttuples']:
                if i[1] == 'Red' and temptuple[1] == 'Red':
                    if priority > i[3]:
                        temptuple = i
                        priority = i[3]
                elif i[1] == 'Red':
                    pass
                elif temptuple[1] == 'Red':
                    temptuple = i
                    priority = i[3]
                elif priority > i[3]:
                    temptuple = i
                    priority = i[3]
           
            self.store['chosentuple'] = temptuple
it has the following data and as far as I can see it should select the blue event:
1713567708327.png

and yet it's outcome is:
1713567749699.png
 
Last edited:

peterppp

Member
Mar 5, 2020
461
868
So I'm kinda stuck and I don't see why I'm getting an unexpected result.
I got the following code which should select the next event to play.

what I expect it to do is the following:
if the currently selected tuple and the comparison are both red see which priority is the lowest number,
if the selected tuple is not red and the comparison is do nothing,
if the selected tuple is red and the comparison is not overwrite the current tuple
if neither is red select the tuple with the lowest number.
And yet it doesn't do that and I don't see why.
Python:
            temptuple = ('','red')
            priority = 100

            for i in self.store['currenttuples']:
                if i[1] == 'Red' and temptuple[1] == 'Red':
                    if priority > i[3]:
                        temptuple = i
                        priority = i[3]
                elif i[1] == 'Red':
                    pass
                elif temptuple[1] == 'Red':
                    temptuple = i
                    priority = i[3]
                elif priority > i[3]:
                    temptuple = i
                    priority = i[3]
           
            self.store['chosentuple'] = temptuple
it has the following data and as far as I can see it should select the blue event:
View attachment 3556617

and yet it's outcome is:
View attachment 3556623
red is not the same as Red, so last elif will be executed for first i, setting priority to 11. then for next i, nothing will execute since 11 is lower than 21
 
  • Like
Reactions: GNVE

GNVE

Active Member
Jul 20, 2018
635
1,118
red is not the same as Red, so last elif will be executed for first i, setting priority to 11. then for next i, nothing will execute since 11 is lower than 21
Thanks for the fresh pair of eyes. Don't wanna know how long I had been staring at that...
 

GNVE

Active Member
Jul 20, 2018
635
1,118
but i don't see how blue will ever be selected. shouldn't that last elif be i[3] > priority?
No, in my system 1 is highest priority and 99 the lowest (the 100 makes sure that you'll always have a true tuple selected).
If I used your suggestion it would select the lowest priority event. X > Y means X is greater then Y and A < B means A is smaller than B.
So for me I could use i[3] < priority or priority > i[3]
 

peterppp

Member
Mar 5, 2020
461
868
No, in my system 1 is highest priority and 99 the lowest (the 100 makes sure that you'll always have a true tuple selected).
If I used your suggestion it would select the lowest priority event. X > Y means X is greater then Y and A < B means A is smaller than B.
So for me I could use i[3] < priority or priority > i[3]
ok, but then why is blue lower priority than red? i understand if it's just a test...

i think it's a confusing way to code. i would check for less than, but if you think it works for you...
 

GNVE

Active Member
Jul 20, 2018
635
1,118
I went with list rules where 1 is generally the highest priority (think the 10 most profitable movies of all time, Top 100 songs of the 90's, DEFCON 1, the number 1 priority etc etc etc). it felt logical when I decided to do it. Whether to go with < or > is a matter of whatever I feel like in the moment.
 

peterppp

Member
Mar 5, 2020
461
868
I went with list rules where 1 is generally the highest priority (think the 10 most profitable movies of all time, Top 100 songs of the 90's, DEFCON 1, the number 1 priority etc etc etc). it felt logical when I decided to do it. Whether to go with < or > is a matter of whatever I feel like in the moment.
i understand that but you made blue lower priority than red which seems to indicate you aren't following your own rules

the downside with using 1 as highest priority is that you have to go to 0 and below if you must add something with even higher priority.
 

GNVE

Active Member
Jul 20, 2018
635
1,118
In theory yes, however the priority system is not the only way to determine an order. The event class allows testing of requirements. So you can say that event X needs to play before event Y is unlocked. Or that event Y needs you to be wealthy enough or not too popular or whatever. It can require certain upgrades or policies to be active even.
The events are also locked to the location class and locations can be hidden based on certain factors (e.g. the tent will become a trailer and eventually a house. A church will become an abandoned church). This makes the order of play even more clear.

To be honest the priority system is more rigid than you'd think based on the code above as 1 - 10 is for white events (very time limited events), 11 - 20 for green events (one time events) 21-30 for blue events (new repeatable events) and the rest for yellow events (seen before repeatable events)
 
  • Like
Reactions: peterppp