Improving REG stylist

Results 1 to 3 of 3
  1. #1
    :l Cygnus is offline
    MemberRank
    Mar 2015 Join Date
    f425Location
    237Posts

    Improving REG stylist

    A common issue that often keeps me awake at night, is that the sinister REG stylist of Odin cheat me and my players on our REG coupons, and when they are supposed to be giving me a new hairdo, they sometimes charge me for their services without even touching my hair!
    Now, I have thought about two ways of doing this, but can't seem to get either to work.

    The first one is subtracting the player's current hairstyle from the array. I tried adding -(cm.getPlayer().getHair()); to the end of my array, but it returned an error. I'm not sure how i would add the check to the array, since it seems to be unable to read functions added to it.

    The second one is adding the check to remove the players current hairstyle from cm.setHair(hairnew[Math.floor(Math.random() * hairnew.length)]); [Math.floor....], although I'm not sure if this is a viable option...
    Any help/hints are appreciated!
    Regards, Cygnus


  2. #2
    The journey never ends. SYJourney is offline
    MemberRank
    Mar 2015 Join Date
    FrankfurtLocation
    427Posts

    Re: Improving REG stylist

    You could make a second array and only add the hairstyles to it from the old array that the player does not have.
    Or make a loop which keeps giving you random hairs until the condition (newhair != oldhair) is fullfilled.

    The second option would look something like this:

    var newhair = 0;
    do {
    newhair = hairnew[Math.floor(Math.random() * hairnew.length)];
    } while (newhair == cm.getPlayer().getHair());
    cm.setHair(newhair);

  3. #3
    :l Cygnus is offline
    MemberRank
    Mar 2015 Join Date
    f425Location
    237Posts

    Re: Improving REG stylist

    Quote Originally Posted by SYJourney View Post
    You could make a second array and only add the hairstyles to it from the old array that the player does not have.
    Or make a loop which keeps giving you random hairs until the condition (newhair != oldhair) is fullfilled.

    The second option would look something like this:

    var newhair = 0;
    do {
    newhair = hairnew[Math.floor(Math.random() * hairnew.length)];
    } while (newhair == cm.getPlayer().getHair());
    cm.setHair(newhair);
    Thank you so much! :)
    Ended up going with the second one, works like a charm!
    Regards



Advertisement