Display block command [SEARCH-COMPARE]

    Joined
    Jul 30, 2013
    Messages
    398
    Reaction score
    282
    • Wired for Logic Gold
    • Legacy Citizen 8
    • Purchased!
    Currently, we can "compare" if two or more display blocks contain the same written text, this is very useful, but we also need the "search-compare" command.
    This means, if we have a sample text, it search if in another ( or more ) display block, it contain that sample text.

    1º display block "master": [SEARCH]starmade
    2º display block : starmade is fun
    3º display block : is fun play this game

    Sensor block detect 2º display block and not 3º, because the sample text of "master" is "starmade", and it´s written in the 2º and not in the 3º.

    This can be very usefull when you want detect only if a text is present in one ( or more ) display blocks, instead of detect if the text is the same.
     
    • Like
    Reactions: Lone_Puppy
    Joined
    Mar 31, 2015
    Messages
    281
    Reaction score
    95
    • Purchased!
    • Legacy Citizen 5
    I mentioned [search] tag in Displays connected to Rail/Rail docker to send commands to/from docked entities & beamed logic block

    Which is a little different that what you're suggesting. Since the [search][/search] would actually allow for multiple tests on the same display block. The idea here was for a way a docked ship and station could send commands back and forth. The beauty of a search for a key on linked displays vs. beamed logic, is, if a station doesn't recognize a command, it would simply be ignored and not break anything (such as an "undock" or "unload" command).

    Also see: Radios + Display which could make use of a [search] tag to send messages and commands to everyone, or factioned entities fleets.
     

    NeonSturm

    StormMaker
    Joined
    Dec 31, 2013
    Messages
    5,110
    Reaction score
    617
    • Wired for Logic
    • Thinking Positive
    • Legacy Citizen 5
    Do you mean something like this?
    master : "[ENABLE]starmade"
    display : "starmade is fun" = logic bit enabled because it contains "starmade"
    display : "fun to play" = logic bit disabled because it does not contain "starmade"​
     
    Joined
    Mar 31, 2015
    Messages
    281
    Reaction score
    95
    • Purchased!
    • Legacy Citizen 5
    Or you could go with my suggestion with search tags:

    [search]:sometext:[/search]

    If ":somettext" appears anywhere in the display, then the compare result is true, rather than matching the entire contents of the display. This would allow multiple logic commands to be put on a single display--which would be very useful for the linked displays via docking rails that would allow a ship and docked entity to send and receive multiple commands, like undock, offload cargo, onload cargo, etc.
     
    Joined
    Sep 9, 2013
    Messages
    68
    Reaction score
    10
    • Legacy Citizen 3
    I agree with OP, a [SEARCH] of some sort would be great

    In the meantime you can do something like:

    *Edit: Scroll down to see better solution from Jaaskinal*

    Copy the display module's content,
    run regex on that module:
    [REPLACE]\b(?!starmade\b).*?\b[WITH]
    (replaces anything that isn't the word "starmade" with null)
    Then compare the modules.

    Note*- There's a problem here. If the module has the word "starmade" twice+, it wont work because the result will be starmadestarmade. - I - couldn't fix it cuz i'm dumb right now. - Hopefully someone smarter than me will fix it? <3.

    <rant> Before we get a [SEARCH] I think something to let us get at the variables in the modules is far more important Like Display Module - [PARSE]!. </rant>
     
    Last edited:

    NeonSturm

    StormMaker
    Joined
    Dec 31, 2013
    Messages
    5,110
    Reaction score
    617
    • Wired for Logic
    • Thinking Positive
    • Legacy Citizen 5
    Maybe we should check if regex can handle all operations PHP or java can do on strings.

    If some functions are not possible with regex, we might list them to give schema a checklist.
    It would be a great community asset to have a similar function-list for SM.
     
    Joined
    Jul 30, 2013
    Messages
    398
    Reaction score
    282
    • Wired for Logic Gold
    • Legacy Citizen 8
    • Purchased!
    Fellow Starmadian Is working on creating a fantastic reference of the different uses of regex commands, different applications and uses. If anyone has any doubts or find something useful, I hope everyone who has knowledge, share it with the rest of the community. Personally, I will contribute as much as I can.

    Link to Fellow Starmadian regex post
     
    Joined
    Sep 9, 2013
    Messages
    68
    Reaction score
    10
    • Legacy Citizen 3
    Jaaskinal Posted a far better solution than what I was trying to do.

    1: Copy the original statement onto a second display block.
    2: Use "[REPLACEFIRST]regex[WITH]temp" on the second display block.
    3: Use a sensor to determine if they are the same.
    4a: If they are the same, the text did not contain "regex".
    4b: If they are not the same, the text contained the word "regex", output "regex" onto another display block.