TPT Script Server

This page is used for previewing and submitting scripts for use with the Script Manager

Available Scripts

(2) TPTMulti by LBPHacker
(3) set wifi v2 by jacob1
(4) Script Paste by jacob1
(5) Random Element by jacob1
(6) Magical Merge Master 3000 by nucular
(7) More Fuel Mod-heavy by jward212
(9) Breakpoints (BRPT) by boxmein
(10) Cockroaches! by boxmein
(11) Random tree by ssccsscc
(12) Element with random properties by ssccsscc
(15) Minimalistic Element Dehider by nucular
(16) FPS Gauge by mniip
(17) TPT Radio by jward212
(18) Print Debugger by FeynmanLogomaker
(19) Powered BHOL by jacob1
(20) Light and lamps by electronic_steve
(21) Extremely Durable TTAN by QuentinADay
(22) New Buttons by QuentinADay
(23) Pure Energy by QuentinADay
(25) RCA's HUD XV Update I by RCAProduction
(27) 123456787654 vols by mjpowder
(28) Singularity Bomb by QuentinADay
(29) ES wifi set by electronic_steve
(30) Lua Elements Pack by FeynmanLogomaker
(31) stkm gun by jward212
(32) space building materials by kjack1111
(34) Rust bomb by Damian97
(35) Simple command block by ssccsscc
(36) Everlasting Fusion by QuentinADay
(37) Screenshot Organiser by mecha-man
(38) Napalm mod by cccp3
(39) Rocket fuel mod v0.15 by cccp3
(41) Useful web links by jward212
(42) TPT Logic Gates Mod by iamdumb
(43) ESTools by electronic_steve
(44) Head Crabs-HL2 by jward212
(45) Procedural Save Generator by boxmein
(46) smooth colours for nametag by jward212
(47) ZAKPACK by zak03
(49) Performance Monitor by FeynmanLogomaker
(51) Texter by byzod
(52) Texter default fonts by byzod
(53) Schicko's Font Pack for Texter by Schicko
(54) Realistic Element Names by Atomic10
(55) TPT's Mod V.3 Update 1 by Amy
(56) Temporaryaccount-Decorator by Temporaryaccount
(57) random save loader by jward212
(58) Tmp gradient display by ssccsscc
(59) particle re-orderer by mniip
(60) Electric Glow by jacob1
(61) More Fuel Mod-lite by jward212
(63) Rythidium by janekbe04
(64) Simple FPS GUI by Sfsjunior
(65) Enhanced Element Dehider by ChargedCreeper
(66) Graph of average temp by ssccsscc
(67) Template save loader by jacob1
(68) Lua Text Generator by jBot-42
(70) Pixel's Freezer by Pixelguru26
(71) Thingy | Fusion For Ever by TheChosenEvilOne
(72) op explosions by zolly_bro
(73) Scar by DorkyBobster
(74) ScreenShotMod by lill74
(77) Useful Things by TheEvilChosenOne
(78) Alchemy Mod by _MrN_
(79) Nuke v2 by Fnaf65
(80) Compressor mod by TheChosenEvilOne
(81) Custom Render Mode Loader by jacob1
(82) Spacewars by JosephMA
(83) MOAR - Alpha 0.1 by TheChosenEvilOne
(86) Element Creator by cxi
(88) Soapworm by LBPHacker
(90) Pressure Bomb by God_Kra
(91) SMFB by wntjq69
(92) Potato by cxi
(93) Subatomic Pack (BDS) by TPT_PL
(94) Acidic Pack (BDS) by TPT_PL
(95) Starbound Building Materials by Sanpypr
(96) Factory problems by TPT_PL
(97) Gamma Ray-diation by Kostia4381
(98) Magic by livingfossil
(99) Cross-window Copy/Cut/Paste by LBPHacker
(100) Langton's Ant with variations by LBPHacker
(101) Remote particle creator/deleter by TPT_PL
(102) Force fields by electronic_steve
(103) Reinforced Concrete by 12Me21
(105) TPT_PL's Lua Mod by TPT_PL
(106) Nuke v4 by Fnaf65
(107) CHEMMOD V1 by KevAK
(108) Chemicals by Ligan
(109) VonDaniel's Template by VonDaniel
(110) The Inaccurate Radioactivity Toy Mod by TuDoR2007
(112) textmonsterPack by textmonster404
(113) Meteor by TheScienceKid
(114) Tgpm by TuDoR2007
(115) Civilizations by TPT_PL
(116) RAD-MOD 1.2.1B by Kev_AK
(117) MicroLua by RamiLego4Game
(118) Extra customizable HUD by djy0212
(119) Ingame brush editor by ssccsscc
(120) Window Maker by Paul_31415
(121) CHEM-MOD V1.2B by Kev_AK
(122) Rainbow PHOT by Mrprocom
(123) stronger stickmanv by yuval
(124) 3D Pressure Visualizer by mniip
(125) Arkadian Liquid by JanKaszanka
(126) Fuel by nukers473
(127) Immersive Radioactivity v2.1 by Potbelly
(128) ElementLaunchingTool by juh9870
(129) CHEM-MOD_v1.2.2b by KevAK
(130) Slingshot by Mrprocom
(131) Perlin Noise Generator by DoubleF
(132) Element Replace by TomW1605
(133) Flooder V2 by TheAwesomeMutant
(134) Link Sign GUI by QuanTech
(135) Element dehider by 4e616d65
(136) Subphoton ROM Builder by mad-cow
(137) Hardened Dust by Liftski
(138) Bio-Vir by TheAwesomeMutant
(140) Orbit Simulator by Mrprocom
(141) johnnyou's Font for Texter by johnnyou (49796346)
(142) auto_wifi by phisically
(143) Layering helper by ssccsscc
(144) Layering Helper Extended by LuaMaster
(145) TPT Remade by TuDoR2007
(146) All-seeing sampler by djy0212
(147) Layering helper remastered by ssccsscc
(148) Eraser by thepowdertoy12
(149) EXPLOSIONS by olix3001
(150) Simple rocket fuel mod by ArseniyPlotnikov2006
(151) Pure Fission by Fnaf65
(154) Graph by ssccsscc
(155) Little's Pack! by LittleProgramming
(156) Lead by LoftisGaming
(157) WIFI Tuner by ssccsscc
(158) Previous Brush by TomW1605
(159) HUD Auto-Hider by Tim
(161) Stack tool by thepowdertoy12
(162) Oil and plastic by ArseniyPlotnikov2006
(163) Colored Ember by DUC
(164) Timer by ssccsscc
(165) Bacteria Mod by TuDoR2007
(166) Noise filter by LBPHacker
(167) Future-proof element dehider by LBPHacker
(168) RadioactiveNuke by DreamingWarlord
(169) Only Hot Element by DreamingWarlord
(170) Philosopher's Stone by Godhydra
(171) Conic section generator by LBPHacker
(172) Interface API by ssccsscc
(173) Metals&Materials by Ferrous26
(174) tpt.all by LBPHacker
(175) The Visual Elements Pack by Goblin01, vvv331
(176) Layering Helper Reforged by PowderNotSolid
(177) SNOWified SING by LBPHacker
(178) FPS Chart by Goblin01
(179) TPT font writer by Goblin01
(180) Simple Ruler by PowderNotSolid
(181) Heat Modifier by DreamingWarlord
(182) TPT Remade II by TuDoR2007
(183) Gravity simulator by ArseniyPlotnikov2k6
(184) Unobtainium by christheboss894
(185) TPTMIDI noteblock in tpt by djy0212
(186) DreamingWarlord's Lua Tool by DreamingWarlord
(187) Elements Tooltip by Goblin01
(189) Explodium script by 0d15ea5ebe57c0debadc0ffee0ddf00d
(190) more powered force elements by 6nop6nop
(191) Yzaak1Scifire Modpack by Yzaak1Scifire
(194) Fluor and more modpack! by galaktor
(195) Hot Powder by lieve_blendi
(196) Star by TUANMINHVIETNAM
(197) Heat Powders by lieve_blendi
(200) Tangeriinium (thx 2 cxi 4 code) by LostEditor
(201) Freezer by lieve_blendi
(202) Powder Power! by TPTSortaGuy
(203) PowderPlus v1.4 by PowderPlus Team
(204) fire by ME
(205) Stacked Goo Animations by Maticzpl
(206) Stickman Control for Android Version by PhauloRiquelme
(207) Spark Removal Button by Xyz
(208) More HEAC's! by Maxhd1234
(209) Immersive Radioactivity v3.0 by Potbelly
(210) Subframe Chipmaker Script by Maticzpl
(211) Realistic Propellants by ArseniyPlotnikov2k6
(212) Mass Equals Gravity by Maticzpl
(213) PhiMod v1 by ArolaunTech
(214) PC Controls for Android by Cracker1000
(217) Single-pixel pipe configurator by LBPHacker
(218) Omega Death Laser Gun by Dogeoum
(219) Notifications by Maticzpl
(221) Powderizer by ArolaunTech
(222) ElemDehider 1.2 by Inventor70
(223) Unobtainum V2 by DoomKittyAttack
(224) Organics Mod v0.2B by PowderPlus Team
(225) Gravity distortion by Avolte55
(226) tmp Wifi by PhauloRiquelme
(227) Alchemagica Mod v1.0 by RebMiami
(228) Fan Elements Mod by RebMiami
(229) Impossibilities by ArolaunTech
(230) Realistic Explosives by ArseniyPlotnikov2k6
(231) libactivation by anamorphic
(232) Alloy Brushes by Maticzpl
(233) Gravity bender by pres
(234) Slow Tick by Pixel
(235) Paste ID by Maticzpl
(236) many things by jadenflp2
(237) Territect by Rebmiami
(238) Better Descriptions v1.0.5 by ashyboi2022
(239) LIGHTNING SPRK by GOLmaster10101
(240) Small Bombs by juh9870
(241) Save Shop by aaccbb
(242) Moving solids v1.3.0 Beta by ArolaunTech
(244) Alchemistry by rdococ
(245) ETRD (Formerly PowderIM) by aaccbb
(246) RadonX by Justadirtblock
(248) Water-X by deuterium_oxide
(250) Indestructible INSL by CheekyRand0m
(252) Console's Mod by Console/Compec
(255) Slow motion by LBPHacker
(256) Powered Repeller by Hythonia
(257) Zeta's Electric Tools. by Zetalasis
(258) Azure serum (AZSR) by ALumpOfPowderToy
(259) COLORFULSAND by xert
(260) Lightning Circle by defaultuser0
(261) Powder Future Tech by JonaHungary
(262) TPTGlowingSolids by DestinyDyson
(263) Volcano Bomb by I_am_the_NugsWorld
(264) Neon Lights by Rebmiami
(265) Radioactive Materials by xyz
(266) Eater mod by VIPERGAMEZ
(267) the biology mod by someone
(268) Atomic Physics by qe
(269) Pure Radiation by ronansb
(270) Fake Elements by That_PowderToy_Guy
(271) Tachyons and MISC by RamenNoods
(272) Exotic Particles by rdococ
(273) FPS Slider by aaccbb
(274) Enphosian's Radioactive mod pack by Enphosian
(276) ROM Builder by QnpfvTPz
(277) acb's Idea Generator by aaccbb

+ Submit new script!

Title: Author:
Script:
--PC Controls for android script (Thanks to jacob1 for helping with fan wall tool.)
local version = 5.0 --Internal version for update checks and stuff.
local timermotd = 0
local req2 = http.get("https://pastebin.com/raw/7JPWsa4a") --Link where it checks for updates

--Updater for script
local function checkforupdates()
timermotd = timermotd + 1
if timermotd >= 250 then
event.unregister(event.tick,checkforupdates)
print("PC Controls script: Unable to check for updates..")
end
if req2:status() == "done" then
local ret2, code2 = req2:finish()
event.unregister(event.tick,checkforupdates)
if code2 == 200 then
if tonumber(ret2) > version then
interface.beginConfirm(" PC Controls Update check","Update v."..tonumber(ret2).." available for download, click update to continue..","Update",
function (result)
if result then 
platform.openLink("https://powdertoy.co.uk/Discussions/Thread/View.html?Thread=26505")
end
end)
else
--print("PC Controls script: You are running the latest version.")
end
else
print("PC Controls script: Unable to check for updates, please check network connection on your device..")
end
end

end
event.register(event.tick,checkforupdates)

--Window button
local function drawqolbutton()
gfx.fillCircle(14,175,8,8,10,10,10,255) -- Dark background
if tpt.mousex > sim.XRES and tpt.mousey > 129 and tpt.mousey < 160 then
gfx.fillRect(613,130,29,29,32,216,255,200)
gfx.drawText(550,140,"PC Controls",255,255,255,255)
else
gfx.fillRect(613,130,29,29,32,216,255,100)
end
gfx.drawRect(613,130,29,29,32,216,255,255)
gfx.drawText(622,140,"PC",32,216,255,255)
end

local brushmenu = Window:new(240, 90, 347, 230)
-- Register clicks for the qol button
local function clickqolbutton()
if tpt.mousex > sim.XRES and tpt.mousey > 129 and tpt.mousey < 160 then
ui.showWindow(brushmenu)
return false
end
end

event.register(event.tick,drawqolbutton)
event.register(event.mousedown,clickqolbutton)

local drawcoordstatus = "0"
local x1, x2, y1, y2 = 0,0,0,0
local orig_x1, orig_y1, used_zoom = 0, 0, false
local perfval = 0

--Define various buttons
local button1 = Button:new(10,35,50,24, "Circle", "Circular brush.")
local button2 = Button:new(70,35,50,24, "Rectangle", "Rectangular brush.")
local button3 = Button:new(130,35,50,24, "Triangle", "Triangular brush.")

--Tools
local button7 = Button:new(250,35,40,24, "Flood", "Flood fill.")
local button12 = Button:new(300,35,40,24, "Box", "Box tool")
local button13 = Button:new(200,35,40,24, "Line", "Line brush.")

--Modes and shortcuts
local button4 = Button:new(300,4,40,20, "X", "Closes window")
local button5 = Button:new(10,200,60,20, "Hover mode", "Disables mouse clicks.")
local button6 = Button:new(130,200,60,20, "Part count", "Enables find mode.")
local button8 = Button:new(10,165,60,20, "Debug mode", "Turns on debug mode.")
local button9 = Button:new(130,165,60,20, "Cross-hair", "Turns on coord display.")
local button10 = Button:new(260,200,60,20, "Feedback", "Displays selected element count")
local button11 = Button:new(260,165,60,20, "Draw Grid", "Toggles grid")
local button16 = Button:new(130,132,60,20, "Performance", "Toggles performance mode")

-- Simulation options:
local button14 = Button:new(10,132,60,20, "Undo/ Redo", "Adds redo, undo and other useful options")
local button15 = Button:new(260,132,60,20, "Reset Sim.", "Resets pressure, sprk and other settings.")

--Sliders
local brushheight = Slider:new(10,77,330,20,255)
local brushwidth = Slider:new(10,97,330,20,255)

--Buttons and sliders end
local drawval, boxval, findval, hoverval = 0,0,0,0
local boxstat = "0"
local linetoolstat = "0"
local floodstat = "0"
local wallid = 404 --id 404 is reserved for internal checks.
local WL_FAN = 5
local WL_FANHELPER = 6 --255 --TODO: allow 255 from Lua

local function drawcoord()
graphics.drawText(tpt.mousex-30-tpt.brushx, tpt.mousey-25,"X:"..tpt.mousex,32,216,255,230)
graphics.drawText(tpt.mousex+8+tpt.brushx, tpt.mousey-25,"Y:"..tpt.mousey,32,216,255,230)
graphics.fillRect(tpt.mousex + 1 ,tpt.mousey,8 ,1,32,216,255,230)
graphics.fillRect(tpt.mousex -8,tpt.mousey,8,1, 32,216,255,230)
graphics.fillRect(tpt.mousex,tpt.mousey-8,1 ,8,32,216,255,230)
graphics.fillRect(tpt.mousex,tpt.mousey,1 ,8,32,216,255,230)
end
local simopval = 0

local function selectedbrush()
brushheight:value(tpt.brushx)
brushwidth:value(tpt.brushy)
if ren.debugHUD() == 1 then
gfx.drawText(315,261,"ON",35,255,35,255)
else
gfx.drawText(315,261,"OFF",255,35,35,255)
end

if drawcoordstatus == "1" then
gfx.drawText(435,261,"ON",35,255,35,255)
else
gfx.drawText(435,261,"OFF",255,35,35,255)
end
if perfval == 1 then
gfx.drawText(435,227,"ON",35,255,35,255)
else
gfx.drawText(435,227,"OFF",255,35,35,255)
end
if findval == 1 then
gfx.drawText(435,295,"ON",35,255,35,255)
elseif findval == 0 then
gfx.drawText(435,295,"OFF",255,35,35,255)
end
if hoverval == 1 then
gfx.drawText(315,295,"ON",35,255,35,255)
elseif hoverval  == 0 then
gfx.drawText(315,295,"OFF",255,35,35,255)
end
if ren.grid() > 0 then
gfx.drawText(565,261,"ON",35,255,35,255)
elseif ren.grid() == 0 then
gfx.drawText(565,261,"OFF",255,35,35,255)
end
if simopval == 1 then
gfx.drawText(315,227,"ON",35,255,35,255)
elseif simopval == 0 then
gfx.drawText(315,227,"OFF",255,35,35,255)
end

--Graphics for menu.
gfx.fillRect(240,90,347,230,32,216,255,35)
gfx.drawText(313,95,"Cracker1000's PC Controls Script ver."..version,130,130,255,255)
gfx.drawText(250,110,"Brush Shape:                          Tool selection:")
gfx.drawText(250,157,"Brush size:")
gfx.drawText(388,173,"Width: "..tpt.brushx)
gfx.drawText(388,193,"Height: "..tpt.brushy)
gfx.drawText(280,210,"-----------------------------------------------------",32,216,255)

if tpt.brushID == 0 then
gfx.drawRect(248,123,54,28,32,216,255,255)
elseif tpt.brushID == 1 then
gfx.drawRect(308,123,54,28,32,216,255,255)
elseif tpt.brushID == 2 then
gfx.drawRect(368,123,54,28,32,216,255,255)
end

if linetoolstat == "1" then
gfx.drawRect(438,123,44,28,35,255,35,255)
else
gfx.drawRect(438,123,44,28,255,35,35,255)
end

if floodstat == "1" then
gfx.drawRect(488,123,44,28,35,255,35,255)
else
gfx.drawRect(488,123,44,28,255,35,35,255)
end

if boxstat == "1" then
gfx.drawRect(538,123,44,28,35,255,35,255)
else
gfx.drawRect(538,123,44,28,255,35,35,255)
end
end

function convertwallid()
--Convert wall identifier to ID.
if tpt.selectedl == "DEFAULT_WL_ERASE" then
wallid = 0 
elseif tpt.selectedl == "DEFAULT_WL_CNDTR" then
wallid = 11 
elseif tpt.selectedl == "DEFAULT_WL_EWALL" then
wallid = 2
elseif tpt.selectedl == "DEFAULT_WL_DTECT" then
wallid = 3
elseif tpt.selectedl == "DEFAULT_WL_STRM" then
wallid = 4
elseif tpt.selectedl == "DEFAULT_WL_FAN" then
wallid = 5 
elseif tpt.selectedl == "DEFAULT_WL_LIQD" then
wallid = 6
elseif tpt.selectedl == "DEFAULT_WL_ABSRB" then
wallid = 7
elseif tpt.selectedl == "DEFAULT_WL_WALL" then
wallid = 8
elseif tpt.selectedl == "DEFAULT_WL_AIR" then
wallid = 9
elseif tpt.selectedl == "DEFAULT_WL_POWDR" then
wallid = 10
elseif tpt.selectedl == "DEFAULT_WL_CNDTR" then
wallid = 11
elseif tpt.selectedl == "DEFAULT_WL_EHOLE" then
wallid = 12
elseif tpt.selectedl == "DEFAULT_WL_GAS" then
wallid = 13
elseif tpt.selectedl == "DEFAULT_WL_GRVTY" then
wallid = 14
elseif tpt.selectedl == "DEFAULT_WL_ENRGY" then
wallid = 15
elseif tpt.selectedl == "DEFAULT_WL_NOAIR" then
wallid = 16
elseif tpt.selectedl == "DEFAULT_WL_ERASEA" then
wallid = 17
elseif tpt.selectedl == "DEFAULT_WL_STASIS" then
wallid = 18
elseif tpt.selectedl == "DEFAULT_WL_CNDTW" then
wallid = 1
else
wallid = 404 --Id reserved DO NOT CHANGE.
end
end

local function selecthelp()
local qolr,qolg,qolb = 255,55,55
local x2, y2 = 0,0
if linetoolstat == "1" and drawval > 0 and tpt.mousex < 607 and tpt.mousex > 3 and tpt.mousey < 378 and tpt.mousey > 3 then
x2, y2 = sim.adjustCoords(tpt.mousex, tpt.mousey)
if x1 == x2 or y1 == y2 then
qolr,qolg,qolb = 55,255,55
end
gfx.drawLine(x1, y1, x2, y2, qolr,qolg,qolb,235)
gfx.drawText(x1-40, y1+12,"X:"..x1..", Y:"..y1,qolr,qolg,qolb,235)
gfx.drawText(x2+10, y2+12,"X:"..x2..", Y:"..y2,qolr,qolg,qolb,235)
if usedZoom and (x2 ~= tpt.mousex or y2 ~= tpt.mousey) then
gfx.drawLine(orig_x1, orig_y1, tpt.mousex, tpt.mousey, 255,55,55,235)
end
end
if boxstat == "1" and boxval > 0 and tpt.mousex < 607 and tpt.mousex > 3 and tpt.mousey < 378 and tpt.mousey > 3 then
x2, y2 = sim.adjustCoords(tpt.mousex, tpt.mousey)
gfx.drawLine(x1, y1, x1, y2,255,55,55,235)
gfx.drawLine(x1, y1, x2, y1,255,55,55,235)
gfx.drawLine(x2, y2, x1, y2,255,55,55,235)
gfx.drawLine(x2, y2, x2, y1,255,55,55,235)
gfx.drawText(x1-40, y1+17,"X:"..x1..", Y:"..y1,qolr,qolg,qolb,235)
gfx.drawText(x2-40, y2+17,"X:"..x2..", Y:"..y2,qolr,qolg,qolb,235)
if usedZoom and (x2 ~= tpt.mousex or y2 ~= tpt.mousey) then
gfx.drawLine(orig_x1,orig_y1,orig_x1,tpt.mousey,255,55,55,235)
gfx.drawLine(orig_x1, orig_y1,tpt.mousex,orig_y1,255,55,55,235)
gfx.drawLine(tpt.mousex,tpt.mousey,orig_x1,tpt.mousey,255,55,55,235)
gfx.drawLine(tpt.mousex, tpt.mousey, tpt.mousex, orig_y1,255,55,55,235)
gfx.drawText(orig_x1-40, y1+12,"X:"..orig_x1..", Y:"..orig_y1,qolr,qolg,qolb,235)
gfx.drawText(tpt.mousex+10, tpt.mousey+12,"X:"..tpt.mousex..", Y:"..tpt.mousey,qolr,qolg,qolb,235)
end
end
convertwallid()
end

function mouse_down(x, y)
if linetoolstat == "1"then
if x < sim.XRES and x > 0 and y < sim.YRES and y > 0 then
drawval = drawval + 1
if drawval == 1 then
orig_x1, orig_y1 = x, y
x1, y1 = sim.adjustCoords(x, y)
usedZoom = x1 ~= tpt.mousex or y1 ~= tpt.mousey
return false
end
else
drawval = 0
end
end

if floodstat == "1" and x < sim.XRES and x > 0 and y < sim.YRES and y > 0 then
if wallid ~=404 then
sim.floodWalls(x, y, wallid)
else
sim.floodParts(x, y, tonumber(tpt.selectedl))
end
end

if boxstat == "1"then
if x < sim.XRES and x > 0 and y < sim.YRES and y > 0 then
boxval = boxval + 1
if boxval == 1 then
orig_x1, orig_y1 = x, y
x1, y1 = sim.adjustCoords(x, y)
usedZoom = x1 ~= tpt.mousex or y1 ~= tpt.mousey
return false
end
else
boxval = 0
end
end
end

function mouse_up(x, y)
if x < sim.XRES and x > 0 and y < sim.YRES and y > 0 and boxstat == "1" and boxval == 1 then
x2, y2 = sim.adjustCoords(x, y)
boxval = boxval + 1
if boxval == 2 then
if wallid ~= 404 then
sim.createWallBox(x1,y1,x2,y2,wallid)
else
sim.createBox(x1,y1,x2,y2,tonumber(selectedl))
end
end
boxval = 0
return false
else

if boxval ~= 0 then
print("Box canceled")
boxval = 0
return false
end
end

if x < sim.XRES and x > 0 and y < sim.YRES and y > 0 and linetoolstat == "1" and drawval == 1 then
x2, y2 = sim.adjustCoords(x, y)
drawval = drawval + 1
if drawval == 2 then
-- Handle FAN wall, matching vanilla logic
if tpt.get_wallmap(x1 / 4, y1 / 4) == WL_FAN then
local fvx = (x2 - x1) * .005
local fvy = (y2 - y1) * .005
sim.floodWalls(x1, y1, WL_FANHELPER, WL_FAN)
for i = 0, sim.XCELLS -1 do
for j = 0, sim.YCELLS -1 do
-- Replace all FANHELPER wall with FAN with appropriate velocity
if tpt.get_wallmap(i, j) == WL_FANHELPER then
tpt.set_wallmap(i, j, 1, 1, fvx, fvy, WL_FAN)
end
end
end
else
if wallid ~= 404 then
sim.createWallLine(x1,y1,x2,y2,tpt.brushx,tpt.brushy,wallid)
else
sim.createLine(x1,y1,x2,y2,tpt.brushx,tpt.brushy,tonumber(selectedl),tpt.brushID)
end
end
drawval = 0
return false
end
else
if drawval ~= 0 then
print("Line canceled")
drawval = 0
return false
end
end
end

button1:action(function(sender)
tpt.brushID = 0
end)

button2:action(function(sender)
tpt.brushID = 1
end)

button3:action(function(sender)
tpt.brushID = 2
end)

button4:action(function(sender)
ui.closeWindow(brushmenu)
end)
brushwidth:onValueChanged(function()
tpt.brushy = brushwidth:value()
end)
brushheight:onValueChanged(function()
tpt.brushx = brushheight:value()
end)

local function hover(x,y)
if y <= 390 and x <= 610 then
return false
end
end

button5:action(function(sender)
if hoverval == 0 then
event.unregister(event.mousedown,hover)
event.register(event.mousedown,hover)
hoverval = 1
elseif hoverval == 1 then
event.unregister(event.mousedown,hover)
hoverval = 0
end
print("Hover mode: Element drawing has been disabled.")
end)

local function findmode()
convertwallid()
if wallid == 404 then
gfx.fillRect(8,368,tonumber(gfx.textSize(sim.elementCount(elem[tpt.selectedl]))*2),12,10,10,10,150)
gfx.drawText(10,370,"Count:"..sim.elementCount(elem[tpt.selectedl]),32,216,255,255)
else
gfx.drawText(10,370,"Wall selected",255,0,0,255)
end
end

button6:action(function(sender)
if findval == 0 then
event.unregister(event.tick,findmode)
event.register(event.tick,findmode)
findval = 1
elseif findval == 1 then
event.unregister(event.tick,findmode)
findval = 0
end
end)

button8:action(function(sender)
if ren.debugHUD() == 0 then
ren.debugHUD(1)
elseif ren.debugHUD() == 1 then
ren.debugHUD(0)
end
end)

button9:action(function(sender)
if drawcoordstatus == "0" then
event.register(event.tick,drawcoord)
drawcoordstatus = "1"
tpt.mousex = 314
tpt.mousey = 208
elseif drawcoordstatus == "1" then
event.unregister(event.tick,drawcoord)
drawcoordstatus = "0"
end
end)

button10:action(function(sender)
ui.closeWindow(brushmenu)
print("Directing to script thread..") --Update the thread id whenever a new thread is made
platform.openLink("https://powdertoy.co.uk/Discussions/Thread/View.html?Thread=26505")
end)

button11:action(function(sender)
if ren.grid() == 0 then
ren.grid(5)
elseif ren.grid() > 0 then
ren.grid(0)
end
end)

button16:action(function(sender)
if perfval == 0 then
perfval = 1
tpt.setdrawcap(30)
tpt.display_mode(7)
elseif perfval == 1 then
perfval = 0
tpt.setdrawcap(0)
tpt.display_mode(3)
end
end)

local function simoptions()
--Draw buttons
gfx.fillRect(280,355,130,26,10,10,10,200)
gfx.drawRect(280,355,130,26)
gfx.drawText(286,365,"Undo")
gfx.drawText(326,365,"Redo")
gfx.drawText(366,365,"1-Frame")

if tpt.mousey > 355 and tpt.mousey < 382 then
if tpt.mousex > 280 and tpt.mousex < 315  then
gfx.fillRect(280,356,36,24,55,255,55,120)
elseif tpt.mousex > 316 and tpt.mousex < 355 then
gfx.fillRect(322,356,36,24,55,255,55,120)
elseif tpt.mousex > 356 and tpt.mousex < 410 then
gfx.fillRect(364,356,45,24,55,255,55,120)
end
end
end

local function simoptionsclick(x,y)
if y > 355 and y < 382 then
if x > 280 and x < 315  then
print("Undo used")
sim.historyRestore()
elseif x > 316 and x < 355 then
sim.historyForward()
print("Redo used")
elseif x > 356 and x < 410 then
tpt.set_pause(1)
sim.framerender(1)
print("Advanced by 1 frame")
end
return false
end
end

button14:action(function(sender)
if simopval == 0 then
simopval = 1
event.unregister(event.tick,simoptions)
event.register(event.tick,simoptions)
event.unregister(event.mousedown,simoptionsclick)
event.register(event.mousedown,simoptionsclick)
print("Simulation options turned on.")
elseif simopval == 1 then
simopval = 0
event.unregister(event.mousedown,simoptionsclick)
event.unregister(event.tick,simoptions)
end
end)

button15:action(function(sender)
ui.closeWindow(brushmenu)
sim.resetPressure()
tpt.reset_spark()
print("SPRK and Pressure have been reset.")
end)

local function disabletools()
event.unregister(event.mousedown,mouse_down)
event.unregister(event.tick,selecthelp)
event.unregister(event.mouseup,mouse_up)
end

button7:action(function(sender)
disabletools()
boxstat = "0"
linetoolstat = "0"
if floodstat == "0" then
print("Click in an enclosed area to flood fill, turn off when not in use")
floodstat = "1"
event.register(event.mousedown,mouse_down)
event.register(event.tick,selecthelp)
ui.closeWindow(brushmenu)
elseif floodstat == "1" then
event.unregister(event.mousedown,mouse_down)
event.unregister(event.tick,selecthelp)
floodstat = "0"
end
end)

button12:action(function(sender)
disabletools()
floodstat = "0"
linetoolstat = "0"
if boxstat == "0" then
print("Click and drag to draw a box, click outside the simulation area to cancel.")
event.register(event.mousedown,mouse_down)
event.register(event.mouseup,mouse_up)
event.register(event.tick,selecthelp)
boxstat = "1"
ui.closeWindow(brushmenu)
elseif boxstat == "1" then
event.unregister(event.mousedown,mouse_down)
event.unregister(event.tick,selecthelp)
event.unregister(event.mouseup,mouse_up)
boxstat = "0"
end
end)

button13:action(function(sender)
disabletools()
floodstat = "0"
boxstat = "0"
drawval = 0
if linetoolstat == "0" then
print("Click and drag to draw a line, click outside the simulation area to cancel.")
event.register(event.mousedown,mouse_down)
event.register(event.mouseup,mouse_up)
event.register(event.tick,selecthelp)
linetoolstat = "1"
ui.closeWindow(brushmenu)
elseif linetoolstat == "1" then
event.unregister(event.mousedown,mouse_down)
event.unregister(event.tick,selecthelp)
event.unregister(event.mouseup,mouse_up)
linetoolstat = "0"
end
end)

--ADD BUTTONS
brushmenu:addComponent(button1)
brushmenu:addComponent(button2)
brushmenu:addComponent(button3)
brushmenu:addComponent(button4)
brushmenu:addComponent(button5)
brushmenu:addComponent(button6)
brushmenu:addComponent(button7)
brushmenu:addComponent(brushwidth)
brushmenu:addComponent(brushheight)
brushmenu:addComponent(button8)
brushmenu:addComponent(button9)
brushmenu:addComponent(button10)
brushmenu:addComponent(button11)
brushmenu:addComponent(button12)
brushmenu:addComponent(button13)
brushmenu:addComponent(button14)
brushmenu:addComponent(button15)
brushmenu:addComponent(button16)
--Draws graphics when menu is open
brushmenu:onDraw(selectedbrush)
--End of script

Description:

Changelog: