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:
-- cxi's Element Creator
-- Version 1.0 August 12 2016
-- This code is released under the MIT license
 
function round(num, dp)
    local mult = 10^(dp or 0)
    return math.floor(num * mult + 0.5) / mult
end
 
local element = elem.allocate("CXI", "ELEM")
 
elem.element(element, elem.element(elem.DEFAULT_PT_DMND))
elem.property(element, "Name", "ELEM")
elem.property(element, "Colour", 0xFFFFFF)
elem.property(element, "Description", "Element created using cxi's element creator. Press N to open.")
elem.property(element, "MenuSection", elem.SC_SPECIAL)
 
local width = 600
local height = 342
 
local exportwidth = 570
local exportheight = 88
 
local window = Window:new(14, 38, width, height)
local exportwindow = Window:new(29, 165, exportwidth, exportheight)
 
local clrlabel = Label:new(270, 316, 32, 16, "Color:")
window:addComponent(clrlabel)
local colortext = Textbox:new(306, 316, 50, 16, "ffffff", "")
window:addComponent(colortext)
 
local y = 30
 
local advlabel = Label:new(10, y, width / 2 - 20, 16, "Advection - how much air movement affects a particle.")
window:addComponent(advlabel)
local advectiontext = Textbox:new(10, y + 20, width / 2 - 20, 16, "0.4", "")
window:addComponent(advectiontext)
y = y + 40
 
local adrlabel = Label:new(10, y, width / 2 - 20, 16, "AirDrag - how much air a particle moves when moving.")
window:addComponent(adrlabel)
local airdragtext = Textbox:new(10, y + 20, width / 2 - 20, 16, "0.01", "")
window:addComponent(airdragtext)
y = y + 40
 
local allabel = Label:new(10, y, width / 2 - 20, 16, "AirLoss - how much a particle slows down moving air.")
window:addComponent(allabel)
local airlosstext = Textbox:new(10, y + 20, width / 2 - 20, 16, "0.94", "")
window:addComponent(airlosstext)
y = y + 40
 
local llabel = Label:new(10, y, width / 2 - 20, 16, "Loss - how much the speed a particle retains each frame.")
window:addComponent(llabel)
local losstext = Textbox:new(10, y + 20, width / 2 - 20, 16, "0.95", "")
window:addComponent(losstext)
y = y + 40
 
local collabel = Label:new(10, y, width / 2 - 20, 16, "Collision - how a particle moves when it collides.")
window:addComponent(collabel)
local collisiontext = Textbox:new(10, y + 20, width / 2 - 20, 16, "-0.1", "")
window:addComponent(collisiontext)
y = y + 40
 
local grvlabel = Label:new(10, y, width / 2 - 20, 16, "Gravity - how fast a particle falls.")
window:addComponent(grvlabel)
local gravitytext = Textbox:new(10, y + 20, width / 2 - 20, 16, "-0.1", "")
window:addComponent(gravitytext)
y = y + 40
 
local diflabel = Label:new(10, y, width / 2 - 20, 16, "Diffusion - how much a particle wiggles.")
window:addComponent(diflabel)
local diffusiontext = Textbox:new(10, y + 20, width / 2 - 20, 16, "0", "")
window:addComponent(diffusiontext)
y = 30
 
local htalabel = Label:new(width / 2 + 10, y, width / 2 - 20, 16, "HotAir - how much a particle increases the pressure by.")
window:addComponent(htalabel)
local hotairtext = Textbox:new(width / 2 + 10, y + 20, width / 2 - 20, 16, "0", "")
window:addComponent(hotairtext)
y = y + 40
 
local explabel = Label:new(width / 2 + 10, y, width / 2 - 20, 16, "Explosive - 0: none, 1: fire, 2: pressure > 2.5 or fire.")
window:addComponent(explabel)
local explosivetext = Textbox:new(width / 2 + 10, y + 20, width / 2 - 20, 16, "0", "")
window:addComponent(explosivetext)
y = y + 40
 
local fllabel = Label:new(width / 2 + 10, y, width / 2 - 20, 16, "Flammable - how well the element burns.")
window:addComponent(fllabel)
local flammabletext = Textbox:new(width / 2 + 10, y + 20, width / 2 - 20, 16, "0", "")
window:addComponent(flammabletext)
y = y + 40
 
local hdlabel = Label:new(width / 2 + 10, y, width / 2 - 20, 16, "Hardness - how quickly ACID dissolves the element.")
window:addComponent(hdlabel)
local hardnesstext = Textbox:new(width / 2 + 10, y + 20, width / 2 - 20, 16, "0", "")
window:addComponent(hardnesstext)
y = y + 40
 
local wtlabel = Label:new(width / 2 + 10, y, width / 2 - 20, 16, "Weight - how heavy the element is.")
window:addComponent(wtlabel)
local weighttext = Textbox:new(width / 2 + 10, y + 20, width / 2 - 20, 16, "0", "")
window:addComponent(weighttext)
y = y + 40
 
local hclabel = Label:new(width / 2 + 10, y, width / 2 - 20, 16, "Heat conductivity - 0 to 255.")
window:addComponent(hclabel)
local heatconducttext = Textbox:new(width / 2 + 10, y + 20, width / 2 - 20, 16, "0", "")
window:addComponent(heatconducttext)
y = y + 40
 
local itlabel = Label:new(width / 2 + 10, y, width / 2 - 20, 16, "Initial temperature in Kelvin.")
window:addComponent(itlabel)
local temperaturetext = Textbox:new(width / 2 + 10, y + 20, width / 2 - 20, 16, "0", "")
window:addComponent(temperaturetext)
 
local function updateproperties(sender)
    elem.property(element, "Color", tonumber(colortext:text():lower(), 16))
    elem.property(element, "Advection", tonumber(advectiontext:text()))
    elem.property(element, "AirDrag", tonumber(airdragtext:text()))
    elem.property(element, "AirLoss", tonumber(airlosstext:text()))
    elem.property(element, "Loss", tonumber(losstext:text()))
    elem.property(element, "Collision", tonumber(collisiontext:text()))
    elem.property(element, "Gravity", tonumber(gravitytext:text()))
    elem.property(element, "Diffusion", tonumber(diffusiontext:text()))
    elem.property(element, "HotAir", tonumber(hotairtext:text()))
    elem.property(element, "Explosive", tonumber(explosivetext:text()))
    elem.property(element, "Flammable", tonumber(flammabletext:text()))
    elem.property(element, "Hardness", tonumber(hardnesstext:text()))
    elem.property(element, "Weight", tonumber(weighttext:text()))
    elem.property(element, "HeatConduct", tonumber(heatconducttext:text()))
    elem.property(element, "Temperature", tonumber(temperaturetext:text()))
end
 
colortext:onTextChanged(updateproperties)
advectiontext:onTextChanged(updateproperties)
airdragtext:onTextChanged(updateproperties)
airlosstext:onTextChanged(updateproperties)
losstext:onTextChanged(updateproperties)
collisiontext:onTextChanged(updateproperties)
gravitytext:onTextChanged(updateproperties)
diffusiontext:onTextChanged(updateproperties)
hotairtext:onTextChanged(updateproperties)
explosivetext:onTextChanged(updateproperties)
flammabletext:onTextChanged(updateproperties)
hardnesstext:onTextChanged(updateproperties)
weighttext:onTextChanged(updateproperties)
heatconducttext:onTextChanged(updateproperties)
temperaturetext:onTextChanged(updateproperties)
 
local x = 10
local w = 48
local buttons = {}
 
local solidbutton = Button:new(x, 316, w, 16, "Solid")
window:addComponent(solidbutton)
x = x + w - 1
buttons["Solid"] = solidbutton
 
local powderbutton = Button:new(x, 316, w, 16, "Powder")
window:addComponent(powderbutton)
x = x + w - 1
buttons["Powder"] = powderbutton
 
local liquidbutton = Button:new(x, 316, w, 16, "Liquid")
window:addComponent(liquidbutton)
x = x + w - 1
buttons["Liquid"] = liquidbutton
 
local gasbutton = Button:new(x, 316, w, 16, "Gas")
window:addComponent(gasbutton)
x = x + w - 1
buttons["Gas"] = gasbutton
 
local energybutton = Button:new(x, 316, w, 16, "Energy")
window:addComponent(energybutton)
x = x + w - 1
buttons["Energy"] = energybutton
 
local function settype(sender)
    if sender:text() == solidbutton:text() then
        elem.property(element, "Properties", elem.TYPE_SOLID)
        elem.property(element, "Falldown", 0)
    end
    if sender:text() == powderbutton:text() then
        elem.property(element, "Properties", elem.TYPE_PART)
        elem.property(element, "Falldown", 1)
    end
    if sender:text() == liquidbutton:text() then
        elem.property(element, "Properties", elem.TYPE_LIQUID)
        elem.property(element, "Falldown", 2)
    end
    if sender:text() == gasbutton:text() then
        elem.property(element, "Properties", elem.TYPE_GAS)
        elem.property(element, "Falldown", 0)
    end
    if sender:text() == energybutton:text() then
        elem.property(element, "Properties", elem.TYPE_ENERGY)
        elem.property(element, "Falldown", 0)
    end
    for i, button in pairs(buttons) do
        if string.find(sender:text(), i) then
            button:text("[" .. i .. "]")
        else
            button:text(i)
        end
    end
end
 
solidbutton:action(settype)
powderbutton:action(settype)
liquidbutton:action(settype)
gasbutton:action(settype)
energybutton:action(settype)
 
local function loadelement(sender)
    local e = assert(loadstring("return elem.DEFAULT_PT_" .. sender:text():upper()), nil)()
    if e ~= nil then
        local type = bit.band(elem.property(e, "Properties"), 31)
        elem.property(element, "Properties", type)
        if type == elem.TYPE_SOLID then
            settype(solidbutton)
        elseif type == elem.TYPE_PART then
            settype(powderbutton)
        elseif type == elem.TYPE_LIQUID then
            settype(liquidbutton)
        elseif type == elem.TYPE_GAS then
            settype(gasbutton)
        elseif type == elem.TYPE_ENERGY then
            settype(energybutton)
        end
        elem.property(element, "Falldown", elem.property(e, "Falldown"))
        colortext:text(string.format("%x", elem.property(e, "Color")))
        advectiontext:text(round(elem.property(e, "Advection"), 7))
        airdragtext:text(round(elem.property(e, "AirDrag"), 7))
        airlosstext:text(round(elem.property(e, "AirLoss"), 7))
        losstext:text(round(elem.property(e, "Loss"), 7))
        collisiontext:text(round(elem.property(e, "Collision"), 7))
        gravitytext:text(round(elem.property(e, "Gravity"), 7))
        diffusiontext:text(round(elem.property(e, "Diffusion"), 7))
        hotairtext:text(round(elem.property(e, "HotAir"), 7))
        explosivetext:text(round(elem.property(e, "Explosive"), 0))
        flammabletext:text(round(elem.property(e, "Flammable"), 0))
        hardnesstext:text(round(elem.property(e, "Hardness"), 0))
        weighttext:text(round(elem.property(e, "Weight"), 0))
        heatconducttext:text(round(elem.property(e, "HeatConduct"), 0))
        temperaturetext:text(round(elem.property(e, "Temperature"), 2))
        updateproperties()
    end
end
 
local loadlabel = Label:new(10, 10, 180, 16, "Load properties from existing element:")
window:addComponent(loadlabel)
local loadtext = Textbox:new(196, 10, 64, 16, "DUST", "")
loadtext:onTextChanged(loadelement)
window:addComponent(loadtext)
 
local function export(sender)
    ui.showWindow(exportwindow)
end
 
local exportbutton = Button:new(width - 110, height - 26, 100, 16, "Export code...")
exportbutton:action(export)
window:addComponent(exportbutton)
 
window:onTryExit(function()
    tpt.active_menu(elem.SC_SPECIAL)
    ui.closeWindow(window)
end)
 
local namespace = Textbox:new(10, 10, 120, 16, "", "Namespace")
exportwindow:addComponent(namespace)
local name = Textbox:new(130, 10, 120, 16, "", "1-4 character name")
exportwindow:addComponent(name)
local description = Textbox:new(10, 36, exportwidth - 20, 16, "", "Description")
exportwindow:addComponent(description)
local addtemplates = Checkbox:new(10, 62, exportwidth / 2 - 20, 16, "Include templates for update and graphics functions")
exportwindow:addComponent(addtemplates)
 
local function exportlua(sender)
    local namespacestr = namespace:text():upper()
    local namestr = name:text():upper()
 
    if namespacestr:gsub("%s+", "") == "" or namestr:gsub("%s+", "") == "" or description:text():gsub("%s+", "") == "" then
        tpt.message_box("Error", "Missing required fields.")
        return
    end
 
    local elementconstant = "elem." .. namespacestr .. "_PT_" .. namestr
    local state = ""
    local properties = ""
 
    local type = bit.band(elem.property(element, "Properties"), 31)
    if type == elem.TYPE_SOLID then
        state = "elem.ST_SOLID"
        properties = "elem.TYPE_SOLID"
    elseif type == elem.TYPE_PART then
        state = "elem.ST_SOLID"
        properties = "elem.TYPE_PART"
    elseif type == elem.TYPE_LIQUID then
        state = "elem.ST_LIQUID"
        properties = "elem.TYPE_LIQUID"
    elseif type == elem.TYPE_GAS then
        state = "elem.ST_GAS"
        properties = "elem.TYPE_GAS"
    elseif type == elem.TYPE_ENERGY then
        state = "elem.ST_NONE"
        properties = "elem.TYPE_ENERGY"
    end
 
    local code = string.format([[elem.allocate("%s", "%s")
elem.element(%s, elem.element(elem.DEFAULT_PT_DMND))
 
elem.property(%s, "Name", "%s")
elem.property(%s, "Description", "%s")
elem.property(%s, "Colour", 0x%x)
elem.property(%s, "MenuVisible", 1)
elem.property(%s, "MenuSection", SC_SPECIAL)
 
elem.property(%s, "Advection", %s)
elem.property(%s, "AirDrag", %s)
elem.property(%s, "AirLoss", %s)
elem.property(%s, "Loss", %s)
elem.property(%s, "Collision", %s)
elem.property(%s, "Gravity", %s)
elem.property(%s, "Diffusion", %s)
elem.property(%s, "HotAir", %s)
 
elem.property(%s, "Explosive", %s)
elem.property(%s, "Flammable", %s)
elem.property(%s, "Hardness", %s)
elem.property(%s, "Meltable", 0)
elem.property(%s, "Weight", %s)
 
elem.property(%s, "HeatConduct", %s)
elem.property(%s, "Temperature", %s)
 
elem.property(%s, "Falldown", %s)
elem.property(%s, "State", %s)
elem.property(%s, "Properties", %s)
 
elem.property(%s, "LowPressure", IPL)
elem.property(%s, "LowPressureTransition", NT)
elem.property(%s, "HighPressure", IPH)
elem.property(%s, "HighPressureTransition", NT)
elem.property(%s, "LowTemperature", ITL)
elem.property(%s, "LowTemperatureTransition", NT)
elem.property(%s, "HighTemperature", ITH)
elem.property(%s, "HighTemperatureTransition", NT)]], namespacestr, namestr, elementconstant, elementconstant, namestr, elementconstant, description:text(), elementconstant, elem.property(element, "Color"), elementconstant, elementconstant, elementconstant, round(elem.property(element, "Advection"), 7), elementconstant, round(elem.property(element, "AirDrag"), 7), elementconstant, round(elem.property(element, "AirLoss"), 7), elementconstant, round(elem.property(element, "Loss"), 7), elementconstant, round(elem.property(element, "Collision"), 7), elementconstant, round(elem.property(element, "Gravity"), 7), elementconstant, round(elem.property(element, "Diffusion"), 7), elementconstant, round(elem.property(element, "HotAir"), 7), elementconstant, round(elem.property(element, "Explosive"), 0), elementconstant, round(elem.property(element, "Flammable"), 0), elementconstant, round(elem.property(element, "Hardness"), 0), elementconstant, elementconstant, round(elem.property(element, "Weight"), 0), elementconstant, round(elem.property(element, "HeatConduct"), 0), elementconstant, round(elem.property(element, "Temperature"), 2), elementconstant, elem.property(element, "Falldown"), elementconstant, state, elementconstant, properties, elementconstant, elementconstant, elementconstant, elementconstant, elementconstant, elementconstant, elementconstant, elementconstant)
 
    if addtemplates:checked() then
        code = code .. string.format([[
 
 
function %s_Update(i, x, y, ss, nt)
    -- i: particle index
    -- x, y: particle x, y coords
end
elements.property(%s, "Update", %s_Update)
 
function %s_Graphics(i, colr, colg, colb)
    -- i: particle index
    -- colr, colg, colb: color red, green, and blue channels
 
    -- return cache, pixel mode,
    --        alpha, red, green, blue,
    --        fire alpha, fire red, fire green, fire blue
    return 1, 0x0000001, 255, colr, colg, colb, 0, 0, 0, 0
end
elements.property(%s, "Graphics", %s_Graphics)]], namestr, elementconstant, namestr, namestr, elementconstant, namestr)
    end
 
    file = io.open("scripts/" .. namestr .. ".lua", "w")
    file:write(code)
    file:close()
end
 
local function exportcpp(sender)
    local namestr = name:text():upper()
 
    if namestr:gsub("%s+", "") == "" or description:text():gsub("%s+", "") == "" then
        tpt.message_box("Error", "Missing required fields.")
        return
    end
 
    local properties = ""
 
    local type = bit.band(elem.property(element, "Properties"), 31)
    if type == elem.TYPE_SOLID then
        properties = "TYPE_SOLID"
    elseif type == elem.TYPE_PART then
        properties = "TYPE_PART"
    elseif type == elem.TYPE_LIQUID then
        properties = "TYPE_LIQUID"
    elseif type == elem.TYPE_GAS then
        properties = "TYPE_GAS"
    elseif type == elem.TYPE_ENERGY then
        properties = "TYPE_ENERGY"
    end
 
    local code = string.format([[#include "simulation/Elements.h"
//#TPT-Directive ElementClass Element_%s PT_%s {INSERT ID HERE}
Element_%s::Element_%s()
{
    Identifier = "DEFAULT_PT_%s";
    Name = "%s";
    Colour = PIXPACK(0x%x);
    MenuVisible = 1;
    MenuSection = SC_SPECIAL;
    Enabled = 1;
 
    Advection = %sf;
    AirDrag = %sf * CFDS;
    AirLoss = %s;
    Loss = %sf;
    Collision = %sf;
    Gravity = %sf;
    Diffusion = %sf;
    HotAir = %sf * CFDS;
    Falldown = %s;
 
    Flammable = %s;
    Explosive = %s;
    Meltable = 0;
    Hardness = %s;
 
    Weight = %s;
 
    Temperature = %sf;
    HeatConduct = %s;
    Description = "%s";
 
    Properties = %s;
 
    LowPressure = IPL;
    LowPressureTransition = NT;
    HighPressure = IPH;
    HighPressureTransition = NT;
    LowTemperature = ITL;
    LowTemperatureTransition = NT;
    HighTemperature = ITH;
    HighTemperatureTransition = NT;]], namestr, namestr, namestr, namestr, namestr, namestr, elem.property(element, "Color"), round(elem.property(element, "Advection"), 7), round(elem.property(element, "AirDrag"), 7), round(elem.property(element, "AirLoss"), 7), round(elem.property(element, "Loss"), 7), round(elem.property(element, "Collision"), 7), round(elem.property(element, "Gravity"), 7), round(elem.property(element, "Diffusion"), 7), round(elem.property(element, "HotAir"), 7), elem.property(element, "Falldown"), round(elem.property(element, "Flammable"), 0), round(elem.property(element, "Explosive"), 0), round(elem.property(element, "Hardness"), 0), round(elem.property(element, "Weight"), 0), round(elem.property(element, "Temperature"), 2), round(elem.property(element, "HeatConduct"), 0), description:text(), properties)
 
    if addtemplates:checked() then
        code = code .. string.format([[
 
 
    Update = &Element_%s::update;
    Graphics = &Element_%s::graphics;]], namestr, namestr)
    end
 
    code = code .. [[
 
}]]
 
    if addtemplates:checked() then
        code = code .. string.format([[
 
 
// #define UPDATE_FUNC_ARGS Simulation* sim, int i, int x, int y, int surround_space, int nt, Particle *parts, int pmap[YRES][XRES]
 
//#TPT-Directive ElementHeader Element_%s static int update(UPDATE_FUNC_ARGS)
int Element_%s::update(UPDATE_FUNC_ARGS)
{
 
}
 
// #define GRAPHICS_FUNC_ARGS Renderer *ren, Particle *cpart, int nx, int ny,
//                            int *pixel_mode, int* cola, int *colr, int *colg,
//                            int *colb, int *firea, int *firer, int *fireg, int *fireb
 
//#TPT-Directive ElementHeader Element_%s static int graphics(GRAPHICS_FUNC_ARGS)
int Element_%s::graphics(GRAPHICS_FUNC_ARGS)
{
 
}]], namestr, namestr, namestr, namestr)
    end
 
    code = code .. string.format([[
 
 
Element_%s::~Element_%s() {}]], namestr, namestr)
 
    file = io.open(namestr .. ".cpp", "w")
    file:write(code)
    file:close()
end
 
local exportluabutton = Button:new(exportwidth - 110, exportheight - 26, 100, 16, "Export Lua code")
exportluabutton:action(exportlua)
exportwindow:addComponent(exportluabutton)
local exportcppbutton = Button:new(exportwidth - 220, exportheight - 26, 100, 16, "Export C++ code")
exportcppbutton:action(exportcpp)
exportwindow:addComponent(exportcppbutton)
 
exportwindow:onTryExit(function()
    ui.closeWindow(exportwindow)
end)
 
local function keypressed(key, keynum, mod, evt)
    if evt == 2 and key == "n" then
        ui.showWindow(window)
    end
end
 
loadelement(loadtext)
 
tpt.register_keypress(keypressed)

Description:

Changelog: