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.

SetValueFloat not work with IMyGravityGenerator

Discussion in 'Programming Questions and Suggestions' started by Heggikawaii, Jan 17, 2015.

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

    Messages:
    5
    My Code:

    Code:
    
    IMyGravityGenerator grav_l = GridTerminalSystem.GetBlockWithName("DroneBay_Grav_Left") as IMyGravityGenerator;
       
    ITerminalAction trr = grav_l.GetActionWithName("OnOff_On");
    trr.Apply(grav_l);
     
    grav_l.SetValueFloat("FieldHeight", 60);
     
    
    Gravity Generator turn on, but Height not change and I has error "Object reference not set to an instance of an object"
     
  2. hellokeith Apprentice Engineer

    Messages:
    335
    try SetValue<Single>
     
  3. Textor Junior Engineer

    Messages:
    775
    Should be SetValue("FieldHeight", 60);

    SetValue doesn't have a <T> version of it, only GetValue<T>() does.
     
  4. hellokeith Apprentice Engineer

    Messages:
    335
    beacon.SetValue<Single>("Radius", 10000) works fine for me. Maybe it works both ways.
     
  5. CubanCreature Trainee Engineer

    Messages:
    33
    How do you set the limits of a piston? Nothing I put in the quotes seems to work.
     
  6. Heggikawaii Trainee Engineer

    Messages:
    5
    Trying SetValue(), SetValue<Single>(), SetValue<float>()
    not work
     
  7. Heggikawaii Trainee Engineer

    Messages:
    5
    grav_l.SetValue<Single>("Height", 60);
    work. Documentation was change :rolleyes:
     
  8. hellokeith Apprentice Engineer

    Messages:
    335
  9. PaladinX333 Apprentice Engineer

    Messages:
    234
    piston.SetValue<Single>("LowerLimit", limit);
    piston.SetValue<Single>("UpperLimit", limit);
     
  10. Sensei Trainee Engineer

    Messages:
    57
    I've encountered a really frustrating phenomenon in my code.
    When I set multiple parameters of a gravity generator in a row, only the last one applies. For example, take the following code:

    Code:
    for (int i = 0; i < blocks2.Count; i++) 
                { 
                   IMyGravityGenerator setMe = blocks2[i] as IMyGravityGenerator; 
                   setMe.SetValue<Single>("Width", 5); 
                   setMe.SetValue<Single>("Height", 3);
                }
    
    If I use this code, the height will be changed, but the width will not. If I comment out the height, or otherwise remove that line, then the width will be set- but it won't be otherwise. What gives? Has anyone encountered this problem before, or perhaps found a solution?
     
  11. Devilman Trainee Engineer

    Messages:
    1
    Hello

    I had the same problem.

    You need to get the name from inside the game. Don't use the property names of the documentaion.
    Go to the control panel. If you want to change "FieldHeight" you need to write "Field height".


    Code:
    grav_l.SetValueFloat("Field height", 60);
    
    I hope it helps
     
Thread Status:
This last post in this thread was made more than 31 days old.