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

Get energy produce on my base

Discussion in 'Programming Questions and Suggestions' started by Maverik, Jun 8, 2020.

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

    Maverik Trainee Engineer

    Messages:
    1
    Hi ,

    I'm trying to make an energy supervision of my little base but my script dont work :

    Code:
    IMyBlockGroup power_produce;
    double energie_produite= 0;
    public void Main()
    {
      power_produce = (IMyBlockGroup)GridTerminalSystem.GetBlockWithName("energie");
      List<IMyPowerProducer> power = new List<IMyPowerProducer>();
      power_produce.GetBlocksOfType(power);
      foreach( var item in power){
    	IMyPowerProducer eolienne = item as IMyPowerProducer;
    	energie_produite += eolienne.CurrentOutput;
      }
     
      Echo("Energie produite :"+energie_produite.ToString());
    }
    Is there something wrong in my code ?

    Thanks in advance,
    best regards
     
  2. Wicorel

    Wicorel Senior Engineer

    Messages:
    1,263
    You need to use GridTerminalSystem() to get blocks

    Code:
    GridTerminalSystem.GetBlocksOfType(power);
    
     
Thread Status:
This last post in this thread was made more than 31 days old.