Computer blocks which support custom code from pre-selected functions

    NeonSturm

    StormMaker
    Joined
    Dec 31, 2013
    Messages
    5,110
    Reaction score
    617
    • Wired for Logic
    • Thinking Positive
    • Legacy Citizen 5
    X-Series (https://en.wikipedia.org/wiki/X3:_Reunion has an Scripting interface where everybody can write own scripts.

    I don't know if one of you (especially Omni and Schema) know it. It is good!



    The interface is hirachical

    • Math
    • Player

      Give credits ("__INT__ = Give the player __INT__ credits.")

    [*]Ship

    • create ("__OBJ_SHIP__ = Create a ship in sektor __SECTOR__ and position __POSITION__.")
    • move to ("__BOLEAN__ success = Let __OBJ_SHIP__ move to __SECTOR__ and position __POSITION__.")
    • ...

    [*]Station

    • create ("__OBJ_STATION__ = Create a ship in sektor __SECTOR__ and position __POSITION__.")
    • ...

    [*]Adjacent Blocks

    • general

      connected to ("__BOOLEAN__ = Is true, if __BLOCK__(default: __$THIS__) block is connected to __BLOCK_TYPE__ blocks on __SIDE__(default: __$ALL_SIDES__).")
    • count connected ("__INT__{1,2,3,4,5,6,0} = Is the number of __BLOCK_TYPE__ blocks connected to __BLOCK__(__$THIS__) block.")
    • count connected ("__INT__{1,2,3,4,5,6,0} = The number of neighbours \"__THIS__(__$THIS__)\" has with type \"__BLOCK_TYPE__(__ALL_BLOCK_TYPES__)\".")

    [*]possible +/- x/y/z block functions - require the THIS-input to not be null (filter the possiblity of null with other commands).




    The code-line/variable-number navigation is done with up/down for lines and left/right for a selection field and tab for the next one.





    Functions which may kill the game or allow cheating are not included and the editor tracks all possibilities.

    • If you take a PlexStore/Inventar item, you get a variable. If you put it into the inventar/AnotherPlexStore, you lose this variable - it is not available anymore / has 0 items / a possible value of "null"/"undefined/etc.
    • Possibilities?:

      A returned integer can have values from {{-1 to 2}, {3 to 4}} (it's an example) and shows this to the user
    • It may ask for a filter (which enters it's own range of values and set a passed? boolean to true/false) - if it gets too complex or a function does not accept some possible values, ask for adding a filter too.
    • If something is able to unset a variable or clear it's content, "null"/"undefined"/etc is added to the range of possible values of this variable. Maybe permanently if set from outside a class (use set/get filters to avoid this!)

    [*]It is validated on script-saves that everything can handle all possible values given to it. There is a last-working (blueprint) and locally a last-edited save.






    Although it might be a bit of work, it could help to create fail-safe functions.

    Computer blocks may contain such a script to which is limited to

    • allow access to some a number of variables with eventually pre-defined type
    • certain functions/categories with limited usage
    • certain execution speed (each function requires X cpuTime-units to prepare - which can be inversive recursive for ship or grid or both and is added to the docking spot's ship while active)

    These codes could be provided by a server for custom blocks.





    There could be bonus cpuTime-generation for more players on a ship and an inversive exponential one for NPC crew-members.
     

    NeonSturm

    StormMaker
    Joined
    Dec 31, 2013
    Messages
    5,110
    Reaction score
    617
    • Wired for Logic
    • Thinking Positive
    • Legacy Citizen 5
    http://star-made.org/content/movement-sensors-exclusive-or

    http://star-made.org/content/fighting-gigantism-starmade partially, if LAG would influence complex computer systems player controlled things may be good again.

    http://star-made.org/content/command-blocks-fleet-unit-control-antena-bl..., you just need antennas too.

    adding more as I find them








    As nobody posted so far, I guess this needs examples - long, but please read :D


    PlexInverter Script

    // found in Script / enable variable, Adjacent Blocks / general / connected to

    \"variablePlex\" registered as variable name.

    variablePlex = The \"Plex Inverter\" block is connected to a PlexDoor on __$ALL_SIDES__.

    // found in Script / if (else and and are automatically added) and Script / FALSE

    if variablePlex is true

    // leave empty

    else if it is false

    return FALSE

    // found in Signals / On signal, Script / Signals / activate/deactivate, Adjacent Blocks / for each

    Enable signal \"activate\", with the source refered as \"variableSourceBlock\" and do

    For each adjacent block, refered as \"variableNeighbourBlock\" do

    // found in Script / if, Script / =

    if variableSourceBlock = variableNeighbourBlock is true

    else if it is false

    Send signal \"deactivate\" to \"variableNeighbourBlock\"

    }


    1. Because For each has a probability to get executed 6 times, everything within this indentation it has a cost multiplied with 6. Itself has a cost between 20 and 30 (6 checks, 1 new variable 6 variable value changes )
    2. if has a cost of 1 or 2. Compares of the same type have a cost of 1 (cost = 12 to 18 after multiplication with 6).
    3. Send signal may has a higher cost of 5+, because it is passed to another block, requires a check if the other block can handle that signal, may create a new \"variableSourceBlock\", etc (cost = 30+ after multiplication)



    • The whole part costs about 65+ cpuUnits, which is taken before executing it (It is not possible to substract neighbour=source as the code editor is not that intelligent).



    • There might be a command Script-command which cause everything after it to only take cpuUnits everytime the script runs over it, but costs 5 itself (enough cpuTime uints? then substract)

      would reduce the cost to 20..30 + (5 + (7..8+))x -(7..8+) = 37..48 cost for only two neighbours, but about equal cost for 4 and an increased cost for 5 and 6 neighbours.





    If then each memory block array or ship size can only hold scripts of certain size or execute scripts of certain cost, it would make AI developement which fits into a ship\'s design quite a difficult task.

    • But ships would also be more unique and players more proud of a good one.
    • Some players may even learn how difficult it is to create some of the custom-code-blocks and may see which suggestions are complete nonsense before posting these, or don\'t need to make a suggestion but make it by themselves.



    If scripts are stored locally for players and only some (if any) commands/parts run on the server, it would additionally create a possibility of advancement through playing rather than advancement on a server one by one.

    • DRM (Digial right management) Dongle Blocks (similar to logbooks, but placeable) could be used to sell scripted blocks for ingame credits, if it is desired by

      schema: adding such a block
    • admins: enable the usage of it
    • community: playing on such a server





    There are a lot of possibilities and I guess it fits into the design of StarMade.