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.

Succeeding lights

Discussion in 'Programming Questions and Suggestions' started by GK1119, Jan 13, 2017.

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

    Messages:
    11
    Hi there!

    Me and my friend are newbie Programmers, we have an idea which we don't know how to execute.
    We have four Corner Lights in a Line, is it possible to program them so they light up in a succeeding manor (Light#1 lights up, then #2, then #3, and last #4)? We've tried few things but none of them worked. Thanks in advance fellow Programmers.
     
  2. Forcedminer Senior Engineer

    Messages:
    2,227
    I'm almost whispering this to myself but

    .............could timer blocks be used?............

    http://www.spaceengineerswiki.com/Timer_Block

    like have a button sensor or some kind of trigger mechanism that when activated triggers
    timerblock_1 which turns Light#1 ON then activates countdown timer on
    timerblock_2 which turns Light#2 ON then activates countdown timer on
    timerblock_3 which turns Light#3 ON then activates countdown timer on
    timerblock_4 which turns Light#4 ON then activates countdown timer on


    i mean thats one way i see of doing it minus the programming.
     
  3. GK1119 Trainee Engineer

    Messages:
    11
    Yea, forgot to tell that we'd like to skip excessive Timer Blocks :p
     
  4. Wicorel Senior Engineer

    Messages:
    1,262
    When do you want them to light up in sequence?

    There is a delay in the light itself..
     
  5. GK1119 Trainee Engineer

    Messages:
    11
    S - sensor
    L1 - light one etc.

    Example map (seen from above) :
    S L1 L2 L3 L4

    So I step on sensor - the L1(On), after 1 sec L2(on), next sec L3(on), next sec L4(on), and I would like them so stay lit.
     
  6. thekingmen Trainee Engineer

    Messages:
    17
    Hi!
    I have a big project to program in space engineers and I am just starting. I looked at your thread and it seemed like a good opportunity for an example/tutorial to help me learn it. So I have made a script that does what you asked.
    the script is here.


    It is quite basic, I let you handle the saving/reloading the state when reloading the game if needed. To use it, create a programmable block and paste that script to it. In the top near, replace Light1 and the other with the name of your light from the control panel. Then simply create a timer block and set it to whatever delay you would like. In it's script action, run the programmable block with nothing as an argument, and add the timer block Start, so that it reactivate itself in past the delay.
    In your sensor action, simply use Timer.Start if you wait to wait for the delay, or timer.Trigger Now.
    Your light will light up based on the order they were added to lightList.

    Note that I used a helper library ZACommon. It simply add some helper to the ingame programming api. I don't like the official api - make me lose time and takes more lines of code, so I used helper to do some work more easily. Up to you to use it or not.
    Helper from ZeroAngel scripts.
    https://github.com/ZerothAngel/SEScripts
     
Thread Status:
This last post in this thread was made more than 31 days old.