@Nahim_Kerman Victor, Thank you! Amazing. I will try to try this today. I will then try to code it to then see how MANY #1 (highest/lowest) there are so I can then check for any particular one so I can say “This is ONE of the top ones” vs “This is THE top one”.
Do you mean, if more than one have the same value? What I’d do is store the highest value in a “max_rel” (or somesuch) variable and then compare the relationship values to it. (Of course, you’ll then need to set the value again if some relationship value increases higher, or a relationship value decreases in a way that none are at that level anymore.)
@LiliArch Yeah. I mean if there are multiples at the top or the bottom, then I don’t think @Nahim_Kerman’s code would work to give me THE highest or THE lowest - but I think what it would return is the value of that highest and lowest, when I can then use to compare against individual ones to see if they match or not. What do you think? Is there an easier or more elegant way to code it?
Now that I remember, I hardcoded a game of dice, with 4 npc + the player, in one of my WIP. It has a way to compare winners and draws. It’s all done with choicescript.
All the code is in one of the files. You can look at it if you want to, maybe it’ll be useful for you to get inspiration, or to copy some ideas/code out of it.
Well, that depends - that code gives you the (first, if multiple) relationship that has the highest value. It’s great, if you want to know what relationship it is, and you certainly can use it to get the highest value. (I also think it doesn’t take the full advantage of being recursive, but that’s another discussion.)
But if all you need is the highest value (do you need the lowest value too, or is it just highest?) it seems a lot of unnecessary work to me? To me, it seems you could just keep track of the highest value every time you change the relationship values. Not that you don’t need to iterate through every relationship in that case too, just… not every time.
But I’d have to write some test code first for that, and I wouldn’t want to give an example you don’t need.
@LiliArch Thanks. It might make sense if I leave the realm of abstraction and explain what I am up to.
In my book you go to a museum and visit different exhibits. Each exhibit is association with a particular area of science - an Ology. Each exhibit visited raises the related Ology for that exhibit. In each hall, you are given the chance to take photos with your siblings at a limited number of exhibits. In the *choice options - when offered to be IN the photo - there are yes and no options. RIght now, if your exhibit-related Ology is HIGHER than the average then the options are (Yes, because you tend to like that type of exhibit OR No, even though you tend to like that type); I have a related one if the Ology is LOWER than the option.
What I’d like to do is replace those options if the Ology is the highest or lowest, to make it special, as in: “Of course! This one’s your favorite” or “Oh, hell no! So boring!!!”.
Does that help explain what I am looking for?
The visiting of exhibits and the taking of photos is a constant and frequent mechanic throughout the book.
Just so you know. On the dashingdon site, you can add the word /scenes/ at the end of the link of a game and it’ll show you all the files it has. Or remove it to get the playable site of it.
edit: Don’t worry. We all started there at some point anyway.
Can you please pick my jaw back up from the ground? This is awesome, and massive, and currently beyond my ability to parse it out to pull out (and adapt) just the part I need.
Oh, Thanks! I didn’t think it was that much honestly. I did all that even before doing any programming course
You should see what others have done here.
In any case.
The game rules are that every player makes a prediction: greater or lower than 1-to-20
or equal to 1-to-20
Each player turns a cup with one 20 dice and the closest one to the prediction wins. Just a simple game.
The code just randomizes the other player’s predictions (with some leeway) and randomizes the roll dice of everyone.
Then compares and gets if there is a true prediction, or if there are ties of 2, 3 or 4 players
Then also compares if there is any prediction closer that wins over the ties.
Then gets the winner and adds up the points to the score variables.
It might seem complex in the code, but once you split it into smaller parts it gets easier.
That’s like the basics of coding. Separate the functions into small chunks, then make it work with other small chunks and you can build big stuff without even knowing.
Huh. It does not work on Loudbeat’s link (or more accurately, it gives a 404). Maybe that’s some result of older vs. newer project, or did the codebase update go live already?