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
(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 2.0 3000 by 008cff

+ Submit new script!

Title: Author:
Script:
local function clamp(num, min, max)
	if num < min then
		return min
	elseif num > max then
		return max
	else
		return num
	end
end

phimodprescence = true

local new = elements.allocate("PhiMod", "DEUG") --Deuterium gas.
elements.element(new, elements.element(elem.DEFAULT_PT_HYGN))
elements.property(new, "Name", "DEUG")
elements.property(new, "Colour", elements.property(elem.DEFAULT_PT_WATR, "Colour"))
elements.property(new, "Properties", 0x00208)
elements.property(new, "Description", "Deuterium Gas. Turns into DEUT when burned.")

local function updateDEUG(i, x, y, s, nt)
	if nt > s then --Optimization. DEUG doesn't react with itself, so only update particles which have different particles around them.
		for r in sim.neighbors(x,y,1,1, elements.DEFAULT_PT_FIRE) do
			if bit.band(sim.partProperty(r, "tmp"), 2) > 0 then
				sim.partKill(r)
				sim.createBox(x - 1, y - 1, x + 1, y + 1, elem.DEFAULT_PT_FIRE, 0)
				sim.partProperty(i, "life", 20)
				sim.partChangeType(i, elem.DEFAULT_PT_DEUT)
				sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 3200)
				sim.pressure(x/4,y/4,sim.pressure(x/4,y/4)+0.5)
				break
			else
				sim.createBox(x - 1, y - 1, x + 1, y + 1, elem.DEFAULT_PT_FIRE, 0)
				sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 2000)
				sim.pressure(x/4,y/4,sim.pressure(x/4,y/4)+0.25)
				sim.partKill(i)
				return 1
			end
		end
	end
end

elements.property(new, "Update", updateDEUG)

new = elements.allocate("PhiMod","TRIT") --Tritium, the hydrogen isotope. Can fuse with DEUG.
elements.element(new, elements.element(elem.DEFAULT_PT_HYGN))
elements.property(new, "Colour", elements.property(elem.DEFAULT_PT_PLUT, "Colour"))
elements.property(new, "Name", "TRIT")
elements.property(new, "Properties", 0x02608)
elements.property(new, "Description", "Tritium, slightly radioactive. Handle with care.")

local vapor = elements.allocate("PhiMod", "TRWV") --Vapor of super-heavy water.
elements.element(vapor, elements.element(elem.DEFAULT_PT_WTRV))
elements.property(vapor, "Colour", 0xFFE0E0E0)
elements.property(vapor, "Name", "TRWV")
elements.property(vapor, "Properties", 0x02608)
elements.property(vapor, "Description", "Super-heavy water vapor. Handle with care.")

local new2 = elements.allocate("PhiMod", "TRIW") --Super-heavy water.
elements.element(new2, elements.element(elem.DEFAULT_PT_WATR))
elements.property(new2, "Colour", elements.property(elem.DEFAULT_PT_PLUT, "Colour"))
elements.property(new2, "Name", "TRIW")
elements.property(new2, "Properties", 0x06622)
elements.property(new2, "Description", "Tritated water. Radtioactive and toxic. Electrolyse to get TRIT and OXYG.")
elements.property(new2, "HighTemperatureTransition", vapor)
elements.property(vapor, "LowTemperatureTransition", new2)

local function decayTRIT(i, x, y) --Tritium is radioactive.
	if math.random(10000) == 1 then
		sim.partChangeType(i, elements.DEFAULT_PT_NBLE)
		if math.random(2) == 1 then
			sim.partCreate(-1, x + math.random(-1, 1), y + math.random(-1, 1), elements.DEFAULT_PT_O2)
			sim.partCreate(-1, x + math.random(-1, 1), y + math.random(-1, 1), elements.PHIMOD_PT_TRIT)
		end
		sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 50)
		sim.pressure(x/4, y/4, sim.pressure(x/4, y/4) + 0.1)
	end
end

local function corrodeHeavy(i, x, y, s, nt) --Tritium is corrosive
	if s == nt then
		return 0
	end
	for r in sim.neighbors(x, y, 1, 1) do
		if sim.partProperty(r, "type") == elements.PHIMOD_PT_TRIW and math.random(100) == 1 then
			sim.partProperty(i, "tmp", math.random(20, 29))
			sim.partChangeType(i, elements.DEFAULT_PT_BMTL)
			break
		end
		if sim.partProperty(r, "type") == elements.DEFAULT_PT_DEUT and math.random(1000) == 1 then
			sim.partProperty(i, "tmp", math.random(20, 29))
			sim.partChangeType(i, elements.DEFAULT_PT_BMTL)
			break
		end
	end
end
tpt.element_func(corrodeHeavy, elements.DEFAULT_PT_IRON)

local function SPRK_Heavy(i, x, y, s, nt)
	if sim.partProperty(i, "ctype") == elements.PHIMOD_PT_TRIW then
		decayTRIT(i, x, y)
		for r in sim.neighbors(x, y, 1, 1) do
			if sim.partProperty(r, "type") == elements.DEFAULT_PT_SPRK and sim.partProperty(r, "ctype") == elements.DEFAULT_PT_IRON then
				if math.random(3) == 1 then
					sim.partChangeType(i, elements.DEFAULT_PT_O2)
				else
					sim.partChangeType(i, elements.PHIMOD_PT_TRIT)
				end
			end
		end
	end
	if sim.partProperty(i, "ctype") == elements.DEFAULT_PT_IRON then
		for r in sim.neighbors(x, y, 1, 1, elements.DEFAULT_PT_DEUT) do
			if math.random(3) == 1 then
				sim.partChangeType(r, elements.DEFAULT_PT_O2)
			else
				sim.partChangeType(r, elements.PHIMOD_PT_DEUG)
			end
		end
	end
end

tpt.element_func(SPRK_Heavy, elements.DEFAULT_PT_SPRK)

local function updateTRIT(i, x, y, s, nt)
	if math.random(10000) == 1 then
		sim.partChangeType(i, elements.DEFAULT_PT_NBLE)
		return 0
	end
	if nt == s then
		return 0
	end
	for r in sim.neighbors(x,y,1,1) do
		if sim.partProperty(r,"type") == elem.DEFAULT_PT_FIRE then
			if math.floor(sim.partProperty(r, "tmp")/2) % 2 == 1 then
				sim.partKill(r)
				sim.createBox(x - 1, y - 1, x + 1, y + 1, elem.DEFAULT_PT_FIRE)
				sim.partChangeType(i, elements.PHIMOD_PT_TRIW)
				sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 3200)
				sim.pressure(x/4,y/4,sim.pressure(x/4,y/4)+0.5)
				break
			else
				sim.createBox(x - 1, y - 1, x + 1, y + 1, elem.DEFAULT_PT_FIRE)
				sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 2000)
				sim.pressure(x/4,y/4,sim.pressure(x/4,y/4)+0.3)
				sim.partKill(i)
				return 1
			end
		end
		if sim.partProperty(r, "type") == elem.PHIMOD_PT_DEUG and sim.partProperty(i, "temp") > 2073.15 and sim.pressure(x/4,y/4) > 40 then
			sim.partChangeType(r, elements.DEFAULT_PT_NEUT)
			c = sim.partCreate(-3, x, y, elements.DEFAULT_PT_PHOT)
			sim.partProperty(c, "ctype", 0x7C0000)
			sim.partCreate(-3, x, y, elements.DEFAULT_PT_PLSM)
			sim.partChangeType(i, elements.DEFAULT_PT_NBLE)
			sim.partProperty(i, "temp", sim.partProperty(i, "temp") + math.random(750, 1250))
		end
	end
end

elements.property(new, "Update", updateTRIT)
elements.property(new2, "Update", decayTRIT)
elements.property(vapor, "Update", decayTRIT)

local function decayICEI(i, x, y, s, nt)
	if sim.partProperty(i, "ctype") == elements.PHIMOD_PT_TRIW then
		decayTRIT(i, x, y)
	end
	if sim.partProperty(i, "ctype") == elements.PHIMOD_PT_FUEL and math.random(50000) == 1 then
		if math.random(3) == 1 then
			sim.partChangeType(i, elements.DEFAULT_PT_O2)
		else
			sim.partChangeType(i, elements.DEFAULT_PT_DSTW)
		end
	end
end

tpt.element_func(decayICEI, elements.DEFAULT_PT_ICEI)
tpt.element_func(decayICEI, elements.DEFAULT_PT_SNOW)

elements.property(elements.DEFAULT_PT_LN2, "Name", "CLNT")
elements.property(elements.DEFAULT_PT_LN2, "Description", "Coolant. Used to cool stuff.")
elements.property(elements.DEFAULT_PT_NICE, "Name", "FRCT")
elements.property(elements.DEFAULT_PT_NICE, "Description", "Frozen coolant.")

new = elements.allocate("PhiMod", "NIGN")
elements.element(new, elements.element(elements.DEFAULT_PT_OXYG))
elements.property(new, "Name", "NIGN")
elements.property(new, "Description", "Nitrogen gas.")

new = elements.allocate("PhiMod", "LN2")
elements.element(new, elements.element(elements.DEFAULT_PT_LN2))
elements.property(new, "Name", "LN2")
elements.property(new, "Description", "Liquid Nitrogen, very cold.")
elements.property(new, "HighTemperatureTransition", elements.PHIMOD_PT_NIGN)

elements.property(elements.PHIMOD_PT_NIGN, "LowTemperatureTransition", elements.PHIMOD_PT_LN2)
elements.property(elements.PHIMOD_PT_NIGN, "LowTemperature", elements.property(elements.PHIMOD_PT_LN2, "HighTemperature"))

new = elements.allocate("PhiMod", "NICE")
elements.element(new, elements.element(elements.DEFAULT_PT_NICE))
elements.property(new, "Name", "NICE")
elements.property(new, "Description", "Solid nitrogen. Extremely cold.")
elements.property(new, "HighTemperatureTransition", elements.PHIMOD_PT_LN2)
elements.property(elements.PHIMOD_PT_LN2, "LowTemperatureTransition", elements.PHIMOD_PT_NICE)

new = elements.allocate("PhiMod", "DIRT")
elements.element(new, elements.element(elements.DEFAULT_PT_STNE))
elements.property(new, "Colour", 0xFF4A301D)
elements.property(new, "Name", "DIRT")
elements.property(new, "Description", "Dirt. Useful for landscapes.")
elements.property(new, "HighTemperature", 1773.15)

local function graphicsDIRT(i, colr, colg, colb)
	return 0, ren.PMODE_FLAT, 255, colr + sim.partProperty(i,"tmp2"), colg + sim.partProperty(i,"tmp2"), colb + sim.partProperty(i,"tmp2"), 255, 255, 255, 255
end

elements.property(new, "Graphics", graphicsDIRT)
elements.property(new, "Create", function(i) sim.partProperty(i, "tmp2", math.random(0,30)) end)

new = elements.allocate("PhiMod", "FUEL") --Monopropellant (hydrogen peroxide). Credit to IEATDIRT for the idea.
elements.element(new, elements.element(elements.DEFAULT_PT_WATR))
elements.property(new, "Colour", 0xFFB8D9FF)
elements.property(new, "MenuSection", 5)
elements.property(new, "Name", "MONO")
elements.property(new, "Description", "Monopropellant. If it touches PTNM, it will explode.")
elements.property(new, "Weight", 30)
elements.property(new, "HighTemperature", 10000)
elements.property(new, "LowTemperature", 272.72)
elements.property(new, "Properties", 0x202)

local function updateFUEL(i, x, y, s, nt)
	if math.random(50000) == 1 or sim.partProperty(i, "temp") > 423.3 then
		if math.random(3) == 1 then
			sim.partChangeType(i, elements.DEFAULT_PT_O2)
		else
			sim.partChangeType(i, elements.DEFAULT_PT_DSTW)
		end
		if sim.partProperty(i, "temp") > 423.3 then
			sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 1000)
			sim.pressure(x/4,y/4,sim.pressure(x/4,y/4)+1)
		end
		return 0
	end
	if nt == s then
		return 0
	end
	for r in sim.neighbors(x, y, 1, 1) do
		if sim.partProperty(r, "type") == elements.DEFAULT_PT_PTNM then
			if math.random(2) == 1 then
				sim.partChangeType(i, elements.DEFAULT_PT_O2)
			else
				sim.partChangeType(i, elements.DEFAULT_PT_DSTW)
			end
			sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 1000)
			sim.pressure(x/4,y/4,sim.pressure(x/4,y/4)+1)
			return 0
		elseif sim.partProperty(r, "type") == elements.DEFAULT_PT_VIRS or sim.partProperty(r, "type") == elements.DEFAULT_PT_VRSS or sim.partProperty(r, "type") == elements.DEFAULT_PT_VRSG then
			sim.partKill(r)
		elseif sim.partProperty(r, "type") ~= elements.DEFAULT_PT_SOAP then
			sim.partProperty(r, "dcolour", 0x00FFFFFF)
		end
	end
end

elements.property(new, "Update", updateFUEL)

new = elements.allocate("PhiMod", "LH2")
elements.element(new, elements.element(elements.DEFAULT_PT_WATR))
elements.property(new, "Colour", 0xFF5038FF)
elements.property(new, "Name", "LH2")
elements.property(new, "Description", "Liquid hydrogen.")
elements.property(new, "Weight", 5)
elements.property(new, "HighTemperature", 20.3)
elements.property(new, "LowTemperature", -1)
elements.property(new, "HighTemperatureTransition", elements.DEFAULT_PT_H2)
elements.property(elements.DEFAULT_PT_H2, "LowTemperature", 20.3)
elements.property(elements.DEFAULT_PT_H2, "LowTemperatureTransition", elements.PHIMOD_PT_LH2)
elements.property(new, "Temperature", 10)

local function updateLH2(i, x, y, s, nt)
	if s == nt then
		return 0
	end
	for r in sim.neighbors(x, y, 1, 1, elements.DEFAULT_PT_FIRE) do
		if bit.band(sim.partProperty(r, "tmp"), 0x2) ~= 0 then
			sim.pressure(x/4, y/4, sim.pressure(x/4,y/4) + 0.5)
			sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 3200)
			c = sim.partCreate(-3, x, y, elements.DEFAULT_PT_PLSM)
		else
			sim.pressure(x/4, y/4, sim.pressure(x/4,y/4) + 0.25)
			sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 2000)
			c = sim.partCreate(-3, x, y, elements.DEFAULT_PT_FIRE)
		end
		sim.partProperty(r, "tmp", bit.bor(sim.partProperty(r, "tmp"), 0x1))
		sim.partProperty(c, "tmp", 1)
		break
	end
end

local function updateLO2(i, x, y, s, nt)
	if s == nt then
		return 0
	end
	for r in sim.neighbors(x, y, 1, 1, elements.DEFAULT_PT_FIRE) do
		if bit.band(sim.partProperty(r, "tmp"), 0x1) ~= 0 then
			sim.pressure(x/4, y/4, sim.pressure(x/4,y/4) + 0.5)
			sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 3200)
			c = sim.partCreate(-3, x, y, elements.DEFAULT_PT_PLSM)
		else
			sim.pressure(x/4, y/4, sim.pressure(x/4,y/4) + 0.25)
			sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 2000)
			c = sim.partCreate(-3, x, y, elements.DEFAULT_PT_FIRE)
		end
		sim.partProperty(r, "tmp", bit.bor(sim.partProperty(r, "tmp"), 0x2))
		sim.partProperty(c, "tmp", 2)
		break
	end
end

elements.property(new, "Update", updateLH2)
elements.property(elements.DEFAULT_PT_LO2, "Update", updateLO2)

new = elements.allocate("PhiMod", "GRPH")
elements.element(new, elements.element(elements.DEFAULT_PT_HEAC))
elements.property(new, "Colour", 0xFF181818)
elements.property(new, "Name", "GRPH")
elements.property(new, "Description", "Graphite. Can survive extremely high temperatures.")
elements.property(new, "HeatConduct", 2)
elements.property(new, "MenuSection", 9)
elements.property(new, "Properties", 0x14A24)
elements.property(new, "Weight", 102)
elements.property(new, "PhotonReflectWavelengths", 0)

local function updateGRPH(i, x, y, s, nt)
	if sim.partProperty(i, "life") > 0 then
		sim.createBox(x - 1, y - 1, x + 1, y + 1, elements.DEFAULT_PT_FIRE)
	end
	if nt == s then
		return 0
	end
	for r in sim.neighbors(x, y, 1, 1) do
		if sim.partProperty(r, "type") == elements.DEFAULT_PT_PLNT then
			sim.partProperty(r, "dcolour", 0xFF181818)
		end
		if sim.partProperty(r, "type") == elements.DEFAULT_PT_FIRE or sim.partProperty(r, "type") == elements.DEFAULT_PT_PLSM then
			if sim.partProperty(i, "life") == 0 then
				sim.partProperty(i, "life", math.random(180,220))
			end
		end
	end
end

local function GRPH_NEUT(i, x, y, s, nt)
	if s == nt then
		return 0
	end
	for r in sim.neighbors(x, y, 1, 1, elements.PHIMOD_PT_GRPH) do
		sim.partProperty(i, "vx", sim.partProperty(i, "vx") * 0.95)
		sim.partProperty(i, "vy", sim.partProperty(i, "vy") * 0.95)
		if math.random(100) == 1 then
			sim.partKill(i)
			return 1
		end
		return 0
	end
end

local function GRPH_METL(i, x, y, s, nt)
	if s == nt then
		return 0
	end
	if sim.partProperty(i, "ctype") == elements.DEFAULT_PT_IRON then
		for r in sim.neighbors(x, y, 2, 2, elements.PHIMOD_PT_GRPH) do
			sim.partProperty(i, "ctype", elements.DEFAULT_PT_METL)
			return 0
		end
	end
end

local function graphicsGRPH(i, colr, colg, colb)
	if sim.partProperty(i, "temp") > 1000 then
		a = (sim.partProperty(i, "temp") - 1000) / 2000
		g = (sim.partProperty(i, "temp") - 1000) / 10000
		b = (sim.partProperty(i, "temp") - 1000) / 30000
		return 0, ren.FIRE_ADD + ren.DECO_FIRE + ren.PMODE_FLAT, 255, colr, colg, colb, 255*a, 255, 255*g, 255*b
	else
		return 0, ren.PMODE_FLAT, 255, colr, colg, colb, 255, 0, 0, 0
	end
end

elements.property(new, "Update", updateGRPH)
elements.property(new, "Graphics", graphicsGRPH)
tpt.element_func(GRPH_NEUT, elements.DEFAULT_PT_NEUT)
tpt.element_func(GRPH_METL, elements.DEFAULT_PT_LAVA)

vapor = elements.allocate("PhiMod", "VAPR")
elements.element(vapor, elements.element(elements.DEFAULT_PT_WTRV))
elements.property(vapor, "Colour", 0xFF808080)
elements.property(vapor, "Name", "VAPR")
elements.property(vapor, "Description", "Vaporized graphite.")
elements.property(vapor, "Flammable", 1)
elements.property(vapor, "Explosive", 1)
elements.property(vapor, "LowTemperature", 3873.15)
elements.property(vapor, "LowTemperatureTransition", new)
elements.property(new, "HighTemperatureTransition", vapor)
elements.property(new, "HighTemperature", 3873.15)
elements.property(vapor, "Temperature", 4000)

new = elements.allocate("PhiMod", "TEGN") --Tree generator. Credits to ssccsscc.
elements.element(new, elements.element(elements.DEFAULT_PT_DMND))
elements.property(new, "Colour", elements.property(elements.DEFAULT_PT_PLNT, "Colour"))
elements.property(new, "Name", "TEGN")
elements.property(new, "Description", "Tree generator, generates fractal trees.")
elements.property(new, "Properties", 0x00004)

local function updateTEGN(i, x, y, s, nt)
	t = sim.partProperty(i, "tmp")
	t2 = sim.partProperty(i, "tmp2")
	l = sim.partProperty(i, "life")
	d = sim.partProperty(i, "ctype")
	if l < 1 then
		sim.partChangeType(i, elements.DEFAULT_PT_PLNT)
		return 0
	end
	sim.partKill(i)
	lc = 0.8 + 0.4 * math.random()
	ac = -5 + 10 * math.random()
	nx = x + t2 * math.cos(math.rad(t + ac)) * lc
	ny = y - t2 * math.sin(math.rad(t + ac)) * lc
	sim.createLine(x, y, nx, ny, 0, 0, elements.DEFAULT_PT_WOOD)
	sim.partKill(nx, ny)
	c = sim.partCreate(-1, nx, ny, elements.PHIMOD_PT_TEGN)
	sim.partProperty(c, "tmp", (t + 127 - (bit.band(d, 0xFE000)/0x2000)) % 360)
	sim.partProperty(c, "tmp2", math.floor(t2 * ((bit.band(d, 0xF0000000)/0x10000000)%16 / 16)))
	sim.partProperty(c, "life", l - 1)
	sim.partProperty(c, "ctype", d)
	sim.partKill(nx - 1, ny)
	c = sim.partCreate(-1, nx - 1, ny, elements.PHIMOD_PT_TEGN)
	sim.partProperty(c, "tmp", (t + 32 - (bit.band(d, 0x1F80)/0x80)) % 360)
	sim.partProperty(c, "tmp2", math.floor(t2 * ((bit.band(d, 0xF000000)/0x1000000)%16 / 16)))
	sim.partProperty(c, "life", l - 1)
	sim.partProperty(c, "ctype", d)
	sim.partKill(nx + 1, ny)
	c = sim.partCreate(-1, nx + 1, ny, elements.PHIMOD_PT_TEGN)
	sim.partProperty(c, "tmp", (t - bit.band(d, 0x7F)) % 360)
	sim.partProperty(c, "tmp2", math.floor(t2 * ((bit.band(d, 0xF00000)/0x100000)%16 / 16)))
	sim.partProperty(c, "life", l - 1)
	sim.partProperty(c, "ctype", d)
	return 1
end

elements.property(new, "Update", updateTEGN)
elements.property(new, "Create", function(i) sim.partProperty(i, "tmp", 90) sim.partProperty(i, "life", 8) sim.partProperty(i, "tmp2", 20) sim.partProperty(i, "ctype", 0xBBBC2D9E) end)

new = elements.allocate("PhiMod", "R110")
elements.element(new, elements.element(elements.DEFAULT_PT_DMND))
elements.property(new, "Name", "R110")
elements.property(new, "Description", "The Rule 110 cellular automaton.")
elements.property(new, "MenuSection", 12)
elements.property(new, "Colour", 0xFFD0D0EE)
elements.property(new, "Properties", 0x04004)

local function updateR110(i, x, y, s, nt)
	if sim.partProperty(i, "tmp") == 1 or sim.partProperty(i, "life") == 1 then
		return 0
	end
	l = sim.partID(x - 1, y)
	l2 = sim.partID(x - 2, y)
	r = sim.partID(x + 1, y)
	r2 = sim.partID(x + 2, y)
	if l == nil or r == nil then
		sim.partCreate(-1, x, y + 1, elements.PHIMOD_PT_R110)
	end
	if l == nil then
		sim.partCreate(-1, x - 1, y + 1, elements.PHIMOD_PT_R110)
	end
	sim.partProperty(i, "tmp", 1)
end

elements.property(new, "Update", updateR110)
elements.property(new, "Create", function(i) sim.partProperty(i, "life", 1) end)

new = elements.allocate("PhiMod", "GRSS")
elements.element(new, elements.element(elements.DEFAULT_PT_PLNT))
elements.property(new, "Name", "GRSS")
elements.property(new, "Description", "Grass. Grows on dirt.")

local function updateGRSS(i, x, y, s, nt)
	if nt == s or sim.partProperty(i, "life") > 0 then
		return 0
	end
	grow = false
	for rx = -1, 1, 1 do
		for ry = -1, 1, 1 do
			if rx == 0 or ry == 0 then
				r = sim.partID(x + rx, y + ry)
				if r ~= nil and sim.partProperty(r, "type") == elements.PHIMOD_PT_DIRT then
					sim.createBox(x + rx - 1, y + ry - 1, x + rx + 1, y + rx + 1, elements.PHIMOD_PT_GRSS)
					grow = true
				end
			end
		end
	end
	if grow then
		sim.partChangeType(i, elements.DEFAULT_PT_PLNT)
		return 0
	end
end

elements.property(new, "Update", updateGRSS)
elements.property(new, "Create", function(i) sim.partProperty(i, "life", 1) end)

new = elements.allocate("PhiMod", "LMTH")
elements.element(new, elements.element(elements.DEFAULT_PT_WATR))
elements.property(new, "Name", "LMTH")
elements.property(new, "Description", "Liquid methane. Combusts explosively.")
elements.property(new, "MenuSection", 5)
elements.property(new, "Colour", 0xFFE0E0EE)
elements.property(new, "Weight", 27)
elements.property(new, "Temperature", 100)
elements.property(new, "LowTemperature", 91.2)
elements.property(new, "HighTemperature", 111.6)
elements.property(new, "Flammable", 10000)
elements.property(new, "Explosive", 1)

new = elements.allocate("PhiMod", "SMTH")
elements.element(new, elements.element(elements.DEFAULT_PT_DMND))
elements.property(new, "Name", "SMTH")
elements.property(new, "Description", "Solid methane. Combusts extremely explosively.")
elements.property(new, "MenuSection", 5)
elements.property(new, "Colour", 0xFFE0E0EE)
elements.property(new, "Weight", 100)
elements.property(new, "Temperature", 80)
elements.property(new, "LowTemperature", -1)
elements.property(new, "HighTemperature", 91.2)
elements.property(new, "Flammable", 20000)
elements.property(new, "Explosive", 1)

new = elements.allocate("PhiMod", "METH")
elements.element(new, elements.element(elements.DEFAULT_PT_HYGN))
elements.property(new, "Name", "METH")
elements.property(new, "Description", "Gaseous methane. Combusts explosively.")
elements.property(new, "MenuSection", 5)
elements.property(new, "Colour", 0xFFE0E0EE)
elements.property(new, "LowTemperature", 111.6)
elements.property(new, "LowTemperatureTransition", elements.PHIMOD_PT_LMTH)
elements.property(new, "Flammable", 2000)
elements.property(new, "Explosive", 1)
elements.property(elements.PHIMOD_PT_LMTH, "HighTemperatureTransition", new)
elements.property(elements.PHIMOD_PT_SMTH, "HighTemperatureTransition", elements.PHIMOD_PT_LMTH)
elements.property(elements.PHIMOD_PT_LMTH, "LowTemperatureTransition", elements.PHIMOD_PT_SMTH)

--Sabatier reaction: CO2 + 4H2 => CH4 + 2H2O

local function sabatier(i, x, y, s, nt)
	if sim.partProperty(i, "temp") < 600 or sim.pressure(x/4, y/4) < 1 then
		return 0
	end
	if s == nt then
		return 0
	end
	c = -1
	h = -1
	for r in sim.neighbors(x, y, 1, 1) do
		if h == -1 and sim.partProperty(r, "type") == elements.DEFAULT_PT_H2 then
			h = r
		end
		if c == -1 and sim.partProperty(r, "type") == elements.DEFAULT_PT_CO2 then
			c = r
		end
		if h ~= -1 and c ~= -1 then break end
	end
	if h ~= -1 and c ~= -1 then
		sim.partChangeType(h, elements.PHIMOD_PT_METH)
		sim.partChangeType(c, elements.DEFAULT_PT_WTRV)
		sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 100)
	end
end

tpt.element_func(sabatier, elements.DEFAULT_PT_PTNM)

local function anthracite(i, x, y, s, nt) --COAL or BCOL below -20 pressure and above 1000C will turn into GRPH
	if sim.pressure(x/4,y/4) < -20 and sim.partProperty(i, "temp") > 1273.15 then
		sim.partChangeType(i, elements.PHIMOD_PT_GRPH)
		sim.partProperty(i, "life", 0)
		sim.partProperty(i, "tmp", 0)
		return 0
	end
end

tpt.element_func(anthracite, elements.DEFAULT_PT_COAL)
tpt.element_func(anthracite, elements.DEFAULT_PT_BCOL)

new = elements.allocate("PhiMod", "HLID")
elements.element(new,elements.element(elements.DEFAULT_PT_BRAY))
elements.property(new, "Name", "HLID")
elements.property(new, "Description", "High life DEUT.")
elements.property(new, "MenuSection", 10)
elements.property(new, "MenuVisible", 1)
elements.property(new, "Create", function(i) sim.partProperty(i, "life", 65535) sim.partChangeType(i, elements.DEFAULT_PT_DEUT) end)

new = elements.allocate("PhiMod","2EAQ")
elements.element(new,elements.element(elements.DEFAULT_PT_STNE))
elements.property(new, "Name", "2EAQ")
elements.property(new, "Description", "2-Ethylanthraquinone. Used to produce MONO.")
elements.property(new, "Colour", 0xFFFFFFDD)
elements.property(new, "HighTemperature", 378)

tpt.element_func(
	function(i, x, y, s, nt)
		if s == nt then
			return 0
		end
		h = -1
		for r in sim.neighbors(x, y, 2, 2, elements.DEFAULT_PT_H2) do
			h = r
			break
		end
		for r in sim.neighbors(x, y) do
			if sim.partProperty(r, "tmp") == 0 and sim.partProperty(r, "type") == elements.PHIMOD_PT_2EAQ and h > 0 then
				sim.partProperty(r, "tmp", 1)
				sim.partKill(h)
				break
			end
		end
	end,
	elements.DEFAULT_PT_PTNM)

local function update2EAQ(i, x, y, s, nt)
	if sim.partProperty(i, "tmp") == 0 or s == nt then
		return 0
	end
	for r in sim.neighbors(x, y, 2, 2, elements.DEFAULT_PT_O2) do 
		sim.partProperty(i, "tmp", 0)
		sim.partChangeType(r, elements.PHIMOD_PT_FUEL)
		break
	end
end

elements.property(new, "Update", update2EAQ)
elements.property(elements.DEFAULT_PT_DEUT, "Weight", 30)

new = elements.allocate("PhiMod", "MEAT")
elements.element(new, elements.element(elements.DEFAULT_PT_HEAC))
elements.property(new, "Name", "MEAT")
elements.property(new, "Description", "Meat. Living, can be used to make creatures.")
elements.property(new, "Colour", 0x946450)
elements.property(new, "Create", function(i) sim.partProperty(i, "life", math.random(800, 1200)) sim.partProperty(i, "tmp", 100) end)
elements.property(new, "Properties", 0x4204)
elements.property(new, "Flammable", 1)
elements.property(new, "Explosive", 1)

local function killMEAT(i)
	sim.partProperty(i, "ctype", 1)
end

local function updateMEAT(i, x, y, s, nt)
	if sim.partProperty(i, "temp") > sim.partProperty(i, "tmp2") then
		sim.partProperty(i, "tmp2", sim.partProperty(i, "temp"))
	end
	if sim.partProperty(i, "ctype") == 1 then
		return 0
	end
	if sim.partProperty(i, "life") <= 0 or sim.partProperty(i, "temp") > 573 or sim.partProperty(i, "temp") < 283 then
		killMEAT(i)
		return 0
	end
	if sim.partProperty(i, "life") > 50 and math.random(100) == 1 then
		sim.partProperty(i, "tmp", sim.partProperty(i, "tmp") - 1)
		if sim.partProperty(i,"tmp") <= 0 then
			killMEAT(i)
			return 0
		end
	end
	if nt == s then
		return 0
	end
	for r in sim.neighbors(x, y) do
		if sim.partProperty(r, "type") == elements.DEFAULT_PT_O2 then
			sim.partProperty(i, "life", 1000)
			sim.partChangeType(r, elements.DEFAULT_PT_CO2)
			return 0
		elseif sim.partProperty(r, "type") == elements.PHIMOD_PT_FOOD and sim.partProperty(i, "tmp") < 80 then
			sim.partProperty(i, "tmp", 100)
			sim.partChangeType(r, elements.PHIMOD_PT_WSTE)
			return 0
		end
	end
end

local function graphicsMEAT(i, colr, colg, colb)
	f = clamp(sim.partProperty(i, "tmp")/3600 + sim.partProperty(i, "life")/4500 + 1.3 - (sim.partProperty(i, "tmp2") - 273)/330, 0.2, 1.8)
	gb = clamp(f, 0, 1)
	ff = clamp((273.15 - sim.partProperty(i, "temp")) * 10, 0, 255)
	if sim.partProperty(i, "ctype") == 1 then
		f = f * 0.8
	end
	return 0, ren.PMODE_FLAT, 255, colr * f + 0.5 * ff, colg * gb + ff, colb * gb + ff, 255, 0, 0, 0	
end

local function rads(i, x, y, s, nt)
	if s == nt then return 0 end
	for r in sim.neighbors(x, y, 2, 2, elements.PHIMOD_PT_MEAT) do
		killMEAT(r)
	end
end

local function eatMEAT(i, x, y, s, nt) --STKM can eat MEAT.
	l = sim.partProperty(i, "life")
	if l == 100 then
		return 0
	end
	for r in sim.neighbors(x, y, 2, 2, elements.PHIMOD_PT_MEAT) do
		t = sim.partProperty(r, "tmp2") - 273.15
		lg = -5 + 0.01 * t - 0.00002 * t * t + 10 * sim.partProperty(r, "ctype")
		sim.partProperty(i, "life", clamp(l + lg, 0, 100))
		sim.partKill(r)
		return 0
	end
end

elements.property(new, "Update", updateMEAT)
elements.property(new, "Graphics", graphicsMEAT)
tpt.element_func(rads, elements.DEFAULT_PT_NEUT)
tpt.element_func(eatMEAT, elements.DEFAULT_PT_STKM)

new = elements.allocate("PhiMod", "FOOD")
elements.element(new, elements.element(elements.DEFAULT_PT_GEL))
elements.property(new, "Name", "FUD")
elements.property(new, "Description", "Food. Eaten by MEAT.")
elements.property(new, "Flammable", 20)
elements.property(new, "Explosive", 1)
elements.property(new, "Colour", 0xF07D43)

new = elements.allocate("PhiMod", "BACT")
elements.element(new, elements.element(elements.DEFAULT_PT_WATR))
elements.property(new, "Name", "BACT")
elements.property(new, "Description", "Bacteria. Forms complex colonies. Feed it FUD.")
elements.property(new, "Colour", 0xFFFFFF)
elements.property(new, "Weight", 20)
elements.property(new, "HighTemperatureTransition", elements.DEFAULT_PT_BIZR)
elements.property(new, "HighTemperature", 383.15)
elements.property(new, "Flammable", 10)
elements.property(new, "Properties", 0x202)
elements.property(new, "Create",
	function(i)
		sim.partProperty(i, "tmp", 100) sim.partProperty(i, "ctype", 1)
	end)

local function updateBACT(i, x, y, s, nt)
	f = sim.partProperty(i, "tmp")
	g = sim.partProperty(i, "ctype")
	if f < 0 then --Dying.
		sim.partChangeType(r, elements.DEFAULT_PT_BIZR)
		return 0
	end
	if math.random(1000) == 1 then --BACT shouldn't need too much FUD, as it becomes too difficult.
		sim.partProperty(i, "tmp", f - 1 - bit.band(g, 16)/16 - bit.band(g, 8)/8 - bit.band(g,4)/4 - bit.band(g, 2)/2 - bit.band(g, 32)/32 - bit.band(g, 64)/64 - bit.band(g, 128)/128 - bit.band(g, 256)/256)
		return 0
	end
	if s > 2 then
		if f > 50 and math.random(10) == 1 then --Creating OIL and SOAP, to keep the colony in shape.
			if math.random(2) == 1 then
				sim.createBox(x - 1, y - 1, x + 1, y + 1, elem.DEFAULT_PT_OIL)
				sim.partProperty(i, "tmp", sim.partProperty(i, "tmp") - 40)
			else
				sim.createBox(x - 1, y - 1, x + 1, y + 1, elem.DEFAULT_PT_SOAP)
				sim.partProperty(i, "tmp", sim.partProperty(i, "tmp") - 40)
			end
		elseif f > 80 and math.random(2) == 1 then --Replication with mutations.
			rx = math.random(-1, 1)
			ry = math.random(-1, 1)
			r = sim.partID(x + rx, y + ry)
			sim.partKill(r)
			c = sim.partCreate(-1, x + rx, y + ry, elem.PHIMOD_PT_BACT)
			sim.partProperty(c, "tmp", f / 2)
			if math.random(20) == 1 then
				sim.partProperty(c, "ctype", bit.bxor(g, bit.lshift(1, math.random(0,8))))
			else
				sim.partProperty(c, "ctype", g)
			end
			sim.partProperty(i, "tmp", f / 2)
		end
	end
	rx = math.random(-1, 1)
	ry = math.random(-1, 1)
	r = sim.partID(x + rx, y + ry)
	if r ~= nil then --Eating.
		if (sim.partProperty(r, "type") == elements.DEFAULT_PT_OIL or sim.partProperty(r, "type") == elements.DEFAULT_PT_SOAP) and f < 10 then
			sim.partKill(r)
			sim.partProperty(i, "tmp", f + 5)
			return 0
		elseif bit.band(g, 16) == 16 and sim.partProperty(r, "type") == elements.DEFAULT_PT_BIZR then --BIZR is basically dead bacteria...
			sim.partKill(r)
			sim.partProperty(i, "tmp", f + 5)
			return 0
		elseif bit.band(g, 8) == 8 and (sim.partProperty(r, "type") == elements.DEFAULT_PT_MWAX or sim.partProperty(r, "type") == elements.DEFAULT_PT_WAX) then
			sim.partKill(r)
			sim.partProperty(i, "tmp", f + 15)
			return 0
		elseif bit.band(g, 4) == 4 and sim.partProperty(r, "type") == elements.DEFAULT_PT_NITR then
			sim.partKill(r)
			sim.partProperty(i, "tmp", f + 25)
			return 0
		elseif bit.band(g, 2) == 2 and sim.partProperty(r, "type") == elements.DEFAULT_PT_DESL then
			sim.partKill(r)
			sim.partProperty(i, "tmp", f + 15)
			return 0
		end
	end
	rx = math.random(-1, 1)
	ry = math.random(-1, 1)
	r = sim.partID(x + rx, y + ry)
	if r ~= nil and sim.partProperty(r, "type") == elements.PHIMOD_PT_BACT and sim.partProperty(r, "tmp") < f then --Food diffusing.
		sim.partProperty(i, "tmp", sim.partProperty(i, "tmp") - 1)
		sim.partProperty(r, "tmp", sim.partProperty(r, "tmp") + 1)
	end
	if s == nt or bit.band(g, 1) == 0 then return 0 end
	ivx = sim.partProperty(i, "vx") --Sticky BACT.
	ivy = sim.partProperty(i, "vy")
	for r in sim.neighbors(x, y) do
		if sim.partProperty(r, "type") == elements.DEFAULT_PT_OIL then
			rvx = sim.partProperty(r, "vx") --Sticking, as described in SOAP.cpp.
			rvy = sim.partProperty(r, "vy")
			ax = (ivx * 0.5 + rvx) / 2
			ay = ((ivy - 0.1) * 0.5 + rvy) / 2
			sim.partProperty(i, "vx", ax)
			sim.partProperty(i, "vy", ay)
			sim.partProperty(r, "vx", ax)
			sim.partProperty(r, "vy", ay)
		elseif sim.partProperty(r, "type") == elements.PHIMOD_PT_FOOD then
			sim.partKill(r)
			sim.partProperty(i, "tmp", 100)
		end
	end
end

local function graphicsBACT(i, colr, colg, colb)
	f = sim.partProperty(i, "tmp") / 100
	return 0, ren.PMODE_FLAT + ren.PMODE_BLUR, 255, f * 255, f * 255, f * 255, 255, 255, 255, 255
end

elements.property(new, "Graphics", graphicsBACT)
elements.property(new, "Update", updateBACT)

new = elements.allocate("PhiMod", "CSNS")
elements.element(new, elements.element(elements.DEFAULT_PT_VSNS))
elements.property(new, "Name", "CSNS")
elements.property(new, "Colour", 0x8000FF)
elements.property(new, "Description", "Ctype sensor. Detects if an element's ctype aligns with its own. Can output data to FILT.")

local function createCSNS(i, x, y, s, nt)
	sim.partProperty(i, "tmp2", 2) sim.partProperty(i, 'tmp', 1)
end

local function updateCSNS(i, x, y, s, nt)
	if nt == s then
		return 0
	end
	dr = sim.partProperty(i, "tmp2")
	c = sim.partProperty(i, "ctype")
	bn = sim.partProperty(i, "tmp")
	nc = -1
	spark = false
	for r in sim.neighbors(x, y, dr, dr) do
		cr = bit.band(sim.partProperty(r, "ctype"), c)
		nr = bit.bor(sim.partProperty(r, "ctype"), c)
		if (bit.band(bn, 1) == 1 or (nr == c)) and (bit.band(bn, 2) or (cr == c)) and cr > 0 and sim.partProperty(r, "type") ~= elem.PHIMOD_PT_CSNS then
			spark = true
			break
		end
	end
	if bit.band(bn, 4) == 4 then
		for r in sim.neighbors(x, y, dr, dr) do
			if sim.partProperty(r, "type") ~= elements.PHIMOD_PT_CSNS then
				nc = sim.partProperty(r, "ctype")
				break
			end
		end
		if nc ~= -1 then
			for r in sim.neighbors(x, y) do
				if sim.partProperty(r, "type") == elem.DEFAULT_PT_FILT then
					sim.partProperty(r, "ctype", nc)
				end
			end
		end
	end
	if not spark then
		return 0
	end
	for r in sim.neighbors(x, y) do
		rt = sim.partProperty(r, "type")
		if sim.partProperty(r, "life") == 0 and bit.band(elements.property(rt, "Properties"), 32) == 32 and (rt ~= elem.DEFAULT_PT_WATR and rt ~= elem.DEFAULT_PT_SLTW and rt ~= elem.DEFAULT_PT_NTCT and rt ~= elem.DEFAULT_PT_PTCT and rt ~= elem.DEFAULT_PT_INWR) then
			sim.partProperty(r, "life", 4)
			sim.partProperty(r, "ctype", rt)
			sim.partChangeType(r, elem.DEFAULT_PT_SPRK)
		end
	end
end

elements.property(new, "Create", createCSNS)
elements.property(new, "Update", updateCSNS)

new = elements.allocate("PhiMod", "CSOR")
elements.element(new, elements.element(elements.DEFAULT_PT_STOR))
elements.property(new, "Name", "CSOR")
elements.property(new, "Description", "Ctype sorter. Only lets in particles with the same ctype.")
elements.property(new, "Colour", 0x5050DF)
elements.property(new, "Create", function(i)
	sim.partProperty(i, "tmp", -1)
end)

local function updateCSOR(i, x, y, s, nt)
	if s == nt then
		return 0
	end
	for r in sim.neighbors(x, y) do
		rt = sim.partProperty(r, "type")
		if rt == elements.DEFAULT_PT_SPRK and sim.partProperty(r, "ctype") == elements.DEFAULT_PT_PSCN then
			--Release a single particle.
			for rx = -1, 1 do
				for ry = -1, 1 do
					sp = sim.partID(x + rx, y + ry)
					if sp == nil and sim.partProperty(i, "tmp") ~= -1 then
						c = sim.partCreate(-1, x + rx, y + ry, sim.partProperty(i, "tmp"))
						sim.partProperty(c, "temp", sim.partProperty(i, "temp"))
						sim.partProperty(c, "ctype", sim.partProperty(i, "tmp2"))
						sim.partProperty(c, "life", sim.partProperty(i, "life"))
						sim.partProperty(i, "tmp", -1)
						return 0
					end
				end
			end
		elseif sim.partProperty(i,"tmp") == -1 and sim.partProperty(r, "ctype") == sim.partProperty(i, "ctype") and bit.band(elements.property(rt, "Properties"),4) == 0 then
			--Absorb a particle.
			sim.partProperty(i, "tmp", rt)
			sim.partProperty(i, "temp", sim.partProperty(r, "temp"))
			sim.partProperty(i, "tmp2", sim.partProperty(r, "ctype"))
			sim.partProperty(i, "life", sim.partProperty(r, "life")) --Sorry, doesn't store the tmp of a particle, since there are not enough properties.
			sim.partKill(r)
		end
	end
end

local function graphicsCSOR(i, colr, colg, colb)
	if sim.partProperty(i, "tmp") ~= -1 then
		f = 1.5
	else
		f = 1
	end
	return 0, ren.PMODE_FLAT, 255, colr * f, colg * f, colb * f, 255, 255, 255, 255
end

elements.property(new, "Update", updateCSOR)
elements.property(new, "Graphics", graphicsCSOR)

new = elements.allocate("PhiMod", "WSTE")
elements.element(new, elements.element(elements.DEFAULT_PT_WATR))
elements.property(new, "Name", "WSTE")
elements.property(new, "Description", "Chemical waste. Formed from various reactions.")
elements.property(new, "Colour", 0x235532)
elements.property(new, "Properties", 0x482)
elements.property(new, "Weight", 20)

new = elements.allocate("PhiMod", "PHOE")
elements.element(new, elements.element(elements.DEFAULT_PT_TTAN))
elements.property(new, "Name", "PHOE")
elements.property(new, "Description", "Diphenyl oxalate. Glows with MONO.")
elements.property(new, "Colour", 0xFFFDE0)
elements.property(new, "HighTemperature", 409)
elements.property(new, "Properties", 0x504)

local function updatePHOE(i, x, y, s, nt)
	if s == nt then
		return 0
	end
	for r in sim.neighbors(x, y, 1, 1, elements.PHIMOD_PT_FUEL) do
		if math.random(5) == 1 then
			sim.partChangeType(i, elements.PHIMOD_PT_WSTE)
		else
			sim.partChangeType(i, elements.DEFAULT_PT_PHOT)
		end
		sim.partChangeType(r, elements.DEFAULT_PT_PHOT)
		sim.partProperty(r, "life", math.random(600,800))
		sim.partProperty(r, "ctype", 0x0007C000)
		sim.partProperty(r, "vx", math.random(-1,1))
		sim.partProperty(r, "vy", math.random(-1,1))
		sim.partProperty(i, "temp", sim.partProperty(i, "temp") + 1)
		return 0
	end
end

elements.property(elements.PHIMOD_PT_PHOE, "Update", updatePHOE)

new = elements.allocate("PhiMod", "ANTI")
elements.element(new, elements.element(elements.DEFAULT_PT_WATR))
elements.property(new, "Name", "ANTI")
elements.property(new, "Description", "Antibiotic. Can kill bacteria, but beware of antibiotic resistance.")
elements.property(new, "Colour", 0xFFCCCC)
elements.property(new, "Weight", 35)
elements.property(new, "Properties", 0x102)
elements.property(new, "Create", function(i) sim.partProperty(i, "tmp", 10) end)

local function updateANTI(i, x, y, s, nt)
	if s == nt then
		return 0
	end
	e = sim.partProperty(i, "tmp") / 100
	for r in sim.neighbors(x, y, 1, 1) do
		rt = sim.partProperty(r, "type")
		if rt == elements.PHIMOD_PT_BACT then
			if bit.band(sim.partProperty(r, "ctype"), 480) * math.random() < 32 * e then --Antibiotics can have a variety of effectivenesses, but bacteria can have varying levels of resistance.
				sim.partChangeType(r, elements.DEFAULT_PT_BIZR)
				sim.partKill(i)
				return 1
			end
		end
		if rt == elements.PHIMOD_PT_MEAT or rt == elements.DEFAULT_PT_BIZR then --Diffusion into meat and BIZR.
			if math.random(8000) == 1 then
				sim.partKill(i)
				return 1
			end
		end
	end
end

elements.property(new, "Update", updateANTI)

Description:

Changelog: