1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

How to use "IMySlimBlock" ?

Discussion in 'Programming (In-game)' started by Ghost, Jan 16, 2015.

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

    Ghost Trainee Engineer

    Messages:
    9
    I dont know how to use "IMySlimBlock".
    Can someone give me an Example?!
    I want to choose a specific block in a list of blocks. Is that possible ?

    Thanks in advance :)

    ghost
     
  2. Phoera

    Phoera Senior Engineer

    Messages:
    1,713
    what are you want to achieve?
     
  3. Ghost

    Ghost Trainee Engineer

    Messages:
    9
    for example the BuildRatio. :)
     
  4. Phoera

    Phoera Senior Engineer

    Messages:
    1,713
    Code:
            IMySlimBlock GetSlimBlockFromFat(IMyTerminalBlock block)
            {
                return block.CubeGrid.GetCubeBlock(block.Position);
            }
    
    BuildLevelRatio property of it gives percentage of build level(1=100%)
     
  5. Digi

    Digi Senior Engineer

    Messages:
    2,393
    Aren't they part of the same class hierarchy ? You could just cast it.

    Code:
    var slim = block as IMySlimBlock;

    EDIT: Ah nvm, the IMyTerminalBlock is a field (FatBlock) in the IMySlimBlock, it's not extending that class.
     
    Last edited by a moderator: Jan 18, 2015
  6. Phoera

    Phoera Senior Engineer

    Messages:
    1,713
    nope, you can't.
     
  7. Cuber

    Cuber Apprentice Engineer

    Messages:
    262
    <table><tbody><tr><td>IMyCubeBlock has a property called CubeGrid which gets its parent IMyCubeGrid.
    Sandbox.ModAPI.Ingame.IMyCubeGrid has a method called GetCubeBlock which will retrieve a IMySlimBlock residing at a location.
    I don't know if you can access Sandbox.ModAPI.IMyCubeGrid, but if you can, you can get all blocks as IMySlimBlocks by using its method GetBlocks.</td></tr></tbody></table>
     
  8. Ghost

    Ghost Trainee Engineer

    Messages:
    9
    Thank you! That was all i needed ;)
     
Thread Status:
This last post in this thread was made more than 31 days old.