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 159819
(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 159819
(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
(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-IM 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
(275) TPTMulti v2.2.5 Beta by LBPHacker
(276) ROM Builder by QnpfvTPz
(277) acb's Idea Generator by aaccbb
(278) Bode's Grapher by Bodester
(279) Gradient Tool by Bodester
(280) Better FPS Slider by ngmoco
(281) MyWIFI by Bodester
(282) acb's Slow-Mo Script by aaccbb
(283) Fun n' Chemicals by 0xHenryMC
(284) Resistant coating by git4rker
(285) Nationwide script by Kit237
(286) weird alphabet.lua by alice_loona_ot12
(287) MT's font for texter by Kit237
(288) Compiler for the SCE computer by NoVIcE by NoVIcE
(289) Perlin Noise Map Generator by Kit236
(290) hell fire element by Hecker
(291) Power stuff by William
(292) Missile by BaCOn
(293) Wargame's things by Kit236
(294) Inert Gas by EwguhMicBewguhGuy
(295) Average Temperature Display by tptQuantification
(296) Radicons by stillthere
(297) ROCKET by stillthere
(298) NUUKE! by stillthere
(299) SubpixelScope by Rebmiami
(300) Unobtanium Element Pack by AlgoPowdo
(301) Magnets by TheSuperNova
(302) library007 3000 by 008cff
(303) Element tuner by TheSuperNova
(304) Somethings by TheSuperNova
(305) Realistic Water by yuht
(306) Futurism by TheSuperNova
(307) MMod by MeltedLawnFlamingo
(308) Wierd energy by mellowmonster12
(309) Time Reversing by crocodilea
(310) Weather System by Bigmann
(311) infinite framerate by kayra
(312) Diamondifier mod by Believer0914
(313) Radtech by ReallyJustDont
(314) TPT 'port' of IRC Crackbot game by creator_of_fail
(315) Fireshoas Stuff by Fireshoa
(316) TPTASM: Universal assembler for TPT computers by LBPHacker
(317) Ronansb's Elements by ronansb
(318) AeroStuff v1.2 by AerospaceFan
(319) TPT Font Writer Expanded by budc123
(320) Element Table Pack by RetroBoy2040
(321) One Time Conductor by Believer0914
(322) Extra Debug Info by creator_of_fail
(323) burst v1 by ml_lom
(324) Nuclide Expansion by Alchnoious
(325) Nuclear Elems by xhrqnx2
(326) UM by Sunshine1304
(327) Android stamp rescanner by LBPHacker
(328) Temp Resetting Button by DoobsterBro1234
(329) INFEKTOR_infection_V1 by PowderTechnician1475
(330) Nanotech V2 by TheSuperNova
(331) super explosives by egglegendbro
(332) The Return of the Powder Dinn by savask
(333) INFEKTOR_infection_V2 by PowderTechnician1475
(334) Metallic Diamond by Shyth
(335) stupid stuff mod by stillthere
(336) R3 Keyboard Writer by lesio
(337) Chaos Matter by PstnPopper-2000
(338) VirusStuff by AerospaceFan
(339) acids and reactions by egglegendbro
(340) PipeHUD by JonaHungary
(341) visible warp by TheFPSKiller
(342) Ozone Mod by Aeiouman
(343) Leaf's Beautiful World by Leaf1
(344) Wireless FILT serializator by Houseinik
(345) TINY-PLATFORMER by LogikDOS
(346) RadiThor by linfuciuscont
(347) Aero's Periodic Table Mod by AerospaceFan
(348) MoreCommands by LogikDOS
(350) MetalsPack by somedudesaidTPT
(351) 3D Pressure Visualizer 2 by Legoer333
(352) Tools++ by Houseinik

+ Submit new script!

Title: Author:
Script:
--== Layering Helper Reforged ==--
---- is a remake of "LuaMaster"'s Layering Helper Extended.
---- In it a lot of efforts have been made to condense the code,
---- as well as fixing the bind and exposing the function for opening the menu.

---- Usage:
--- # Ctrl+J (Default) to open the menu
--- # lhr_showWindow() in console to open the menu manually
--- ^ Not recommended as the cursor position might be messed up

--< Local Functions >--
local function testIsNumber(value) return tonumber(value) ~= nil end
local function testElement(element_type) if element_type == nil then return false, 0 end success, ret = pcall(tpt.element, element_type) if success and not testIsNumber(element_type) then return true, ret elseif success and testIsNumber(element_type) then return true, element_type end return false, 0 end

local names_setstring = ""
local names_nilstring = ""
function testExpression(str) -- what have I done
	if string.len(names_setstring) < 1 or string.len(names_nilstring) < 1 then
		local name_count = 0
		local string_buffer = ""
		local vstring_buffer = ""

		for name, tbl in pairs(tpt.el) do
			if name_count >= 5 then
				names_setstring = names_setstring .. string.format("%s = %s; ", string_buffer, vstring_buffer)
				names_nilstring = names_nilstring .. string.format("%s = %s; ", string_buffer, "nil" .. ((name_count > 1) and (string.rep(", nil", name_count * 2 - 1)) or ""))

				string_buffer = ""
				vstring_buffer = ""

				name_count = 0
			end

			local exists, elem_id = testElement(name)
			
			if exists then
				name = string.gsub(name, "%-", "")
				local lname, uname = string.lower(name), string.upper(name)

				string_buffer = string_buffer .. string.rep(", ", name_count > 0 and 1 or 0) .. lname .. ", " .. uname
				vstring_buffer = vstring_buffer .. string.rep(", ", name_count > 0 and 1 or 0) .. elem_id .. ", " .. elem_id
				
				name_count = name_count + 1
			end
		end
		
		if name_count > 0 then
			names_setstring = names_setstring .. string.format("local %s = %s; ", string_buffer, vstring_buffer)
			names_nilstring = names_nilstring .. string.format("%s = %s; ", string_buffer, "nil" .. ((name_count > 1) and (string.rep(", nil", name_count * 2 - 1)) or ""))
		end
		
		string_buffer = nil
		vstring_buffer = nil

		name_count = nil
	end

	local func = loadstring(names_setstring .. "local lresult = (" .. str .. "); " .. names_nilstring .. "return lresult")
	if func then
		local ret, err = func()
		
		if ret == nil and type(err) == "string" then
			return false, err
		end
		
		return true, ret
	end
	
	return false, nil
end

--< Local Variables >--
-- dont set these directly unless you are a wizard or something
local open_key_code = 106

local is_drawing = false
local pos1_x, pos1_y, pos2_x, pos2_y = 0, 0, 0, 0
local color_r, color_g, color_b, color_a = 161, 71, 194, 255

local option_do_lua 	= true
local option_no_overlap = false

--< GUI Components >--
local guiWindow = Window:new(-1, -1, 600, 400)
local guiComponents = {}

local function get_input(use_lua)
	if type(use_lua) ~= "boolean" then use_lua = true end
	local str = tpt.input()
	
	if option_do_lua and use_lua and string.len(str) > 0 then
		local success, result = testExpression(str)
		
		if success then
			if tostring(result) == "nil" then
				result = 0
			end

			return tostring(result)
		end
	end
	
	return str
end

guiComponents["Label"] = Label:new(0, 0, 600, 40, "Layering Helper Reforged")

guiComponents["Type_Set"] = Button:new(1 + 93 * 0, 40, 93, 26 / 2, "Set Types")
guiComponents["Type_Set"]:action(function() local str = get_input(false); if string.len(str) < 1 then return end for i = 1, 5 do guiComponents["Part" .. i .. "_Type"]:text(str) end end)
guiComponents["Type_Clear"] = Button:new(1 + 93 * 0, 40 + 26 / 2, 93, 26 / 2, "Clear Types")
guiComponents["Type_Clear"]:action(function() for i = 1, 5 do guiComponents["Part" .. i .. "_Type"]:text("") end end)

guiComponents["Life_Set"] = Button:new(1 + 93 * 1, 40, 93, 26 / 2, "Set Lifes")
guiComponents["Life_Set"]:action(function() local str = get_input(); if string.len(str) < 1 then return end for i = 1, 5 do guiComponents["Part" .. i .. "_Life"]:text(str) end end)
guiComponents["Life_Clear"] = Button:new(1 + 93 * 1, 40 + 26 / 2, 93, 26 / 2, "Clear Lifes")
guiComponents["Life_Clear"]:action(function() for i = 1, 5 do guiComponents["Part" .. i .. "_Life"]:text("") end end)

guiComponents["Ctype_Set"] = Button:new(1 + 93 * 2, 40, 93, 26 / 2, "Set Ctypes")
guiComponents["Ctype_Set"]:action(function() local str = get_input(); if string.len(str) < 1 then return end for i = 1, 5 do guiComponents["Part" .. i .. "_Ctype"]:text(str) end end)
guiComponents["Ctype_Clear"] = Button:new(1 + 93 * 2, 40 + 26 / 2, 93, 26 / 2, "Clear Ctypes")
guiComponents["Ctype_Clear"]:action(function() for i = 1, 5 do guiComponents["Part" .. i .. "_Ctype"]:text("") end end)

guiComponents["Temp_Set"] = Button:new(1 + 93 * 3, 40, 93, 26 / 2, "Set Temps")
guiComponents["Temp_Set"]:action(function() local str = get_input(); if string.len(str) < 1 then return end for i = 1, 5 do guiComponents["Part" .. i .. "_Temp"]:text(str) end end)
guiComponents["Temp_Clear"] = Button:new(1 + 93 * 3, 40 + 26 / 2, 93, 26 / 2, "Clear Temps")
guiComponents["Temp_Clear"]:action(function() for i = 1, 5 do guiComponents["Part" .. i .. "_Temp"]:text("") end end)

guiComponents["Tmp_Set"] = Button:new(1 + 93 * 4, 40, 93, 26 / 2, "Set Tmps")
guiComponents["Tmp_Set"]:action(function() local str = get_input(); if string.len(str) < 1 then return end for i = 1, 5 do guiComponents["Part" .. i .. "_Tmp"]:text(str) end end)
guiComponents["Tmp_Clear"] = Button:new(1 + 93 * 4, 40 + 26 / 2, 93, 26 / 2, "Clear Tmps")
guiComponents["Tmp_Clear"]:action(function() for i = 1, 5 do guiComponents["Part" .. i .. "_Tmp"]:text("") end end)

guiComponents["Tmp2_Set"] = Button:new(1 + 93 * 5, 40, 93, 26 / 2, "Set Tmp2s")
guiComponents["Tmp2_Set"]:action(function() local str = get_input(); if string.len(str) < 1 then return end for i = 1, 5 do guiComponents["Part" .. i .. "_Tmp2"]:text(str) end end)
guiComponents["Tmp2_Clear"] = Button:new(1 + 93 * 5, 40 + 26 / 2, 93, 26 / 2, "Clear Tmp2s")
guiComponents["Tmp2_Clear"]:action(function() for i = 1, 5 do guiComponents["Part" .. i .. "_Tmp2"]:text("") end end)

guiComponents["ClearButton"] = Button:new(1 + 93 * 6, 40, 40, 26, "Clear *")

for i = 1, 5 do
	guiComponents["Part" .. i .. "_Type"]	= Textbox:new(1 + 93 * 0, 40 + 26 * i, 93, 26, nil, "Part " .. i .. ": Type")
	guiComponents["Part" .. i .. "_Life"]	= Textbox:new(1 + 93 * 1, 40 + 26 * i, 93, 26, nil, "Part " .. i .. ": Life")
	guiComponents["Part" .. i .. "_Ctype"]	= Textbox:new(1 + 93 * 2, 40 + 26 * i, 93, 26, nil, "Part " .. i .. ": Ctype")
	guiComponents["Part" .. i .. "_Temp"]	= Textbox:new(1 + 93 * 3, 40 + 26 * i, 93, 26, nil, "Part " .. i .. ": Temp")
	guiComponents["Part" .. i .. "_Tmp"]	= Textbox:new(1 + 93 * 4, 40 + 26 * i, 93, 26, nil, "Part " .. i .. ": Tmp")
	guiComponents["Part" .. i .. "_Tmp2"]	= Textbox:new(1 + 93 * 5, 40 + 26 * i, 93, 26, nil, "Part " .. i .. ": Tmp2")
	guiComponents["Part" .. i .. "_ClearButton"] = Button:new(1 + 93 * 6, 40 + 26 * i, 40, 26, "Clear")
	guiComponents["Part" .. i .. "_ClearButton"]:action(function()
		guiComponents["Part" .. i .. "_Type"]:text("")
		guiComponents["Part" .. i .. "_Life"]:text("")
		guiComponents["Part" .. i .. "_Ctype"]:text("")
		guiComponents["Part" .. i .. "_Temp"]:text("")
		guiComponents["Part" .. i .. "_Tmp"]:text("")
		guiComponents["Part" .. i .. "_Tmp2"]:text("")
	end)
end

guiComponents["Label2"] = Label:new(0, 40 + 26 * 6, 600, 40, "Options")

guiComponents["doLuaToggle"] = Button:new(1, 40 * 2 + 26 * 6, 600 - 2, 26, "Do Lua: ON (Values will be evaluated by Lua on creation and in mass-set buttons)")
guiComponents["doLuaToggle"]:action(function() 
	option_do_lua = not option_do_lua
	
	if option_do_lua then 
		guiComponents["doLuaToggle"]:text("Do Lua: ON (Values will be evaluated by Lua on creation and in mass-set buttons)")
	else
		guiComponents["doLuaToggle"]:text("Do Lua: OFF (Values will be used as-is when creating parts)")
	end
end)

guiComponents["noOverlapToggle"] = Button:new(1, 40 * 2 + 26 * 7, 600 - 2, 26, "No Overlap: OFF (LHR will try to place things regardless of what is there)")
guiComponents["noOverlapToggle"]:action(function() 
	option_no_overlap = not option_no_overlap
	
	if option_no_overlap then 
		guiComponents["noOverlapToggle"]:text("No Overlap: ON (LHR only place parts somewhere if that place is empty)")
	else
		guiComponents["noOverlapToggle"]:text("No Overlap: OFF (LHR will try to place things regardless of what is there)")
	end
end)

guiComponents["TimesBox"]		= Textbox:new(1, 400 - 40 - 26, 600 - 2, 26, nil, "Times (def: 1)")
guiComponents["CreateButton"]	= Button:new((600 / 2) * 0 + 1, 400 - 40 - 1, 600 / 2, 40, "Create Parts")
guiComponents["CancelButton"]	= Button:new((600 / 2) * 1, 400 - 40 - 1, 600 / 2 - 1, 40, "Cancel")

local function makePart(x, y, data)
	local index = -1
	
	index = sim.partCreate(-3, x, y, data.type)
	if index >= 0 then
		for k, v in pairs(data) do
			if k ~= "type" then
				sim.partProperty(index, k, v)
			end
		end
	end
	
	return index >= 0
end

local function makeParts(x, y, datas)
	local valid_data = {}

	for i, data in ipairs(datas) do
		if makePart(x, y, data) then
			valid_data[#valid_data + 1] = data
		end
	end
	
	return valid_data
end

local function evaluateStr(value)
	if option_do_lua and string.len(value) > 0 and value ~= nil then
		local success, result = testExpression(value)
		
		if success then
			if tostring(result) == "nil" then
				result = 0
			end

			return tostring(result)
		end
	end
	
	return value
end 

local function collectPartDatas()
	local datas = {}
	local data = {}
	local tmpv = ""

	local ctype_exists, ctype_id = false, 0

	for _i = 1, 5 do
		local i = 6 - _i

		if guiComponents["Part" .. i .. "_Type"]:text() ~= "" then
			typeExists, typeIndex = testElement(guiComponents["Part" .. i .. "_Type"]:text())
			if typeExists then
				data = {type = typeIndex}
			
				tmpv = evaluateStr(guiComponents["Part" .. i .. "_Life"]:text())
				if testIsNumber(tmpv) then
					data.life = tmpv
				elseif tmpv ~= "" then
					print("part" .. i .. ": Life invalid!")
				end

				tmpv = evaluateStr(guiComponents["Part" .. i .. "_Ctype"]:text())
				ctype_exists, ctype_id = testElement(tmpv)
				if ctype_exists then
					data.ctype = ctype_id
				elseif tmpv ~= "" then
					print("part" .. i .. ": Ctype invalid!")
				end

				tmpv = evaluateStr(guiComponents["Part" .. i .. "_Temp"]:text())
				if testIsNumber(tmpv) then
					data.temp = tmpv
				elseif tmpv ~= "" then
					print("part" .. i .. ": Temp invalid!")
				end

				tmpv = evaluateStr(guiComponents["Part" .. i .. "_Tmp"]:text())
				if testIsNumber(tmpv) then
					data.tmp = tmpv
				elseif tmpv ~= "" then
					print("part" .. i .. ": Tmp invalid!")
				end

				tmpv = evaluateStr(guiComponents["Part" .. i .. "_Tmp2"]:text())
				if testIsNumber(tmpv) then
					data.tmp2 = tmpv
				elseif tmpv ~= "" then
					print("part" .. i .. ": Tmp2 invalid!")
				end

				datas[#datas + 1] = data
			else
				print("part" .. i .. ": Type invalid")
			end
		end
	end
	
	return datas
end

guiComponents["CreateButton"]:action(function()
	local times = 1

	local tmpv = guiComponents["TimesBox"]:text()
	if testIsNumber(tmpv) and tonumber(tmpv) >= 0 then
		times = tonumber(tmpv)
	end

	interface.closeWindow(guiWindow)
	
	local datas = collectPartDatas()
	if #datas > 0 then
		if pos1_x == pos2_x and pos1_y == pos2_y then
			if (option_no_overlap and sim.partID(x, y) == nil) or option_no_overlap == false then
				for _ = 1, times do
					datas = makeParts(pos2_x, pos2_y, datas)

					if #datas < 1 then return end
				end
			end
		else
			local x_start, x_end = pos1_x, pos2_x
			if pos2_x < pos1_x then x_start = pos2_x; x_end = pos1_x end

			local y_start, y_end = pos1_y, pos2_y
			if pos2_y < pos1_y then y_start = pos2_y; y_end = pos1_y end

			local width, height = x_end - x_start, y_end - y_start

			for x = x_start, x_end do
				for y = y_start, y_end do
					if (option_no_overlap and sim.partID(x, y) == nil) or option_no_overlap == false then
						for _ = 1, times do
							datas = makeParts(x, y, datas)

							if #datas < 1 then return print("[LHR] Creation ended early"), print("[LHR] It is possible the part limit was reached") end
						end
					end
				end
			end
		end
	end
end)

guiComponents["CancelButton"]:action(function()
	interface.closeWindow(guiWindow)
end)

guiComponents["ClearButton"]:action(function()
	for i = 1, 5 do
		guiComponents["Part" .. i .. "_Type"]:text("")
		guiComponents["Part" .. i .. "_Life"]:text("")
		guiComponents["Part" .. i .. "_Ctype"]:text("")
		guiComponents["Part" .. i .. "_Temp"]:text("")
		guiComponents["Part" .. i .. "_Tmp"]:text("")
		guiComponents["Part" .. i .. "_Tmp2"]:text("")
	end
end)

for _, component in pairs(guiComponents) do
	guiWindow:addComponent(component)
end

function lhr_showWindow() interface.showWindow(guiWindow) end

event.register(evt.tick, function()
	if is_drawing then
		if pos1_x == pos2_x or pos1_y == pos2_y then
			graphics.drawLine(pos1_x, pos1_y, pos2_x, pos2_y, color_r, color_g, color_b, color_a)
		else
			local dist_x, dist_y = math.abs(pos2_x - pos1_x) + 1, math.abs(pos2_y - pos1_y) + 1
			local chosen_x, chosen_y = (pos1_x < pos2_x and pos1_x or pos2_x), (pos1_y < pos2_y and pos1_y or pos2_y)
			
			graphics.drawRect(chosen_x, chosen_y, dist_x, dist_y, color_r, color_g, color_b, color_a)

			local txt = dist_x .. "x" .. dist_y
			local text_x, text_y = graphics.textSize(txt)

			if (text_x + 2) < dist_x and (text_y + 2) < dist_y then
				graphics.drawText(chosen_x + dist_x / 2 - text_x / 2 + 1, chosen_y + dist_y / 2 - text_y / 2 + 2, txt, color_r, color_g, color_b, color_a)
			end
		end
	end
end)

event.register(evt.mousemove, function(x, y, dx, dy)
	if is_drawing then
		pos2_x, pos2_y = sim.adjustCoords(tpt.mousex, tpt.mousey)
	end
end)

event.register(evt.keypress, function(key, _, _, _, ctrl)
	if key == open_key_code and ctrl and not is_drawing then
		pos1_x, pos1_y = sim.adjustCoords(tpt.mousex, tpt.mousey)
		pos2_x, pos2_y = sim.adjustCoords(tpt.mousex, tpt.mousey)

		is_drawing = true
	end
end)

event.register(evt.keyrelease, function(key, _, _, _, ctrl)
	if key == open_key_code and is_drawing then
		is_drawing = false
		pos2_x, pos2_y = sim.adjustCoords(tpt.mousex, tpt.mousey)

		lhr_showWindow()
	end
end)

print("LHR Ready.")

Description:

Changelog: