Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

Question about item ID's.

Discussion in 'Programming Questions and Suggestions' started by Johnny_Devo, Feb 6, 2015.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. Johnny_Devo Trainee Engineer

    Messages:
    64
    For each item, what will ".Content.SubtypeName.ToString()" return?

    I'm going to make a code that will organize items, and I can really shorten it if I simply name cargo containers based upon what the code uses.

    So, for example, will an iron ore inventory slot return the string "Iron Ore" or are there differences? Is it simply exactly what it shows you in game? "Silicon Wafer" "Gold Ingot" "Steel Plate" etc?
     
  2. Phoera Senior Engineer

    Messages:
    1,713
    Test on one item(print to beacon)
    all other the same.
     
  3. JoeTheDestroyer Junior Engineer

    Messages:
    573
    I posted a list of the vanilla items in another thread.

    The string on the left is .Content.TypeId.ToString() with the "MyObjectBuilder_" prefix removed (e.g. "Ore" instead of "MyObjectBuilder_Ore"). The second string is .Content.SubtypeName (which is already a string, btw).

    As you can see, just using Subtype won't work as the game uses "Iron" for both iron ore and iron ingots.
     
  4. Johnny_Devo Trainee Engineer

    Messages:
    64
    So if I were to do something like...

    Code:
    (CheckedInventorySpot).Content.SubtybeName + (CheckedInventorySpot).Content.TypeId.ToString() 
    
    Would it be a unique string "IronIngot" or "CobaltOre"?

    Or does it return "IronMyObjectBuilder_Ingot" or "CobaltMyObjectBuilder_Ore"?

    If the latter, is it always a prefix of "MyObjectBuilder_"? Is there a way to remove this prefix?
     
  5. Phoera Senior Engineer

    Messages:
    1,713
    it eill retutn MyObjectBuilder_Ore
    Type contains main type, ore or ingot.

    also experiment with Content.ToString
    it will end like ***Ingot/Iron and you can get what you need.
     
  6. JoeTheDestroyer Junior Engineer

    Messages:
    573
    Yes.
    Code:
    .Content.TypeId.ToString().Substring(16)
    should get rid of the prefix.

    ---

    Just straight concatenating the two type names like you suggest will give cumbersome names to all the other items types, though (e.g., "Missile200mmAmmoMagazine"). You may want to just special case the ambiguous names.
     
  7. Johnny_Devo Trainee Engineer

    Messages:
    64
    Did testing, and all the ingots and ores do indeed return a unique ID that I can use in my naming convention to make the code shorter.

    For edge cases, I can also do a conditional branch before the item is moved. "If ....Contains("PhysicalGunObject") || ....Contains("AmmoMagazine") || ....Contains("Component")" covers every item that is not an ore or an ingot.
     
Thread Status:
This last post in this thread was made more than 31 days old.