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.

Help with Merge Blocks

Discussion in 'Programming Questions and Suggestions' started by k33n, Mar 23, 2017.

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

    Messages:
    5
    I'm new to Space Engineers and interested in learning how to use the Programming Block. Though I don't have any C# skills to speak of, I am a C programmer for nearly 20 years. However, I am having trouble searching a simple example of a script in the game.

    What I'm really wanting to do right now is turn on a light whenever a Merge Block is activated. I have the Programming Block and a Timer set for 1 second ticks. Any help with guidance on how I can do this would be great. I searched http://www.spaceengineerswiki.com/Scripting_API_Documentation but I'm having trouble finding much in terms of documentation other than scatter object, member, and method lists. :\
     
  2. Laiden Trainee Engineer

    Messages:
    24
    Hi k33n, you made some progress meanwhile?
    If there's still some motivation left, im positive that a 'C' familiar will be able to adapt to C# easily. Just about the documentation - SE ingame doc is very fragmented. Apart from these forums threads and the steam official guides for basics, the best point to get updated documentation, is by exploring the SE github source. Use the search engine there.

    An advice for first step: Try to setup Visual Studio Community and add SE binaries. This will unlock IntelliSense for Ingame-Code, what make it lightyears easier. Check guides on this forum (or google) for how to configure.

    Next is to examine public properties of the MergeBlock (or its parent classes like MyTerminalBlock, FunctionalBlock...) and how to access them. One of them might be what you want. However, as far as I know, SE Ingame does not have kind of a event system, so many things lead to inefficient polling. If possible, try to do it without PB, using TimerBlock, Sensor or RemoteControl.
     
  3. Erna_Vida Trainee Engineer

    Messages:
    46
    By activated do you mean currently merged or just on? On is easy enough but I ended up finding a bit of code someone else wrote for merged, as there's no "provided" way to tell that that I was able to see
     
  4. Malware Master Engineer

    Messages:
    9,511
    If you want to learn ingame programming I would recommend to get on Keen's Discord. There's usually people there who can help with questions.

    @Laiden is not entirely correct about script efficiency. Timers and sensors can trigger scripts, meaning everything you can do with timers and sensors can be done with scripts, without any change in efficiency at all - except you can do so much more with scripts. Scripts have gotten an unfairly poor reputation because of badly written scripts which does not take into account what scripts are and how they run.

    FYI the merge block is not an easy block to start out scripting because it has a detrimental behavior on scripts by its very nature. People tend to use this block as a docking clamp, but it's not. It's name betrays its true purpose: To permanently merge two grids into one. This has direct effect on scripts, because what was once two separate ships have now effectively become one.
     
  5. Laiden Trainee Engineer

    Messages:
    24
    Hmm I'm still a bystander with the Discord phenomenon, how can we imagine the Keen Discord? A giant 24h live chatroom with masses of engineers? Dev's also there?

    @Malware Sorry, my expression was wrong. It wasn't my intention to say the scripting system would be bad or to avoid it. I was more to advice, using what Timers, Sensors, Buttons give first, before inventing PB scripts alone. In fact, ignoring power of PB wouldn't be engineering :D With combining PB and function blocks, a more Event-driven scripting can be made. However, when people need something that the system does not offer, those badly written scripts are easy to spread. The problem I meantioned, "polling" was for example when stopping a Motor-Block's rotation at absolute angle. What would you do to accomplish this? We're forced to poll it at fast rates under Timer-block's smallest 1sec time unit, arent we? Even more worse would be to poll the Merge-Blocks ON/OFF property, when instead we could link the pushbutton-action directly to the light's ON/OFF.
     
    • Like Like x 1
Thread Status:
This last post in this thread was made more than 31 days old.