Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SC_UI = Window:new(40, 50, 542, 302)
- title = Label:new(274, 4, 1, 16, "\bb================================ \brLua element creator\bb ================================")
- ins = Label:new(274, 24, 1, 16, "\boEnter values into boxes. If you don't know what they are, look at the wiki. Leave blank to not write that line.\n Temperature values are floats batween 0 - 10000, transition values and 'Base' have to be an element name.")
- scriptname = Textbox:new(6, 50, 128, 16, "" , "Name of script")
- Ident = Textbox:new(6, 70, 128, 16, "" , "Element id prefix")
- elName = Textbox:new(6, 90, 128, 16, "" , "Name (all in capitals)")
- Base = Textbox:new(6, 110, 128, 16, "" , "Base element")
- Color = Textbox:new(6, 130, 128, 16, "" , "Color (6 digit hex)")
- MenuVisible = Textbox:new(6, 150, 128, 16, "" , "MenuVisible (1 or 0)")
- MenuSection = Textbox:new(6, 170, 128, 16, "" , "MenuSection")
- Advection = Textbox:new(6, 190, 128, 16, "" , "Advection (-1 to 1 float)")
- AirDrag = Textbox:new(140, 50, 128, 16, "" , "AirDrag (any float)")
- AirLoss = Textbox:new(140, 70, 128, 16, "" , "AirLoss (0 to 1 float)")
- Loss = Textbox:new(140, 90, 128, 16, "" , "Loss (any float)")
- Collision = Textbox:new(140, 110, 128, 16, "" , "Collision (any float)")
- Gravity = Textbox:new(140, 130, 128, 16, "" , "Gravity (any float)")
- Diffusion = Textbox:new(140, 150, 128, 16, "" , "Diffusion (any float)")
- HotAir = Textbox:new(140, 170, 128, 16, "" , "HotAir (very small float)")
- Falldown = Textbox:new(140, 190, 128, 16, "" , "Falldown (0, 1, or 2)")
- Flammable = Textbox:new(274, 50, 128, 16, "" , "Flammable (0+ integer)")
- Explosive = Textbox:new(274, 70, 128, 16, "" , "Explosive (0, 1, or 2)")
- Meltable = Textbox:new(274, 90, 128, 16, "" , "Meltable (1 or 0)")
- Hardness = Textbox:new(274, 110, 128, 16, "" , "Hardness (0+ integer)")
- Weight = Textbox:new(274, 130, 128, 16, "" , "Weight (-1 to 100)")
- Temperature = Textbox:new(274, 150, 128, 16, "" , "Temperature (temp value)")
- HeatConduct = Textbox:new(274, 170, 128, 16, "" , "HeatConduct (0 to 255)")
- Description = Textbox:new(6, 210, 530, 16, "" , "Description (text that describes the element)")
- HighTemperature = Textbox:new(408, 50, 128, 16, "" , "HighTemperature (temp)")
- HighTemperatureTransition = Textbox:new(408, 70, 128, 16, "" , "HighTemperatureTranstion")
- LowTemperature = Textbox:new(408, 90, 128, 16, "" , "LowTemperature (temp)")
- LowTemperatureTransition = Textbox:new(408, 110, 128, 16, "" , "LowTemperatureTransition")
- HighPressure = Textbox:new(408, 130, 128, 16, "" , "HighPressure (0 to 256)")
- HighPressureTransition = Textbox:new(408, 150, 128, 16, "" , "HighPressureTranstion")
- LowPressure = Textbox:new(408, 170, 128, 16, "" , "LowPressure (-256 to 0)")
- LowPressureTransition = Textbox:new(408, 190, 128, 16, "" , "LowPressureTranstion")
- State = Textbox:new(274, 190, 128, 16, "" , "State (constant)")
- Properties = Textbox:new(6, 230, 530, 16, "" , "Properties (one constant or multiple constants using bit.bor)")
- Create = Button:new(6, 276, 262, 20, "\btCreate script", "")
- Create:action(function(sender) create_script() end)
- Close = Button:new(0, 0, 14, 14, "\brx", "")
- Close:action(function(sender) interface.closeWindow(SC_UI) end)
- Reset = Button:new(274, 276, 262, 20, "\btReset all values", "")
- Reset:action(function(sender) reset() end)
- Update = Checkbox:new(6, 256, 16, 16, "\brMake update function frame (main element function)")
- Update:checked(true)
- Graphics = Checkbox:new(274, 256, 16, 16, "\brMake graphics function frame (deals with graphics)")
- Graphics:checked(true)
- function open(key)
- if key == 'j' then
- interface.showWindow(SC_UI)
- end
- end
- function reset()
- scriptname:text("")
- Ident:text("")
- elName:text("")
- Base:text("")
- Color:text("")
- MenuVisible:text("")
- MenuSection:text("")
- Advection:text("")
- AirDrag:text("")
- AirLoss:text("")
- Loss:text("")
- Collision:text("")
- Gravity:text("")
- Diffusion:text("")
- HotAir:text("")
- Falldown:text("")
- Flammable:text("")
- Explosive:text("")
- Meltable:text("")
- Hardness:text("")
- Weight:text("")
- Temperature:text("")
- HeatConduct:text("")
- Description:text("")
- HighTemperature:text("")
- HighTemperatureTransition:text("")
- LowTemperature:text("")
- LowTemperatureTransition:text("")
- HighPressure:text("")
- HighPressureTransition:text("")
- LowPressure:text("")
- LowPressureTransition:text("")
- State:text("")
- Properties:text("")
- end
- function create_script()
- if scriptname:text() == "" then
- tpt.throw_error("Specified file must have name, so give it a name!")
- elseif Ident:text() == "" or elName:text() == "" or Base:text() == "" or Color:text() == "" or Description:text() == "" then
- tpt.throw_error("Prefix, Name, Base element, Color, Description all have to have values!")
- else
- FullName = "elements.property(elements." .. Ident:text() .. "_PT_" .. elName:text()
- script = io.open(scriptname:text() .. ".lua", "w")
- script:write("--created with thepowderguy's script\n\n")
- script:write("local NewElement = elements.allocate(\"" .. Ident:text() .. "\", \"" .. elName:text() .. "\")\n")
- script:write("elements.element(elements." .. Ident:text() .. "_PT_" .. elName:text() .. ", elements.element(tpt.element(\"" .. Base:text() .. "\")))\n")
- script:write(FullName .. ", \"Name\", \"" .. elName:text() .. "\")\n")
- script:write(FullName .. ", \"Color\", " .. Color:text() .. ")\n")
- -- START OF PROPERTIES
- if MenuVisible:text() ~= "" then
- script:write(FullName .. ", \"MenuVisible\", " .. MenuVisible:text() .. ")\n")
- end
- if MenuSection:text() ~= "" then
- script:write(FullName .. ", \"MenuSection\", " .. MenuSection:text() .. ")\n")
- end
- if Advection:text() ~= "" then
- script:write(FullName .. ", \"Advection\", " .. Advection:text() .. ")\n")
- end
- if AirDrag:text() ~= "" then
- script:write(FullName .. ", \"AirDrag\", " .. AirDrag:text() .. ")\n")
- end
- if AirLoss:text() ~= "" then
- script:write(FullName .. ", \"AirLoss\", " .. AirLoss:text() .. ")\n")
- end
- if Loss:text() ~= "" then
- script:write(FullName .. ", \"Loss\", " .. Loss:text() .. ")\n")
- end
- if Collision:text() ~= "" then
- script:write(FullName .. ", \"Collision\", " .. Collision:text() .. ")\n")
- end
- if Gravity:text() ~= "" then
- script:write(FullName .. ", \"Gravity\", " .. Gravity:text() .. ")\n")
- end
- if Diffusion:text() ~= "" then
- script:write(FullName .. ", \"Diffusion\", " .. Diffusion:text() .. ")\n")
- end
- if HotAir:text() ~= "" then
- script:write(FullName .. ", \"HotAir\", " .. HotAir:text() .. ")\n")
- end
- if Falldown:text() ~= "" then
- script:write(FullName .. ", \"Falldown\", " .. Falldown:text() .. ")\n")
- end
- if Flammable:text() ~= "" then
- script:write(FullName .. ", \"Flammable\", " .. Flammable:text() .. ")\n")
- end
- if Explosive:text() ~= "" then
- script:write(FullName .. ", \"Explosive\", " .. Explosive:text() .. ")\n")
- end
- if Meltable:text() ~= "" then
- script:write(FullName .. ", \"Meltable\", " .. Meltable:text() .. ")\n")
- end
- if Hardness:text() ~= "" then
- script:write(FullName .. ", \"Hardness\", " .. Hardness:text() .. ")\n")
- end
- if Weight:text() ~= "" then
- script:write(FullName .. ", \"Weight\", " .. Weight:text() .. ")\n")
- end
- if Temperature:text() ~= "" then
- script:write(FullName .. ", \"Temperature\", " .. Temperature:text() .. ")\n")
- end
- if HeatConduct:text() ~= "" then
- script:write(FullName .. ", \"HeatConduct\", " .. HeatConduct:text() .. ")\n")
- end
- if Description:text() ~= "" then
- script:write(FullName .. ", \"Description\", \"" .. Description:text() .. "\")\n")
- end
- if State:text() ~= "" then
- script:write(FullName .. ", \"State\", " .. State:text() .. ")\n")
- end
- if Properties:text() ~= "" then
- script:write(FullName .. ", \"Properties\", " .. Properties:text() .. ")\n")
- end
- -- START OF TRANSITIONS
- if HighTemperature:text() ~= "" then
- script:write(FullName .. ", \"HighTemperature\", " .. HighTemperature:text() .. ")\n")
- end
- if HighTemperatureTransition:text() ~= "" then
- script:write(FullName .. ", \"HighTemperatureTransition\", " .. "tpt.element(\"" .. HighTemperatureTransition:text() .. "\"))\n")
- end
- if LowTemperature:text() ~= "" then
- script:write(FullName .. ", \"LowTemperature\", " .. LowTemperature:text() .. ")\n")
- end
- if LowTemperatureTransition:text() ~= "" then
- script:write(FullName .. ", \"LowTemperatureTransition\", " .. "tpt.element(\"" .. LowTemperatureTransition:text() .. "\"))\n")
- end
- if HighPressure:text() ~= "" then
- script:write(FullName .. ", \"HighPressure\", " .. HighPressure:text() .. ")\n")
- end
- if HighPressureTransition:text() ~= "" then
- script:write(FullName .. ", \"HighPressureTransition\", " .. "tpt.element(\"" .. HighPressureTransition:text() .. "\"))\n")
- end
- if LowPressure:text() ~= "" then
- script:write(FullName .. ", \"LowPressure\", " .. LowPressure:text() .. ")\n")
- end
- if LowPressureTransition:text() ~= "" then
- script:write(FullName .. ", \"LowPressureTransition\", " .. "tpt.element(\"" .. LowPressureTransition:text() .. "\"))\n")
- end
- -- START OF FUNCTION
- if Update:checked() then
- script:write("\nlocal function " .. elName:text() .. "_Update(i, x, y, s, n)\n--insert update code here\n")
- script:write("end\n")
- script:write("tpt.element_func(" .. elName:text() .. "_Update" .. ", elements." .. Ident:text() .. "_PT_" .. elName:text() .. ")\n")
- end
- if Graphics:checked() then
- script:write("\nlocal function " .. elName:text() .. "_Graphics(i, r, g, b)\n--insert graphics code here\n")
- script:write("end\n")
- script:write("tpt.graphics_func(" .. elName:text() .. "_Graphics" .. ", elements." .. Ident:text() .. "_PT_" .. elName:text() .. ")")
- end
- script:flush()
- interface.closeWindow(SC_UI)
- tpt.message_box("--SCRIPT CREATOR--", "Your script has been created!\n(Check in TPT's folder)")
- end
- end
- tpt.register_keypress(open)
- SC_UI:addComponent(title)
- SC_UI:addComponent(ins)
- SC_UI:addComponent(scriptname)
- SC_UI:addComponent(Ident)
- SC_UI:addComponent(elName)
- SC_UI:addComponent(Base)
- SC_UI:addComponent(Color)
- SC_UI:addComponent(MenuVisible)
- SC_UI:addComponent(MenuSection)
- SC_UI:addComponent(Advection)
- SC_UI:addComponent(AirDrag)
- SC_UI:addComponent(AirLoss)
- SC_UI:addComponent(Loss)
- SC_UI:addComponent(Collision)
- SC_UI:addComponent(Gravity)
- SC_UI:addComponent(Diffusion)
- SC_UI:addComponent(HotAir)
- SC_UI:addComponent(Falldown)
- SC_UI:addComponent(Flammable)
- SC_UI:addComponent(Explosive)
- SC_UI:addComponent(Meltable)
- SC_UI:addComponent(Hardness)
- SC_UI:addComponent(Weight)
- SC_UI:addComponent(Temperature)
- SC_UI:addComponent(HeatConduct)
- SC_UI:addComponent(Description)
- SC_UI:addComponent(HighTemperature)
- SC_UI:addComponent(HighTemperatureTransition)
- SC_UI:addComponent(LowTemperature )
- SC_UI:addComponent(LowTemperatureTransition)
- SC_UI:addComponent(HighPressure )
- SC_UI:addComponent(HighPressureTransition)
- SC_UI:addComponent(LowPressure)
- SC_UI:addComponent(LowPressureTransition)
- SC_UI:addComponent(State)
- SC_UI:addComponent(Properties)
- SC_UI:addComponent(Create)
- SC_UI:addComponent(Close)
- SC_UI:addComponent(Reset)
- SC_UI:addComponent(Update)
- SC_UI:addComponent(Graphics)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement