# Ultimate Noob Coding

**URL:** <https://forum.choiceofgames.com/t/ultimate-noob-coding/28655>\
**Category:** ChoiceScript Help\
**Created:** [July 12, 2017, 10:33am UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655 "2017-07-12T10:33:30Z")\
**Posts on this page:** 1\
**Showing post:** 436

<div class="post-metadata">

**Author:** ![KickinTyres](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/kickintyres/32/149342_2.png) [@KickinTyres](https://forum.choiceofgames.com/u/KickinTyres)\
**Post date:** [December 15, 2019, 4:51pm UTC](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655/436 "2019-12-15T16:51:36Z")

</div>

> [@Szaal](#):
>
> My memory is a bit hazy,

If you can remember that it was ever any better, then you weren’t doing it right 😉 😛

…

And you’re correct on both counts

I like the array thing though, because its a neat way of keeping stuff together (if only in my head). So the (full) - and now tested! - way of using two arrays (and some non-array variables, just for added fun) to do the same thing _and_ handle where the stats are **equal** …

```choicescript
*comment - in the startup file
*create varNames_1 "Str"
*create varNames_2 "Agi"
*create varNames_3 "Int"
*create varValues_1 40
*create varValues_2 10
*create varValues_3 40
*create mycounter 3
*create i 0
*create remi1 1
*create remi2 0
*create remi3 0
*create highest_val_is 0

*comment - Add more remiX - and increase mycounter - if you got more variables

*comment - In Scenes File(s)

*comment set highest value and rememberID to be first value pair (at the moment, they are highest!) ... note NOT i!
*set highest_val_is {varValues[1]}
*set remi1 1

*comment start the loop
*label looper
*set i +1
*if (i < mycounter)
    *if highest_val_is < {varValues[i +1]}
        *comment if new > old add new
        *set highest_val_is varValues[i+1]
        *set remi1 i+1
        *comment Reset any earlier "ties/equals!
        *set remi2 0
        *set remi3 0
        *goto looper
    
    *elseif highest_val_is = {varValues[i +1]}
        *comment - New val = Current Highest - check whether a tie already exists
        *if remi2 !=0
          *comment - we already have a tie for high value, so remember another index/item.  
          *set remi3 i+1
          *goto looper
          *comment ----- NOTE: If you have more than 3 stats, you'd add ELSEIFs here

     
        *comment - no current tie for high value, so remember the index/item
        *set remi2 i +1
        *goto looper        
    *else
    *comment highest value is still old value - do nothing
    *goto looper

*comment --- Print To Screen
*if remi2 = 0
    Your highest value stat is: ${varNames[remi1]} with a value of ${varValues[remi1]}
    *finish
*elseif remi3 = 0
    You have two highest value stats: ${varNames[remi1]} with a value of ${varValues[remi1]} and ${varNames[remi2]} with a value of ${varValues[remi2]}
    *finish
*else
    All three of your stats - ${varNames[remi1]}, ${varNames[remi2]}, ${varNames[remi3]} - have a value of ${varValues[remi1]}.

```

So, look, I know … but at the moment, it’s probably safest if I stay indoors _anyway_🙂

Credits:  
String Stuff (“fun”, but didn’t use it): [Reverse Concatenation - #9 by CJW](https://forum.choiceofgames.com/t/reverse-concatenation/20432/9)  
Arrays: [Initialising arrays (and programming language implementation)](https://forum.choiceofgames.com/t/initialising-arrays-and-programming-language-implementation/16975)

---

_[View the full topic](https://forum.choiceofgames.com/t/ultimate-noob-coding/28655)._
