Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local h=6
- local l="V"
- if mods_tnmm==true then
- tpt.message_box("MovieMaker","MovieMaker is already loaded.")
- return false
- end
- mods_tnmm=true
- local t,d,n,i=tpt,math,Button,tostring
- if not fs.exists("Videos")then
- if not fs.makeDirectory("Videos")then
- t.message_box("MovieMaker - Creating folder failed","Please create folder 'Videos' in\nTPTs directory manually.")
- end
- end
- local A=0
- local o=30
- local a=3
- local f=0
- local s=".avi"
- local w=0
- local x=0
- local c=0
- local r=0
- local v
- if package.config:sub(1,1)=="\\"then
- v="\\"
- else
- v="/"
- end
- local u=d.floor((612/2)-(149/2))
- local m=d.floor((384/2)-(59/2))
- local function y()
- local i=io.open("MovieMakerSettings.txt","rb")
- if i~=nil then
- while true do
- line=i:read("*l")
- if line==nil then
- break
- elseif line~=""then
- local t,e=line:match("(.-) (.*)")
- if t=="FPS"then
- o=tonumber(e)
- elseif t=="COD"then
- s=e
- elseif t=="FUL"then
- c=tonumber(e)
- elseif t=="QUA"then
- a=tonumber(e)
- elseif t=="FOC"then
- r=tonumber(e)
- end
- end
- end
- i:close()
- end
- end
- local function E()
- local t={
- FPS=o,
- COD=s,
- FUL=c,
- QUA=a,
- FOC=r,
- }
- local e=""
- for a,t in pairs(t)do
- e=e..a.." "..i(t).."\n"
- end
- e=e:sub(1,-2)
- local t=io.open("MovieMakerSettings.txt","wb")
- if t~=nil then
- t:write(e)
- t:close()
- end
- end
- local function S()
- f=f+1
- t.drawtext(5,385,i(d.floor(f/60)).." s")
- t.drawtext(5,395,i(d.floor(f)).." F")
- end
- local function H()
- t.screenshot(c,r==1 and 0 or 2)
- end
- y()
- local D=n:new(613,(h*16)+1,15,15,l)
- local R=n:new(613-u,((h*16)+1)-m,15,15,l)
- local N=n:new(109,2,38,13,"Options")
- local e=Window:new(u,m,149,59)
- local l=Checkbox:new(0,0,13,13,"AVI Out")
- l:checked(s==".avi")
- local h=Checkbox:new(53,0,13,13,"GIF Out")
- h:checked(s~=".avi")
- local g=n:new(2,30,72,13,"Clean folder")
- local k=n:new(75,30,72,13,"Record")
- local q=n:new(2,44,145,13,"Convert")
- local p=Checkbox:new(0,0,13,13,"Frame Compress")
- p:checked(r==1)
- local y=Checkbox:new(0,13,13,13,"Record HUD")
- y:checked(c==1)
- local _=Label:new(2,30,t.textwidth("Video framerate:"),13,"Video framerate:")
- local z=n:new(99,30,13,13,"-")
- local u=Textbox:new(113,30,20,13,i(o),"FPS")
- u:readonly(true)
- local j=n:new(134,30,13,13,"+")
- local T=Label:new(2,44,t.textwidth("Compression:"),13,"Compression:")
- local b=n:new(99,44,13,13,"-")
- local m=Textbox:new(113,44,20,13,i(a),"FPS")
- m:readonly(true)
- local n=n:new(134,44,13,13,"+")
- interface.addComponent(D)
- e:addComponent(R)
- e:addComponent(N)
- e:addComponent(l)
- e:addComponent(h)
- e:addComponent(g)
- e:addComponent(k)
- e:addComponent(q)
- e:addComponent(p)
- e:addComponent(y)
- e:addComponent(_)
- e:addComponent(z)
- e:addComponent(u)
- e:addComponent(j)
- e:addComponent(T)
- e:addComponent(b)
- e:addComponent(m)
- e:addComponent(n)
- local function O()
- l:visible(true)
- h:visible(true)
- g:visible(true)
- k:visible(true)
- q:visible(true)
- p:visible(false)
- y:visible(false)
- _:visible(false)
- z:visible(false)
- u:visible(false)
- j:visible(false)
- T:visible(false)
- b:visible(false)
- m:visible(false)
- n:visible(false)
- end
- local function I()
- l:visible(false)
- h:visible(false)
- g:visible(false)
- k:visible(false)
- q:visible(false)
- p:visible(true)
- y:visible(true)
- _:visible(true)
- z:visible(true)
- u:visible(true)
- j:visible(true)
- T:visible(true)
- b:visible(true)
- m:visible(true)
- n:visible(true)
- end
- local function T()
- interface.showWindow(e)
- if x==0 then
- O()
- else
- I()
- end
- end
- local function _(a)
- if A==0 then
- w=1-w
- if w==1 then
- T()
- else
- interface.closeWindow(e)
- end
- t.set_pause(w)
- E()
- else
- t.unregister_step(S)
- t.unregister_step(H)
- T()
- t.set_pause(1)
- A=0
- w=1
- t.hud(1)
- t.message_box("MovieMaker - Recording finished","Recorded "..i(d.floor(f/60)).." seconds.\nDon't forget to Convert frames to a video!")
- end
- end
- local function T(e)
- x=1-x
- if x==0 then
- O()
- else
- I()
- end
- E()
- end
- local function x(e)
- l:checked(true)
- h:checked(false)
- s=".avi"
- end
- local function I(e)
- l:checked(false)
- h:checked(true)
- s=".gif"
- end
- local function O(e)
- local a=fs.list(".")
- local e=0
- for o,a in pairs(a)do
- if a:sub(1,11)=="screenshot_"then
- fs.removeFile(a)
- e=e+1
- end
- end
- t.message_box("MovieMaker - Cleanup finished","Deleted "..i(d.floor(e/60)).." seconds of video.")
- f=0
- end
- local function w(a)
- E()
- t.hud(c)
- interface.closeWindow(e)
- t.register_step(S)
- t.register_step(H)
- t.set_pause(0)
- A=1
- end
- local function f(e)
- local i=fs.list(".")
- table.sort(i)
- local e=0
- for a,t in ipairs(i)do
- if t:sub(1,11)=="screenshot_"then
- fs.move(t,"screenshot_"..string.format("%06d",e).."."..(r==1 and"png"or"ppm"))
- e=e+1
- end
- end
- local i=1
- while fs.exists("Videos"..v.."tptvideo"..string.format("%04d",i)..s)==true do
- i=i+1
- end
- os.execute("ffmpeg -r 60 -i screenshot_%06d."..(r==1 and"png"or"ppm").." -q:v "..a.." -r "..o.." Videos"..v.."tptvideo"..string.format("%04d",i)..s)
- t.message_box("MovieMaker - Converting finished","Converted "..d.floor(e/60).." seconds of video.\nDon't forget to clean your folder!")
- end
- local function e(e)
- r=e:checked()==true and 1 or 0
- end
- local function t(e)
- c=e:checked()==true and 1 or 0
- end
- local function d(e)
- if o>1 then o=o-1 end
- u:text(i(o))
- end
- local function r(e)
- if o<60 then o=o+1 end
- u:text(i(o))
- end
- local function s(e)
- if a>1 then a=a-1 end
- m:text(i(a))
- end
- local function o(e)
- if a<31 then a=a+1 end
- m:text(i(a))
- end
- D:action(_)
- R:action(_)
- N:action(T)
- l:action(x)
- h:action(I)
- g:action(O)
- k:action(w)
- q:action(f)
- p:action(e)
- y:action(t)
- z:action(d)
- j:action(r)
- b:action(s)
- n:action(o)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement