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.

Sci-Fi Four Button Panel LCD

Discussion in 'Programming (In-game)' started by Jason Back, Jul 24, 2020.

  1. Jason Back Trainee Engineer

    Messages:
    3
    Hi.
    I've searched for nearly an hour trying to find how to write text to the LCD panel on a button on the Sci-Fi Four Button Panel. I can't find how to do it in a script. The LCD panels are great for displaying what the buttons do but I want to provide some feedback on the action to the LCD screen. I've checked out the MDK API listings and echo'd all of the actions I can find but can't get any further with IMyButtonPanel.

    If anyone can point me in the right direction I would be grateful.
     
  2. oldman Trainee Engineer

    Messages:
    5
    I don't have the Sci-Fi DLC, and in the MDK doc it just shows the Sci-Fi 4-button panel as an IMyButtonPanel... so either that doc is right and this will not work, or that doc is not displaying the full type info for this type of button panel and just maybe this will work... it is worth a shot I guess.

    I'm basing it on this guide here, where the author is just grabbing the drawing surface for the LCD off of the PG block by index:
    https://github.com/malware-dev/MDK-SE/wiki/Text-Panels-and-Drawing-Sprites#the-viewport

    The PG has the following LCDs shown in its control panel:
    * Large Display
    * Keyboard

    And the author grabs the Large Display by calling:
    Code:
    IMyTextSurface _drawingSurface = Me.GetSurface(0);
    In the above example "Me" is the PG, but in your case you want to instead use a reference to your Sci-Fi Four Button Panel LCD.

    IDK if the Sci-Fi Four Button Panel LCD has a similar listing of LCDs that you can just get at by index, but if so, then you can write text the same way as is shown in that page I linked at the beginning.
    So try something like this and if it doesn't work... well I tried:
    Code:
    var lcdButtonPanel = GridTerminalSystem.GetBlockWithName("<insert name here>") as IMyTextSurfaceProvider;
    IMyTextSurface drawingSurface = lcdButtonPanel.GetSurface(0);
    
    Echo ("I have something to draw on: " + (drawingSurface != null));
    // now do your drawing or whatever
    
    Or maybe the LCD is just not yet accessible via the PG?
     
  3. Jason Back Trainee Engineer

    Messages:
    3

    Hi oldman
    Thanks a lot for taking the time to help me out. Lifetime software engineer (retired) but only a month old Space Engineer.

    I had seen that page before when playing with the programmable block but I'd only just started with SE and glazed over at it. I also had assumed that the IMyButtonPanel interface didn't have the desired functionality and I needed to get at the object behind it but failed to do so. I've been through malware's API listings and non of IMyTextSurfaceProvider inheritors is a panel but the cockpit and programmable block are. Is there another reference where you would find this information or is this simply something I should know as I learn?

    The key is the text surface, once you have that then job done. This may be obvious but IMyTextSurface.WriteString needs the LCD panel set to text and images but drawing to it requires the LCD panel set to Script.

    Thanks again
     
    • Like Like x 1
  4. oldman Trainee Engineer

    Messages:
    5
    What my suggestion worked?! :) I was just guessing that it might have a similar, but undocumented access to the LCD like we have on the PG. I suppose if it works then we should make a PR to get the MDK doc updated to reflect that the sci-fi button panel implements IMyTextSurfaceProvider... I'll maybe come back to that once I am more familiar with what all this stuff means. My info is limited to probably what you've also seen in the MDK docs. I just started messing around with programming the PG myself yesterday, and when I sat down to see what I could do today, I figured it would be a good learning experience to try and figure out your question.

    It is so cool that SE has the PG block functionality, I really hope it doesn't get deprecated, as this just adds a lot of depth to what the game is to me (gracias @Malware).

    Seems this forum is not very active and people keep pointing to the discord server. But, I rather like forums, as they preserve history for all to browse and search and read (or maybe I have it wrong and discord does this... IDK I have only used it for voice comms when group gaming). If I keep playing around with the PG then I will probably visit here now and then when I have free time.

    Have fun!
     
  5. Jason Back Trainee Engineer

    Messages:
    3
    Yes all working and I can now see status updates on the button's LCD panel. So much better as I don't like sending everything to a big LCD screen and the basic buttons I found I forgot which one did what !! It's more realistic to have the feedback local to the button.
    I have to agree on the forums and Discord. I'll check it out at some point maybe.

    A lot of the code examples I have seen are often depreciated or obsolete or access protected properties and methods so I've been struggling to find good references. It would be nice if the documentation was more comprehensive. I bought SE for less than a tenner so got the DLC to support when I became hooked.

    Cheers