Deleting all elements except for one

  • longinuspun
    10th Oct 2012 Member 0 Permalink

    What I mean by the title is that using the console, you can delete all the elements except for a specific type. For example, you only want to keep the dust on the screen so you remove all the particles except for the dust in the console. Is there already a way to do this, and if not, can it be done either in a new version, or by a combination of existing commands

  • plead-for-destruction
    10th Oct 2012 Member 1 Permalink
    @longinuspun (View Post)
    It can be done, with Lua.
  • boxmein
    10th Oct 2012 Former Staff 0 Permalink
    @longinuspun (View Post)

    -- If you want to use it as a script file:
    function allbutone(element)
    for i=1,255,1 do
    if tpt.element(element) ~= i then
    tpt.set_property("type", "none", tpt.element(i))
    end
    end
    end

    -- If you want to copy/paste it into the console:
    function allbutone(element) for i=1,255,1 do if tpt.element(element) ~= i then tpt.set_property("type", "none", tpt.element(i)) end end end



    ## Usage: ##
    allbutone(string element) -- Deletes all elements but this. Expect it to run for 2-3 seconds, might do more. It can freeze your game if the time goes over 5 seconds. Just wait it out...

    ### Example: ###
    allbutone("glas") -- Clears all but glass.
    allbutone("sand") -- Clears all but sand.