How do I convert Hex to Decimal?

0 favourites
  • 5 posts
From the Asset Store
Upgrade your game's interface with the Purple Hex UI Kit.
  • I know rojohound posted one years ago, would anyone have a project that contains the events for this?

    Example:

    W274B = 71010059

    Thanks,

    Metric

  • Basically this?

    function hex2dec(hex)
     — var num=0
     — repeat len(hex) times
     — — num = num*16+max(0, find(“0123456789abcdef”, mid(hex,loopindex,1))
    — return num

    Btw your example is odd to me. W isn’t a hex digit.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for that rojohound

    The example i gave was from a circuit ID in work where we drop the "W" to come up with the decimal.

    Im trying to get your code working via events. Im sure its easier via JS but im unable to trigger/display the results in a text box that way (cant do JS :D )

    Il keep messing around with it.

    Thanks Rojo, always helpful!

  • I got this work work by adding -1 to the repeat event.

    len(hex)-1

    Thanks again Rojo!

  • Basically this?

    function hex2dec(hex)
    — var num=0
    — repeat len(hex) times
    — — num = num*16+max(0, find(“0123456789abcdef”, mid(hex,loopindex,1))
    — return num

    Btw your example is odd to me. W isn’t a hex digit.

    Hello R0J0hound I found this comment of yours 9years ago

    Another interesting idea would be to use

    http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm

    The idea is to use an array to store the direction to move for every spot to get to the target with the shortest distance. It's just as easy to have more than one target so it's good for many objects that need to find a path to the same set of targets.

    So after the array is calculated objects can move to the closest target by just referencing the direction of the square it's currently on.

    https://dl.dropboxusercontent.com/u/542 ... eSpot.capx

    In the example I made the objects accelerate toward the direction instead of just setting the direction. The result was nice rounded turning.

    It caused a stall if I calculated the array all at once, so I adjusted it to only calculate a bit at a time.

    the dropbox link is broken again :( may I ask for a fixed one if possible? thankyouuu

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)