====== sparticle-brush ====== A sand particle based terrain brush that can be run in the console and used to create intricate terrain patterns. ===== Examples ===== {{:ixe:tools:spartbrush_planet_large.png|A hollow planet with several layers.}} ===== Code ===== # Sparticle brush # Meant to run in the console. Add the script to your console folder as "spartbrush.irpl", # Then run it with the command "run spartbrush" # This is version 1. A more updated version may be available at https://github.com/qople/creeper-world-mods/blob/main/IXE/Console/spartbrush.irpl $speed:1.0 $count:100 $angle:"AUTO" # auto $spread:360 $minLifetime:150 $maxLifetime:180 if(mouseDelta GetMousePos >lastPos endif endif if(0 1 GetMouseButton) timer # Pick sand randomly to create cool layers index nextLayerTime lastLayerTime break endif loop # Weighted rand based on percentage through the layer layerDuration timeThroughLayer layerPortion if(RandFloat sand else sand endif GetMousePos >pos if(mouseDelta spartAngle else spartAngle endif # Make the sparticle explosion. tAngle lastPos #data{"lastPos"} #RandInt(data("maxage") Table( "sandDef" data CreateSandParticle(timer endif # Concats the number you type to the input string and updates the UI text as necessary. :AcceptInput if("Return" 0 GetKeyDown) if(currentInput @UpdateFieldText endif @ConfirmInput #SendMsg("SPARTBRUSH_TOGGLEINPUT" TableN("name" currentInput endif loop if("Period" 0 GetKeyDown currentInput endif # Special case for angle, let it be "AUTO" when A is pressed. if("A" 0 GetKeyDown currentInput endif if("Backspace" 0 GetKeyDown) currentInput endif @UpdateFieldText endif :UpdateFieldText shortName container " currentInput "" >inputField 0 >numLayers -250 >layerUiYPos 0 >layerUiXPos false TerpPaintingEnabled # Lookup table for filling in UI text Table( "speed" "Speed" "angle" "Angle" "count" "Count" "spread" "Spread" "minLifetime" "LT Min" "maxLifetime" "LT Max" "sandId" "Type" "layerDuration" "Duration" ) >varNameToUiText ListN("sandId" "layerDuration" 2) >uiBlacklist # We always need the last element with 9999999... at the end # so we never actually reach the end and try to index out of bounds or something. List(9999999) >times CreateList >lengths List(0) >sands CreateUI("spartbrush" @UI CreateTable) >result >resultString RegisterForMsg("SPARTBRUSH_TOGGLEINPUT" "ToggleInput") RegisterForMsg("SPARTBRUSH_ADDLAYER" "AddLayer") RegisterForMsg("SPARTBRUSH_REMOVELAYER" "RemoveLayer") @AddLayer Trace(@Helptext) # Toggles accepting input from the player :ToggleInput <_DATA >uiTable if(inputField currentInput "" >currentInput inputField currentInput "" >currentInput index sands[index lengths[! endif endif @BuildLayerLists keys inputField # Gets the integer value stored in the field :ValueFromField >uiName if(uiName if(layerJson "spartbrush_layer" numLayers layerUiYPos if(layerUiYPos layerUiXPos endif # Removes the last layer :RemoveLayer if(numLayers "spartbrush_layer" layerUiYPos if(screenHeight layersPerColumn -250 50 layerUiYPos layerUiXPos endif endif # Makes the layer lists :BuildLayerLists 0 1 ListN >times 0 >lastTime lastTime AppendToList loop sands[