The code and .DLLs are here, just copy-paste all the scripts and .DLLs into your Powder Toy folder.
To use, press 'j' to start, and then enter the file name and the frame rate of the GIF.
To end it, press control-j. Once you've made it, you have to restart TPT to make another.
There's supposed to be a GIF above this text, but it's not showing up for me. I'll fix that soon.
Version:
1.0:
First created
1.5:
Allow for multiple gifs to be recorded in one session without restart
Removed unneeded code
Planned in next version:
Better GUI, more customizable features
Allow multiple recordings without having to restart
Looping
Current version of script:
require 'gd'
gif = gif or {}
local im = gd.createTrueColor(610, 380)
local scnum = 0
local capt
function gif.control(a, b, c, d)
if a == 'j' and not(c == 64) then
capt = true
gif.current = tpt.input('GIF name', 'Enter the GIF filename here.') .. '.gif'
gif.speed = 100 / tonumber(tpt.input('GIF Speed', 'In FPS', '30'))
im:gifAnimBegin(gif.current, false, 10000)
tpt.register_step(gif.capture)
elseif a == 'j' and c == 64 then
capt = nil
im:gifAnimEnd(gif.current)
tpt.unregister_step(gif.capture)
end
end
tpt.register_keypress(gif.control)
function gif.capture()
if capt then
tpt.screenshot()
im, errstr = gd.createFromPng(("screenshot_%06d"):format(scnum) .. '.png')
if im then im:gifAnimAdd(gif.current, true, 0, 0, gif.speed, gd.DISPOSAL_NONE) end
os.remove(("screenshot_%06d"):format(scnum) .. '.png')
scnum = scnum + 1
end
end
I don't really care about errstr being global, although your second suggestion actually makes sense.
Meh. This works exactly the same.
And why are you always hypercritical of my scripts? THere are much worse ones out there, and mine, while not written as well as they could be, actually work quite well.