Jump to content
  • rsc204

    What is Hex... Numbers don't hurt me...


    So here I'd like to just very quickly explain the differences between the Decimal numbering system, you know, the one we use everyday for money, counting, calculations etc, and Hexadecimal. I suspect, few out there would have need to use the latter of those. But let's say you want to make mods for SC4, at this point Hex (short for Hexadecimal) is something you may need to understand. It's really not that complex, you just need to think differently, because in Hex, we also use letters for numbers. Rather than try to pick that apart badly, I think it's much easier to show you how that works in practise. We'll get to that, but quickly, I should explain the basics first...

    So in SC4, we have three groups of Hex IDs for every object/item used by the game. In many cases you don't need to know anything about them, lots for example are all assigned them automatically, as are BAT models. But, certain objects you might wish to create, will require a reserved range of IDs, which you must request. You will only be able to use those IDs you are allocated, but there seems to be a lot of confusion about how to use these most efficiently. For now, I'm going to attempt to simply explain this. But I hope in future to expand this tutorial a little, along with providing some useful tools to take all the complicated parts of using such IDs out of the equation.

    So let's quickly see which objects will require a dedicated ID range:

    • Game Textures for Lots or Transit Networks
    • Prop/Building or Flora Families
    • MMPs (Mayor Mode Ploppables).

    I plan to update this section with more info and links to reserve a range in due course, bear with me.

    A quick note about TGI's (ID's/IID's)

    What is a TGI? That simply stands for Type, Group and Instance. Instance IDs are sometimes referred to as IIDs.

    Type, Group and Instance numbers for SC4 are each in 8-digit Hexadecimal format. Here's an example of that:

    0x7AB50E44 - 0x01234567 - 0x89ABCDEF

    You can simply think of the three groups of eight digits as a telephone number. The game looks for an object, by "dialing" its ID number. Think of the Type, Group and Instance parts, as much like an International Dialling Code, Area Code and Local Number. Sometimes you just need the local number. Others times you'll need the Area Code as well, sometimes you need all three.

    Usually both the Type and Group IDs are set, that is to say, you have to use specific ones, depending on the type of item. So for example, 0x7AB50E44 as a Type ID, means the item should be a texture. The group ID is like a subcategory, in the case of textures, those for game networks, like NAM's roads use 0x1ABE787D, whereas Lot Textures use group 0x0986135E. But, it's the last ID, the instance or IID we're most interested in here.

    That's a unique instance for your objects. If you are provided a range, almost certainly, you will be using the IID only. One thing to mention here, each 8-digit ID above is prefixed by 0x, I should explain this before continuing. This is just the way that Hex numbers are formatted. Depending on the application used or method of entry, you may need to include it, you may not. I know that seems less than helpful, but it'll make sense when you get there. If you are having problems, always check the format, perhaps you've missed or accidentally included the prefix, either can be a potential source of trouble.

    Why Hex in the first place?

    The answer to why computers use Hex is remarkably simple, it provides orders of magnitude more "space", using the same amount of data. But rather than trying to dwell on that too much, let's jump to an example that everyone can follow.

    When you get assigned a range of IDs for the IID, you will have a "family" or multiple "families" of IIDs. Much like with our phone number example, a family is simply the first few digits that remain the same for each ID. For this section, let's assume you've been assigned the family AAAA####. Where the # characters are digits you will need to decide upon to make your unique IDs.

    Let's look at how that would work, if the last 4 digits were using a traditional Decimal system:

    • AAAA0000 - AAAA0009 = 10 Unique IDs
    • AAAA0010 - AAAA0099 = 10x10 or 100 IDs 
    • AAAA0100 - AAAA0999 = 10x10x10 or 1,000 IDs
    • AAAA1000 - AAAA9999 = 10x10x10x10 or 10,000 IDs
      (Note that these calculations are cumulative, i.e. each includes the # of IDs from the previous line in the total)

    Now, let's look at the difference, just from adding 6 new numbers, i.e. a BASE 16 numbering system or Hex. Because we only have numbers 0-9 in the real world, Hex uses A through F to represent 10 through 16, whilst only using one character. Also note that 0 = 1 in this system, which makes sense if you think about it, 0 is after all a number. Don't focus on that too much, it's not so important.

    • AAAA0000 - AAAA000F = 16 Unique IDs, no big change
    • AAAA0010 - AAAA00FF = 16x16 or 256 IDs, look at that, already we've over twice the number of IDs the decimal system would offer.
    • AAAA0100 - AAAA0FFF = 16x16x16 IDs or 4,096, now it's four times as many.
    • AAAA1000 - AAAAFFFF = 16x16x16x16 IDs or 65,536, and we're up to six and a half times the number.

    If we follow this through all 8 digits, in decimal you've have a total of:

    100,000,000 IDs

    That's a lot, but with Hex, we end up with:

    4,294,967,296 IDs

    So for the exact same amount of data or space used, Hex gives us orders of magnitude more IDs to work with. So Hex is a very useful system indeed. Now think about this, each object in the game must have a unique ID. By having so many possibilities, it greatly reduces the chances that two will accidentally end up the same. Almost every time this happens, it's not the computer, its users using IDs they shouldn't have.

    If you have an assigned range for something, use those IDs ONLY.

    If you are working on something without assigned IDs, DO NOT manually create IDs yourself unless you have no other option.
    Mathematically speaking, the odds of a randomly generated ID conflicting are infinitesimally small. You've literally more chance of winning the lottery. But people, unlike random generators, often think alike or like to use similar patterns. So if the option exists to have a random ID, use it. Almost certainly it will be better for you and the wider community. Conflicts can be a big pain to find when they do occur.

    Speaking of conflicts, actually, sometimes those are useful, we may want an ID to conflict with another. Why? Well let's imagine you want to override an object in the game or from another creator, because you've altered it somehow. If your version has the same ID, it will conflict with the original. But SC4 is smartly designed, if it notices this, it will only use the last item loaded with the same ID. I.e., SC4 will override objects where conflicts occur. The only caveats here are that the object must load later than the one you are overriding. Also that some very specific instances will not work this way. For example, that's why the I-HT fix must be DAT-Packed to work, you can't override that particular file.

    How to use Hex efficiently?

    For now I'm going to cut this here... consider this a WIP. But when I resume work on this guide, I will cover all you need to know about using a range assigned to you in the best possible way. Remember that numbers, Hex or otherwise increment from the right side. When the last digit reaches 9, instead of moving one digit left and using 10, we jump from 9-A. Then through B to F, only after F do we use 10, which is actually 17. That seems like a really complicated thing to understand. But try to remember, you don't need to know what the decimal equivalent is in most cases, you only need to input the correct IDs in order. So 9, A, B, C, D, E, F then 10, it's really quite simple when you don't focus too much on the actual decimal numbers.


      Edited by rsc204  

    User Feedback

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.


Thank You for the Continued Support!

Simtropolis relies mainly on member donations to continue operating. Without your support, we just would not be able to be entering our 15th year online!  You've really help make this a great community.

But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running, so that we can help keep bringing SimCity players together to share our creations.

Make a Donation, Get a Gift!

Expand your city with the best from the Simtropolis Echange.
Make a donation and get one or all three discs today!


By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

Each donation helps keep Simtropolis online, open and free!

Thank you for reading and enjoy the site!

More About STEX Collections