Advertisement
gamax92

tnmm

Apr 28th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.40 KB | None | 0 0
  1. local h=6
  2. local l="V"
  3. if mods_tnmm==true then
  4. tpt.message_box("MovieMaker","MovieMaker is already loaded.")
  5. return false
  6. end
  7. mods_tnmm=true
  8. local t,d,n,i=tpt,math,Button,tostring
  9. if not fs.exists("Videos")then
  10. if not fs.makeDirectory("Videos")then
  11. t.message_box("MovieMaker - Creating folder failed","Please create folder 'Videos' in\nTPTs directory manually.")
  12. end
  13. end
  14. local A=0
  15. local o=30
  16. local a=3
  17. local f=0
  18. local s=".avi"
  19. local w=0
  20. local x=0
  21. local c=0
  22. local r=0
  23. local v
  24. if package.config:sub(1,1)=="\\"then
  25. v="\\"
  26. else
  27. v="/"
  28. end
  29. local u=d.floor((612/2)-(149/2))
  30. local m=d.floor((384/2)-(59/2))
  31. local function y()
  32. local i=io.open("MovieMakerSettings.txt","rb")
  33. if i~=nil then
  34. while true do
  35. line=i:read("*l")
  36. if line==nil then
  37. break
  38. elseif line~=""then
  39. local t,e=line:match("(.-) (.*)")
  40. if t=="FPS"then
  41. o=tonumber(e)
  42. elseif t=="COD"then
  43. s=e
  44. elseif t=="FUL"then
  45. c=tonumber(e)
  46. elseif t=="QUA"then
  47. a=tonumber(e)
  48. elseif t=="FOC"then
  49. r=tonumber(e)
  50. end
  51. end
  52. end
  53. i:close()
  54. end
  55. end
  56. local function E()
  57. local t={
  58. FPS=o,
  59. COD=s,
  60. FUL=c,
  61. QUA=a,
  62. FOC=r,
  63. }
  64. local e=""
  65. for a,t in pairs(t)do
  66. e=e..a.." "..i(t).."\n"
  67. end
  68. e=e:sub(1,-2)
  69. local t=io.open("MovieMakerSettings.txt","wb")
  70. if t~=nil then
  71. t:write(e)
  72. t:close()
  73. end
  74. end
  75. local function S()
  76. f=f+1
  77. t.drawtext(5,385,i(d.floor(f/60)).." s")
  78. t.drawtext(5,395,i(d.floor(f)).." F")
  79. end
  80. local function H()
  81. t.screenshot(c,r==1 and 0 or 2)
  82. end
  83. y()
  84. local D=n:new(613,(h*16)+1,15,15,l)
  85. local R=n:new(613-u,((h*16)+1)-m,15,15,l)
  86. local N=n:new(109,2,38,13,"Options")
  87. local e=Window:new(u,m,149,59)
  88. local l=Checkbox:new(0,0,13,13,"AVI Out")
  89. l:checked(s==".avi")
  90. local h=Checkbox:new(53,0,13,13,"GIF Out")
  91. h:checked(s~=".avi")
  92. local g=n:new(2,30,72,13,"Clean folder")
  93. local k=n:new(75,30,72,13,"Record")
  94. local q=n:new(2,44,145,13,"Convert")
  95. local p=Checkbox:new(0,0,13,13,"Frame Compress")
  96. p:checked(r==1)
  97. local y=Checkbox:new(0,13,13,13,"Record HUD")
  98. y:checked(c==1)
  99. local _=Label:new(2,30,t.textwidth("Video framerate:"),13,"Video framerate:")
  100. local z=n:new(99,30,13,13,"-")
  101. local u=Textbox:new(113,30,20,13,i(o),"FPS")
  102. u:readonly(true)
  103. local j=n:new(134,30,13,13,"+")
  104. local T=Label:new(2,44,t.textwidth("Compression:"),13,"Compression:")
  105. local b=n:new(99,44,13,13,"-")
  106. local m=Textbox:new(113,44,20,13,i(a),"FPS")
  107. m:readonly(true)
  108. local n=n:new(134,44,13,13,"+")
  109. interface.addComponent(D)
  110. e:addComponent(R)
  111. e:addComponent(N)
  112. e:addComponent(l)
  113. e:addComponent(h)
  114. e:addComponent(g)
  115. e:addComponent(k)
  116. e:addComponent(q)
  117. e:addComponent(p)
  118. e:addComponent(y)
  119. e:addComponent(_)
  120. e:addComponent(z)
  121. e:addComponent(u)
  122. e:addComponent(j)
  123. e:addComponent(T)
  124. e:addComponent(b)
  125. e:addComponent(m)
  126. e:addComponent(n)
  127. local function O()
  128. l:visible(true)
  129. h:visible(true)
  130. g:visible(true)
  131. k:visible(true)
  132. q:visible(true)
  133. p:visible(false)
  134. y:visible(false)
  135. _:visible(false)
  136. z:visible(false)
  137. u:visible(false)
  138. j:visible(false)
  139. T:visible(false)
  140. b:visible(false)
  141. m:visible(false)
  142. n:visible(false)
  143. end
  144. local function I()
  145. l:visible(false)
  146. h:visible(false)
  147. g:visible(false)
  148. k:visible(false)
  149. q:visible(false)
  150. p:visible(true)
  151. y:visible(true)
  152. _:visible(true)
  153. z:visible(true)
  154. u:visible(true)
  155. j:visible(true)
  156. T:visible(true)
  157. b:visible(true)
  158. m:visible(true)
  159. n:visible(true)
  160. end
  161. local function T()
  162. interface.showWindow(e)
  163. if x==0 then
  164. O()
  165. else
  166. I()
  167. end
  168. end
  169. local function _(a)
  170. if A==0 then
  171. w=1-w
  172. if w==1 then
  173. T()
  174. else
  175. interface.closeWindow(e)
  176. end
  177. t.set_pause(w)
  178. E()
  179. else
  180. t.unregister_step(S)
  181. t.unregister_step(H)
  182. T()
  183. t.set_pause(1)
  184. A=0
  185. w=1
  186. t.hud(1)
  187. t.message_box("MovieMaker - Recording finished","Recorded "..i(d.floor(f/60)).." seconds.\nDon't forget to Convert frames to a video!")
  188. end
  189. end
  190. local function T(e)
  191. x=1-x
  192. if x==0 then
  193. O()
  194. else
  195. I()
  196. end
  197. E()
  198. end
  199. local function x(e)
  200. l:checked(true)
  201. h:checked(false)
  202. s=".avi"
  203. end
  204. local function I(e)
  205. l:checked(false)
  206. h:checked(true)
  207. s=".gif"
  208. end
  209. local function O(e)
  210. local a=fs.list(".")
  211. local e=0
  212. for o,a in pairs(a)do
  213. if a:sub(1,11)=="screenshot_"then
  214. fs.removeFile(a)
  215. e=e+1
  216. end
  217. end
  218. t.message_box("MovieMaker - Cleanup finished","Deleted "..i(d.floor(e/60)).." seconds of video.")
  219. f=0
  220. end
  221. local function w(a)
  222. E()
  223. t.hud(c)
  224. interface.closeWindow(e)
  225. t.register_step(S)
  226. t.register_step(H)
  227. t.set_pause(0)
  228. A=1
  229. end
  230. local function f(e)
  231. local i=fs.list(".")
  232. table.sort(i)
  233. local e=0
  234. for a,t in ipairs(i)do
  235. if t:sub(1,11)=="screenshot_"then
  236. fs.move(t,"screenshot_"..string.format("%06d",e).."."..(r==1 and"png"or"ppm"))
  237. e=e+1
  238. end
  239. end
  240. local i=1
  241. while fs.exists("Videos"..v.."tptvideo"..string.format("%04d",i)..s)==true do
  242. i=i+1
  243. end
  244. 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)
  245. t.message_box("MovieMaker - Converting finished","Converted "..d.floor(e/60).." seconds of video.\nDon't forget to clean your folder!")
  246. end
  247. local function e(e)
  248. r=e:checked()==true and 1 or 0
  249. end
  250. local function t(e)
  251. c=e:checked()==true and 1 or 0
  252. end
  253. local function d(e)
  254. if o>1 then o=o-1 end
  255. u:text(i(o))
  256. end
  257. local function r(e)
  258. if o<60 then o=o+1 end
  259. u:text(i(o))
  260. end
  261. local function s(e)
  262. if a>1 then a=a-1 end
  263. m:text(i(a))
  264. end
  265. local function o(e)
  266. if a<31 then a=a+1 end
  267. m:text(i(a))
  268. end
  269. D:action(_)
  270. R:action(_)
  271. N:action(T)
  272. l:action(x)
  273. h:action(I)
  274. g:action(O)
  275. k:action(w)
  276. q:action(f)
  277. p:action(e)
  278. y:action(t)
  279. z:action(d)
  280. j:action(r)
  281. b:action(s)
  282. n:action(o)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement