WIP: Transmute - Large-scale fully customizable Alchemy

Discussion in 'WIP and Development Status' started by Uristqwerty, Feb 16, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Uristqwerty

    I have been slowly working on this for a few days now, and feel that it is ready to show to the community here.


    Basically, what it will do, is respond to certain events by trying to find a matching block pattern, and if so, replacing some of the nearby blocks. The patterns and replacements will be fully customizable with text files, so server owners could opt for silly combinations (insta-house!), or more serious and balanced combinations (transmuting iron into gold, and then into diamond! Each step at a hefty resource cost, however...), and create exactly the reactions that they desire.


    Currently, my test/sample definition file looks like this:


    Code:
    comparison s = stone    #accepts either the material name
    comparison i = 15    #or id
    comparison g = 14
    comparison w = 17
    comparison * [find = any; replace = unchanged]    #square brackets used to assign more than one value
    pattern example
    [
        find
        [
            0 = "*iii*"
            1 = "iiiii"
            2 = "iiwii"
            3 = "iiiii"
            4 = "*iii*"
        ]
        replace
        [
            offset = "(0, 2)"
            -2="*sss*"
            -1="sssss"
            0="ssgss"
            1="sssss"
            2="sss"
            2.offset = 1
        ]
        trigger = "ignite (2, 2)"
    ]
    
    and it gets internally converted to

    Code:
    debug: 'root'
    debug: root.'pattern'
    debug: root.pattern.'example'
    debug: root.pattern.example.'trigger' = 'ignite (2, 2)'
    debug: root.pattern.example.'replace'
    debug: root.pattern.example.replace.'2' = 'sss'
    debug: root.pattern.example.replace.2.'offset' = '1'
    debug: root.pattern.example.replace.'1' = 'sssss'
    debug: root.pattern.example.replace.'0' = 'ssgss'
    debug: root.pattern.example.replace.'-2' = '*sss*'
    debug: root.pattern.example.replace.'-1' = 'sssss'
    debug: root.pattern.example.replace.'offset' = '(0, 2)'
    debug: root.pattern.example.'find'
    debug: root.pattern.example.find.'4' = '*iii*'
    debug: root.pattern.example.find.'3' = 'iiiii'
    debug: root.pattern.example.find.'2' = 'iiwii'
    debug: root.pattern.example.find.'1' = 'iiiii'
    debug: root.pattern.example.find.'0' = '*iii*'
    debug: root.'comparison'
    debug: root.comparison.'*'
    debug: root.comparison.*.'replace' = 'unchanged'
    debug: root.comparison.*.'find' = 'any'
    debug: root.comparison.'w' = '17'
    debug: root.comparison.'i' = '15'
    debug: root.comparison.'s' = 'stone'
    debug: root.comparison.'g' = '14'
    which is interesting in the sense that if the "debug root." was removed from each line (and the single quotes converted to double quotes), it would be a valid file describing the exact same thing. (The reason that whitespace and . both mean the same thing is so that it is easier on the parser, and when being written out, can look like a more sophisticated series of commands and parameters, that the code using the data can read as easily as anything else.)

    The sample pattern is tested and working (with a few shortcuts, mainly the lack of support for 3d patterns/replacements, and the inability to parse offsets at the moment, but in-game it appears to work flawlessly, despite the few shortcuts that were made because I was tired of working on the system behind it, and wanted to see the results), but since the change is instantaneous, it doesn't make for great screenshots. Just imagine a circle of iron ore blocks around a log, and when the log is lit, the iron ore becomes smoothstone and the log becomes gold ore, the corner bricks of the 5x5 square remaining unchanged.

    There is support for any complexity of pattern, replacement, or authorization (unless every block is authorized to change, a potential pattern that matches will not be used, and it will continue searching for a match) (currently, the only authorization is "always allow", making that step redundant, but expandable in the future.)

    Finally, if you think this is a great idea or a terrible idea, or have an idea for an improvement, I will try to look at it, and take your opinions int consideration.

    --- merged: Feb 17, 2011 9:08 PM ---

    Dev work, more complete. Now with pictures!

    So I got the parser more complete, and added forced-item replacement.

    Now my test file is

    Code:
    comparison a = air
    comparison s = stone    #accepts either the material name
    comparison i = 15    #or id
    comparison g = 14
    comparison w = 17
    comparison "{si}" = stone
    comparison "{si}".replace = stone
    
    comparison "{si}".replace.item = true
    comparison "{diamond item}" = 264
    comparison * [find = any; replace = unchanged]    #square brackets used to assign more than one value
    pattern example
    [
        find
        [
            0 = "*iii*"
            1 = "iiiii"
            2 = "iiwii"
            3 = "iiiii"
            4 = "*iii*"
        ]
        replace
        [
            offset = "(0, 2)"
            -2="*sss*"
            -1="sssss"
            0="ssgss"
            1="sssss"
            2="sss"
            2.offset = 1
        ]
        trigger = "ignite (2, 2)"
    ]
    pattern itemdrop
    [
        find
        [
            0 = "sgs";
            1 = "gwg";
            2 = "sgs";
        ]
        replace
        [
            0 = "*s*";
            1 = "s{diamond item}s";
            2 = "*s*";
        ]
        trigger = "ignite (1, 1)"
    ]
    pattern exampleCleanup
    [
        find
        [
            0 = "*sss*"
            1 = "sssss"
            2 = "sswss"
            3 = "sssss"
            4 = "*sss*"
        ]
        replace
        [
            0 = "*aaa*"
            1 = "aa{si}aa"
            2 = "a{si}{si}{si}a"
            3 = "aa{si}aa"
            4 = "*aaa*"
        ]
        trigger = "ignite (2, 2)"
    ]
    And everything is fully working (you will notice that replacements don't have to be single characters, and I have put them in {} to distinguish them, but the {} are not nessecary) (also that {diamond item} has a space in the node name. but since it is quoted, the space is ignored.

    Although this isn't a great pair of images, it shows the "exampleCleanup" reaction in action:

    Transmute-1.PNG

    Transmute-2.PNG
     
  2. Offline

    Gutter

    I can think of a few usage for this if you have it support .Schematics files, at least for the Replace operation. Supporting schematics for the Find operation would be amazing, but I could live with Replace only.

    In fact, this could be made into any number of "rune" based mods (all of which lack schematics)
     
Thread Status:
Not open for further replies.

Share This Page