CMND element (Not console commands)

  • Scien_Tific
    16th Apr 2019 Member 1 Permalink

    So I've been inactive for a while now, and decided to see if I could create a new element for TPT, and though it would be fun to make a command blo... erm, particle. The code isn't fully bug tested, but I'll try to update it if any bugs or other issues are found.

     

    Link to lua script: https://pastebin.com/USpG6vDB

     

    To run the code, rename it to whatever you want, put it in your TPT folder, open TPT and type "dofile("filename.lua")" in the console, where filename of course is the name you gave it. If you want it to run automatically every time you open TPT, just put it in the TPT folder and rename it to "autorun". (Remember to keep the .lua, though.)

     

    NOTE: The element does not use console commands, but instead can do only simple tasks, such as placing particles or removing them.

     

    How to use it

    • The temperature of the particle determines which command it does.
    • Life value of -1 makes it execute command once, then destroy itself
    • Life value of 0 makes it repeat the command endlessly
    • Life value of 1 makes it execute command once sparked. (Pretty mych any type of wire works, must be right next to the CMND particle.)
    • Life value of -2 allows it to be activated by other CMND particles on it's left. (Works only with the different "if" commands)
    • Tmp and tmp2 values are used for other data for the command. (Explained in further detail below.)
    • X and y values set in the tmp values are always relative to the position of the CMND particle. (Unless in the "placebox" command, where the tmp2 value is relative to the tmp value)

     

    Tmp values

    This is quite hard to explain, but I'll do my best.

    • First digit of the tmp values must be any number other than 0, unless it contains only one value. (Because otherwise any possible zeros would be removed from the front breaking the decoding algorithm. This will not be mentioned again, so please remember this detail.)
    • If the tmp value must contain multiple values, each value has it's own "reserved space" in it, meaning that if you have a value that equals 10 with four reserved spaces it would be written as 0010, and 100 as 0100.
    • Some values can also be negative. To make it negative, simply put a 1 in front of it. (Note that even if the value is positive, it still needs a 0 in front, again, due to "reserved spaces".) So if you would have the number 10 with three reserved spaces and a negativity indicator at it's front, it as a positive value would be 0010, and as a negative one would be 1010.
    • From now on, I'll be referring to the negativity indicators as n, x and y values, as, well..., x and y, and radius values as r. Their amount shows the amount of "reserved space" in the value for them. So I can more easily type out what the tmp or tmp2 value will do. Example: nxxxnyyyrrr

     

    Temp 0: "placeone" command

    • Ctype is element to place.
    • Tmp tells where to place ctype element.
      • nxxxnyyy
    • Places one of ctype element.

     

    Temp 1: "placebox" command

    • Ctype is element to place.
    • Tmp tells where corner of box should be.
      • nxxxnyyy
    • Tmp2 tells how far from the corner each side goes.
      • nxxxnyyy
    • Places a box shape of the element.

     

    Temp 2: "placeclone" command

    • Tmp tells what particle to clone.
      • nxxxnyyy
    • Tmp2 tells where cloned particle goes to.
      • nxxxnyyy
    • Clones one particle with it's values to another location.
    • If ctype is set, will only clone particles of ctype.

     

    Temp 3: "placecloneexcept" command

    • Tmp tells what particle to clone.
      • nxxxnyyy
    • Tmp2 tells where cloned particle goes to.
      • nxxxnyyy
    • Clones one particle with it's values to another location.
    • If ctype is set, will clone any type of particle except ctype.

     

    Temp 4: "ifinradius" command

    • Tmp is radius
      • r (No reserved space.)
    • Detects particles in given radius and sparks nearby METL or activates CMND to it's right if particles are present.
    • If ctype is set, will only spark/activate things if particles are of ctype.

     

    Temp 5: "ifinradiusat" command

    • Tmp is center position of radius.
      • nxxxnyyy
    • Tmp2 is radius.
      • r (No reserved space.)
    • Detects particles in given radius around a specified location and sparks nearby METL or activates CMND to it's right if particles are present.
    • If ctype is set, will only spark/activate things if particles are of ctype.

     

    Temp 6: "ifexists" command

    • Tmp is position to detect in.
      • nxxxnyyy
    • Detects a single particle in a specified position and sparks nearby METL or activates CMND to it's left if particle is present.
    • If ctype is set, will only spark/activate things if particle is of ctype.

     

    Temp 7: "datachange" command

    • Tmp is position of particle to change data of and what data to change.
      • nxxxnyyyd
    • Tmp2 is what to change data to.
      • d (No reserved space.)
    • Changes data of a particle.
    • If data to change is ctype, will change particle's ctype to CMND particle's ctype instead of the CMND's tmp2.

     

    This ended up being a much longer post than I expected.

    Edited once by Scien_Tific. Last: 16th Apr 2019