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.

How to add an individual component to the assembler queue?

Discussion in 'Programming Questions and Suggestions' started by Erna_Vida, Mar 18, 2017.

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

    Messages:
    46
    This has probably been asked and answered, but google is giving me old posts from back when this wasn't possible as results.

    Now that the ingame programming has access to the assembler queue, how would I find/create a MyDefinitionBase to add to the production queue? Reading the API documentation hasn't really helped me much and I thought someone here may have already done it.

    For example, how would I create a MyDefinitionBase for a steel plate? Any help is appreciated!

    Edit: I've gotten as far as the below (and I can clear the queue just fine....), but I get Object Reference not set to an instance of an object exceptions on it. Note I have checked that the definition ID exists and I added the definition ID by stealing it off existing inventory items. I have tested this with the assembler running on repeat with a load of construction components to ensure its not a matter of the queue not existing:

    Code:
    if(items[j].Content.ToString().Contains("Ore") && !currItem.Equals("Ice")) {
    	currItem += " Ore";
    } else if (items[j].Content.ToString().Contains("Ingot"))  {
    	currItem += " Ingot";
    } else if (!currItem.Equals("Ice")) {
    	currItem = ConvertItemName(currItem);
    	if (!definitionIds.ContainsKey(currItem)){
    		definitionIds.Add(currItem,new MyDefinitionId(items[j].Content.TypeId, items[j].Content.SubtypeId));
    	}
    }
    Code:
    if (!buildthings && mainAssembler != null) {
    	buildthings = true;
    	Echo("Assembler " + mainAssembler.CustomData);
    	Echo("Definition: " + definitionIds["Steel Plates"]);
    	double amount = 100;
    	mainAssembler.AddQueueItem(definitionIds["Steel Plates"],amount);
    }
     
    Last edited: Mar 19, 2017
  2. albmar Trainee Engineer

    Messages:
    69
    The problem is that the MyDefinitionId you are using is an id for the item. But you need one of the blueprint. Since AddQueueItem internally doesn't handle the case where the definition id isn't one of a blueprint, this results in an "Object reference not set..." exception. I also found the following posts concerning your problem, that might help you:

     
    • Informative Informative x 1
  3. Erna_Vida Trainee Engineer

    Messages:
    46
    Exactly what I needed, thanks!

    Not an ideal solution, but one that works at least
     
Thread Status:
This last post in this thread was made more than 31 days old.