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.

List of all methods?

Discussion in 'Programming Questions and Suggestions' started by HeavyMetall, Jan 2, 2015.

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

    Messages:
    10
    I'm not very experienced with programming of this kind, even though I learned some Java a few years ago, but I can't seem to find a complete list of all methods.

    Thing is, I found some Inventory sorting script in the workshop ( http://steamcommunity.com/sharedfiles/filedetails/?id=367386248 )
    Now I tested it, it worked (after changing it like described in the comments), but I thought "Why should I rename my container to '$iron uranium nickel cobalt platinum gold silver magnesium stone silicone' to make it sort all ores (and ingots as well) into a container, if it was possible to just call it '$ore' and another one '$ingot'?"

    I tried quite a lot in my opinion, my best try being changing the line
    Code:
    public bool CanCarry(IMyItemTerminalBlock block, IMyInventoryItem item)
    {
    return block.CustomName.ToLower().Contains(item.Content.SubtypeName.ToLower());
    }
    
    to
    Code:
    public bool CanCarry(IMyItemTerminalBlock block, IMyInventoryItem item)
    {
    return ( block.CustomName.ToLower().Contains(item.Content.SubtypeName.ToLower()) [COLOR= #00ff00]|| block.CustomName.ToLower().Contains(item.Content.TypeName.ToLower())[/COLOR] );
    }
    
    Sadly it appears "TypeName" is nothing the code can work with. It's probably just named something else, but I don't even really know where to look. The official guides seem useless in this regard. Where and how should I search? Googling for ""space engineers" IMyInventoryItem" didn't answer my question either.

    Well, and while I'd prefer to find it out myself, I also wouldn't mind if anyone would be able to help me with this little problem.
     
  2. Cuber Apprentice Engineer

    Messages:
    262
    Check out this link:
    http://forums.keenswh.com/post/file-programmable-block-api-documentation-generated-7224725
     
    Last edited by a moderator: Jan 2, 2015
  3. HeavyMetall Trainee Engineer

    Messages:
    10
    Awesome, thanks for the link. That's what I hoped to find somewhere in the official guides.

    Did not really help me yet, though. The SubtypeName part seems to be inherited from MyObjectBuilder_PhysicalObjects, which inherited it from MyObjectBuilder_base. None of them seem to contain TypeName as a simple string-.-
    For comparison: PhysicalItems.sbc (just using it as an example) is built like this:
    Code:
    <PhysicalItem>
          <Id>
            <TypeId>Ore</TypeId>
            <SubtypeId>Stone</SubtypeId>
          </Id>
          ...
    </PhysicalItem>
    
    So I thought there wouldn't be any big difference between Type and Subtype.

    Guess I'll have keep my brain rotating. Right now I think of constructing something using the class type. Ores use MyObjectBuilder_Ore, Ingots use MyObjectBuilder_Ingot... that should work, right?
    Something like "If containername == $ore && class == MyObjectBuilder_Ore"
     
    Last edited by a moderator: Jan 2, 2015
  4. reptar1025 Trainee Engineer

    Messages:
    28
  5. HeavyMetall Trainee Engineer

    Messages:
    10
    While I enjoy programming sometimes, I'm also a lazy f***. And your script does exactly what I wanted to have.

    No need to invent the wheel on my own, right? #CopyAndPasta :woot:
     
  6. Insanto Trainee Engineer

    Messages:
    20
    what library would i have to ref for the IMyItemTerminalBlock and other interfaces?
    currently working on my little project in VS which makes things a lot smoother but a little intellisense on the interfaces would be nice :)

    never mind, was the sandbox.common :p
    now i just gotta find the GridTerminalSystem definition
     
    Last edited by a moderator: Jan 4, 2015
  7. Digi Senior Engineer

    Messages:
    2,377
    That's also there under the IMyGridTerminalSystem name.

    You can use this to rename it in an IDE:
    Code:
    [COLOR= #660066]IMyGridTerminalSystem [/COLOR][COLOR= #660066]GridTerminalSystem[/COLOR][COLOR= #666600];[/COLOR]
    More info: http://forums.keenswh.com/post/guide-setting-up-visual-studio-for-programmable-block-scripting-7225319
     
    Last edited by a moderator: Jan 4, 2015
Thread Status:
This last post in this thread was made more than 31 days old.