Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --MOVIEMAKER NUCULAR'S MOD V. 1.1
- --ORIGINAL WRITTEN BY GAMAX92
- --VER 1.1 UPDATE http://pastebin.com/raw.php?i=HxMMxSpY
- -- This is my modification of gamax92's awesome idea of a simple screenvideo-program for TPT.
- -- gamax92 has done everything, I just tried to make it compatible with the new PNG output
- -- format of the screenshots and fix a few glitches... and added a few functions.
- -- I hope you like it. Have fun!
- -- Based on official Moviemaker version 1.6
- -- All changes made by me are commented.
- --SETTINGS:
- local qual = 3 -- default quality bigger is worse ranges from 1 to 31
- local nob = 6 --insert the number of buttons on top here
- --TODO:
- --More output formats (but I dont know where to put this option, maybe drop-down-like)
- --convert & clean folder automatically after converting
- --sort more things into functions
- --port GUI to new TPTPPs Interface API (i should really learn more advanced lua...)
- --eye-candy: blinking circle when recording (very simple to do, but where to place it without recording it?)
- --show ffmpegs download page if it not exists. (maybe open it per os.execute?)
- --allow the user to place the script in a subdirectory of TPT's folder
- --repair/recode the file counting procedure before converting
- --of course speed improvements. i've got a rapid framedrop when recording...
- --use inrct function when checking mouseclicks in gui
- --CHANGES:
- -- FROM ORIGINAL 1.6 TO MOD 1.0:
- -- fixed MANY graphical glitches of TPT++
- -- changed arguments for ffmpeg to support new screenshot format .png
- -- changed arguments for del to support .png & delete only screenshot-png's, no other
- -- changed pre-set fps setting to not overspeed the output video
- -- FROM 1.0 TO 1.1:
- -- now shows the recorded frames while recording.
- -- now saves/loads settings in/from file, probably more useful if there would be more settings
- -- added dialogs after recording/converting
- -- changed a few button descriptions
- -- new option: record toolbar too
- -- added TODO list, documentation of changes and BUG list... maybe this will be a bigger project...
- -- replaced not working video counting with ugly os.time()
- -- now using the new fileSystem API for checking existing files instead of the ugly io.open method.
- -- now checking if Videos-folder exists (and creates them) and if ffmpeg.exe exists.
- -- defined all variables and functions as local just to be secure
- -- mouse now doesn't draw particles when GUI is opened
- -- AVI/GIF buttons are now direct clickable. Freed space in GUI by removing these useless buttons. Moved Record & Clean Folder down.
- -- added hackstrife's Quality Option! Thanks, thanks thanks! (added save line too)
- -- working update line for cracker64's Autorun Manager
- --KNOWN BUGS:
- -- TPT freezes while converting a video
- -- TPTs settings, console and stamp browser aren't recorded, script simply pauses (unable to fix in actual version due to TPTs intern code)
- -- bad news for Lua coders: Doesn't records the new Interface API
- -- if fullscreen records is enabled, it records frame and second text too.
- local recording = 0
- local recordfps = 25 -- more realistic fps
- local recordframes = 0
- local recordft = ".avi"
- local recorduiseen = 0
- local recorduitype = 0
- local fullscreen = 0
- if package.config:sub(1,1) == "\\" then
- recordds = "\\"
- else
- recordds = "/"
- end
- -- check if Videos folder exists, create it if not, show mesagebox if creating failed
- if not fs.exists("Videos") then
- if not fs.makeDirectory("Videos") then
- tpt.message_box("Moviemaker - Creating folder failed","Please create folder 'Videos' in\nTPTs directory manually.")
- end
- end
- -- check if FFMPEG exists
- if not fs.exists("ffmpeg.exe") then
- tpt.message_box("Moviemaker - FFMPEG not found","Please copy an version of FFMPEG in\nTPTs directory and name it 'ffmpeg.exe'.")
- end
- local uix = (612 / 2) - (146 / 2)
- local uiy = (384 / 2) - (58 / 2)
- -- load settings based on code from cracker64's awesome Autorun Script Manager
- local function load_last()
- local f = io.open("moviemakersettings.txt","r")
- if f then
- local lines = {}
- local line = f:read("*l")
- while line do
- table.insert(lines,line)
- line = f:read("*l")
- end
- f:close()
- for i=1, #lines do
- local tok=lines[i]:sub(1,3)
- local str=lines[i]:sub(5)
- if tok=="FPS" then
- recordfps = tonumber(str)
- elseif tok=="COD" then
- recordft = str
- elseif tok=="FUL" then
- fullscreen = tonumber(str)
- elseif tok=="QUA" then
- qual = tonumber(str)
- end
- end
- end
- end
- load_last()
- --save settings
- local function save_last()
- local savestring = "FPS "..tostring(recordfps).."\nCOD "..recordft.."\nFUL "..tostring(fullscreen).."\nQUA "..tostring(qual)
- local f = io.open("moviemakersettings.txt","w")
- if f then
- f:write(savestring)
- f:close()
- end
- end
- local function recordsui()
- tpt.fillrect(612,nob * 16,14,14) --fix tptpp's fillrect glitch
- tpt.drawtext(618,nob * 16 + 5,"S",0,0,0)
- recordframes = recordframes + 1
- tpt.drawtext(5,385,tostring(math.floor(recordframes / recordfps)) .. " s")
- tpt.drawtext(5,395,tostring(math.floor(recordframes)) .. " F") --show recorded frames too
- end
- --new screenshot function
- local function screensh()
- tpt.screenshot(fullscreen)
- end
- local function recordui()
- if recorduiseen == 1 then
- tpt.fillrect(uix,uiy,146,58,0,0,0) --fix tptpp's fillrect glitch
- tpt.drawrect(uix,uiy,146,58)
- tpt.drawrect(uix + 107, uiy + 2, 37, 12)
- if recorduitype == 0 then
- tpt.drawtext(uix + 109, uiy + 5, "Options")
- tpt.drawrect(uix + 2, uiy + 2, 12, 12)
- tpt.drawrect(uix + 54, uiy + 2, 12, 12)
- if recordft == ".avi" then
- tpt.fillrect(uix + 2, uiy + 2, 10, 10, 0, 255, 0) --fix tptpp's fillrect glitch
- tpt.fillrect(uix + 54, uiy + 2, 10, 10, 0, 63, 0) --fix tptpp's fillrect glitch
- else
- tpt.fillrect(uix + 2, uiy + 2, 10, 10, 0, 63, 0) --fix tptpp's fillrect glitch
- tpt.fillrect(uix + 54, uiy + 2, 10, 10, 0, 255, 0) --fix tptpp's fillrect glitch
- end
- tpt.drawrect(uix + 2, uiy + 30, 70, 12)
- tpt.drawrect(uix + 74, uiy + 30, 70, 12)
- --removed borders of select... buttons
- tpt.drawrect(uix + 2, uiy + 44, 142, 12)
- tpt.drawtext(uix + 16, uiy + 5, "AVI Out")
- tpt.drawtext(uix + 68, uiy + 5, "GIF Out")
- tpt.drawtext(uix + 9, uiy + 32, "Clean folder")
- tpt.drawtext(uix + 93, uiy + 32, "Record") --better description, I thought
- --removed 'Select GIF' and 'Select AVI'
- tpt.drawtext(287, uiy + 47, "CONVERT") --better description, I thought
- else
- tpt.drawtext(uix + 115, uiy + 5, "Main")
- -- draw fps selecter with offset
- tpt.drawrect(uix + 25, uiy + 16 - 14, 12, 12)
- tpt.drawrect(uix + 39, uiy + 16 - 14, 19, 12)
- tpt.drawrect(uix + 60, uiy + 16 - 14, 12, 12)
- tpt.drawtext(uix + 2, uiy + 18 - 14, "FPS:")
- tpt.drawline(uix + 28, uiy + 22 - 14, uix + 34, uiy + 22 - 14)
- tpt.drawtext(uix + (48 - (tpt.textwidth(tostring(recordfps)) / 2)), uiy + 19 - 14, tostring(recordfps))
- tpt.drawline(uix + 63, uiy + 22 - 14, uix + 69, uiy + 22 - 14)
- tpt.drawline(uix + 66, uiy + 19 - 14, uix + 66, uiy + 25 - 14)
- -- %%quality menu part THANKS TO HACKSTRIFE!
- tpt.drawrect(uix + 76, uiy + 33, 12, 12)
- tpt.drawrect(uix + 90, uiy + 33, 19, 12)
- tpt.drawrect(uix + 111, uiy + 33, 12, 12)
- tpt.drawtext(uix + 2, uiy + 36, "COMPRESSION:")
- tpt.drawline(uix + 79, uiy + 39, uix + 85, uiy + 39)
- tpt.drawtext(uix + (72 - (tpt.textwidth(tostring(qual)) / 2)) + 27, uiy + 36, tostring(qual))
- tpt.drawline(uix + 114, uiy + 39, uix + 120, uiy + 39)
- tpt.drawline(uix + 117, uiy + 36, uix + 117, uiy + 42)
- -- add fullscreen option
- tpt.drawtext(uix + 16, uiy + 35 - 13, "Record menus")
- tpt.drawrect(uix + 2, uiy + 32 - 13, 12, 12)
- if fullscreen == 0 then
- tpt.fillrect(uix + 2, uiy + 32 - 13, 10, 10, 0, 63, 0)
- else
- tpt.fillrect(uix + 2, uiy + 32 - 13, 10, 10, 0, 255, 0)
- end
- -- add info button (maybe next version
- --tpt.drawrect(uix + 132, uiy + 16, 12, 12)
- --tpt.drawtext(uix + 138, uiy + 19, "!")
- end
- end
- tpt.drawrect(613,nob * 16 + 1,14,14,200,200,200)
- tpt.drawtext(618,nob * 16 + 5,"S")
- end
- local function recordmouse(x,y,b,e)
- if recording == 1 and x > 612 and y > (nob * 16) and x < 629 and y < (nob * 16 + 16) and b == 1 and e == 1 then
- tpt.unregister_step(recordsui)
- tpt.unregister_step(screensh)
- tpt.register_step(recordui)
- tpt.set_pause(1)
- recording = 0
- recorduiseen = 1 --block mouse too in the frame between gui open and recording
- tpt.message_box("Recording finished", "Recorded " .. tostring(recordframes) .. " Frames.\nDon't forget to Convert them to a video!") --show finish message
- elseif recording == 0 and x > 612 and y > (nob * 16) and x < 629 and y < (nob * 16 + 16) and b == 1 and e == 1 then
- recorduiseen = math.mod(recorduiseen + 1, 2)
- tpt.set_pause(recorduiseen)
- save_last()
- end
- if x > uix + 106 and y > uiy + 1 and x < uix + 148 and y < uiy + 15 and b == 1 and e == 1 then
- recorduitype = math.mod(recorduitype + 1, 2)
- end
- if b == 1 and e == 1 and recorduiseen == 1 and recorduitype == 0 then
- if x > uix + 1 and y > uiy + 29 and x < uix + 73 and y < uiy + 43 then
- -- deleting only screenshot pngs
- if recordds == "\\" then
- os.execute("del screenshot_*.png")
- else
- os.execute("rm screenshot_*.png")
- end
- elseif x > uix + 73 and y > uiy + 29 and x < uix + 145 and y < uiy + 43 then
- save_last()
- tpt.unregister_step(recordui)
- tpt.register_step(recordsui)
- tpt.register_step(screensh) --new screenshot function
- tpt.set_pause(0)
- recording = 1
- elseif x > uix + 1 and y > uiy + 1 and x < uix + 15 and y < uiy + 15 then --avi icon is now direct clickable
- recordft = ".avi"
- elseif x > uix + 54 and y > uiy + 1 and x < uix + 67 and y < uiy + 15 then --gif icon too
- recordft = ".gif"
- elseif x > uix + 1 and y > uiy + 43 and x < uix + 145 and y < uiy + 57 then
- -- replaced non-working file counting with ugly os.time()
- -- working png converting
- os.execute("ffmpeg -r " .. tostring(recordfps) .. " -i screenshot_%06d.png -q:v " .. tostring(qual) .. " Videos" .. recordds .. "tptvideo" .. tostring(os.time()).. recordft)
- tpt.message_box("Converting finished", "Converted " .. tostring(math.floor(recordframes / recordfps)) .. " Seconds of video.\nDon't forget to clean your folder!") --show finish message
- end
- elseif b == 1 and e == 1 and recorduiseen == 1 and recorduitype == 1 then
- -- check fps element with offset
- if x > uix + 24 and y > uiy + 15 - 14 and x < uix + 38 and y < uiy + 29 - 14 then
- if recordfps > 1 then recordfps = recordfps - 1 end
- elseif x > uix + 59 and y > uiy + 15 - 14 and x < uix + 73 and y < uiy + 29 - 14 then
- if recordfps < 60 then recordfps = recordfps + 1 end
- -- %% quality menu mouse click check THANKS TO HACKSTRIFE!
- elseif x > uix + 75 and y > uiy + 34 and x < uix + 88 and y < uiy + 49 then
- if qual > 1 then qual = qual - 1 end
- elseif x > uix + 110 and y > uiy + 34 and x < uix + 123 and y < uiy + 49 then
- if qual < 31 then qual = qual + 1 end
- elseif x > uix + 1 and y > uiy + 31 - 13 and x < uix + 15 and y < uiy + 44 - 13 then --check fullscreen option
- if fullscreen == 1 then fullscreen = 0 else fullscreen = 1 end
- end
- end
- --block mouse from interacting with tpt when GUI is open
- if recorduiseen == 1 then
- if recording == 1 then
- recorduiseen = 0
- end
- return false
- end
- end
- tpt.register_step(recordui)
- tpt.register_mouseclick(recordmouse)
Add Comment
Please, Sign In to add comment