local recordingTime = 3*TICRATE addHook("NetVars", function(n) recordingTime = n($) end) local function setRecordingTime(p, time) if p if tonumber(time) recordingTime = time*TICRATE for q in players.iterate if q.mo and q.mo.valid local reset = q.mo.bloopsRecording local resetPers = q.bloopsRecordingPersistent resetPers.record = {} reset.playbacktimer = 0 reset.timeRemaining = recordingTime end end print("All existing recordings wiped. new recording length is " + tostring(recordingTime/TICRATE) + " seconds.") elseif time == nil CONS_Printf(p, "Adjusts the length of a recording. Currently " + tostring(recordingTime/TICRATE) + " seconds. Entering a new value will wipe all recordings!") else CONS_Printf(p, "A Valid number must be provided.") end else CONS_Printf(p, "You must be in a level to use this command.") end end local function setPlaybackSpeed(p, speed) if p if tonumber(speed) p.bloopsRecordingPersistent.playbackSpeed = speed CONS_Printf(p, "Playback speed set to: " + speed + "x.") elseif speed == nil CONS_Printf(p, "Adjusts playback speed of a recording. Currently " + p.bloopsRecordingPersistent.playbackSpeed + "x.") else CONS_Printf(p, "A Valid number must be provided.") end else CONS_Printf(p, "You must be in a level to use this command.") end end local function Bloops_TapeRecorder_Pause(p) if p p.mo.bloopsRecording.pause = not $ local extra = (p.mo.bloopsRecording.pause) and "paused." or "unpaused." CONS_Printf(p, "Playback " + extra) else CONS_Printf(p, "You must be in a level to use this command.") end end local function Bloops_TapeRecorder_Rewind(p) if p p.mo.bloopsRecording.rewind = not $ local extra = (p.mo.bloopsRecording.rewind) and "." or " back to normal." CONS_Printf(p, "Playback rewinded" + extra) else CONS_Printf(p, "You must be in a level to use this command.") end end local function Bloops_TapeRecorder_Record(p) if p if not p.mo.bloopsRecording.playbacktimer and p.mo.bloopsRecording.timeRemaining == recordingTime p.mo.bloopsRecording.timeRemaining = $ - 1 p.bloopsRecordingPersistent.record = {} CONS_Printf(p, "Recording ghost...") elseif (p.mo.bloopsRecording.playbacktimer) CONS_Printf(p, "Can't Record during playback!") end else CONS_Printf(p, "You must be in a level to use this command.") end end local function Bloops_TapeRecorder_Playback(p) if p if p.mo.bloopsRecording.playbacktimer == 0 and p.bloopsRecordingPersistent.record[1] and not (p.mo.bloopsRecording.timeRemaining > 0 and p.mo.bloopsRecording.timeRemaining < recordingTime) p.mo.bloopsRecording.playbacktimer = 1 CONS_Printf(p, "Playing back recording...") elseif (not p.bloopsRecordingPersistent.record[1]) CONS_Printf(p, "There is no recording to play back!") elseif (p.mo.bloopsRecording.timeRemaining > 0 and p.mo.bloopsRecording.timeRemaining < recordingTime) CONS_Printf(p, "Can't play back during a recording!") end else CONS_Printf(p, "You must be in a level to use this command.") end end local function Bloops_TapeRecorder_ToolTip(p) if p p.bloopsRecordingPersistent.toolTips = not $ local extra = (p.bloopsRecordingPersistent.toolTips) and "showing toolTips." or "no longer showing toolTips." CONS_Printf(p, "Now " + extra) else CONS_Printf(p, "You must be in a level to use this command.") end end local IOPath = 'client/Bloops_TapeRecorder.txt' local function Bloops_TapeRecorder_Setup(p, rec, play, pause, rew) if p if not rec CONS_Printf(p, "A Quick Setup, binds all four main keys. Currently using "+p.bloopsRecordingPersistent.keyBinds[1]+","+p.bloopsRecordingPersistent.keyBinds[2]+","+p.bloopsRecordingPersistent.keyBinds[3]+","+p.bloopsRecordingPersistent.keyBinds[4]+".") else if play and pause and rew local binds = {rec,play,pause,rew} local commands = {'Record','Playback','Pause','Rewind'} local win = 0 for i = 1,4 COM_BufInsertText(p, "bind " +p.bloopsRecordingPersistent.keyBinds[i]) --wipe old binds FIRST end for i = 1,4 /*if string.len(binds[i]) > 1 CONS_Printf(p, "Please provide valid keybinds for use, single characters spaced out.") break end*/ COM_BufInsertText(p, "bind " +binds[i]+ " TRScript_Bloops_"+commands[i]) p.bloopsRecordingPersistent.keyBinds[i] = binds[i] win = $+1 end if win == 4 if io and p == consoleplayer local file = io.openlocal(IOPath, 'w+') file:write(p.bloopsRecordingPersistent.keyBinds[1]+" "+p.bloopsRecordingPersistent.keyBinds[2]+" "+p.bloopsRecordingPersistent.keyBinds[3]+" "+p.bloopsRecordingPersistent.keyBinds[4]) file:close() end CONS_Printf(p, "Keybinds saved to I/O, hopefully.") end else CONS_Printf(p, "Please provide all four keybinds for use.") end end else CONS_Printf(p, "You must be in a level to use this command.") end end local function itBrokeLol(p) COM_BufInsertText(p,"Bloops_TapeRecorder_Setup r y u i") CONS_Printf(p,"Broken file? Creating new one...") end local function IOLoad_BloopsNoPrint(p, rec, play, pause, rew) if p if not rec itBrokeLol(p) else if play and pause and rew local binds = {rec,play,pause,rew} local commands = {'Record','Playback','Pause','Rewind'} for i = 1,4 COM_BufInsertText(p, "bind " +binds[i]+ " TRScript_Bloops_"+commands[i]) p.bloopsRecordingPersistent.keyBinds[i] = binds[i] end else itBrokeLol(p) end end else itBrokeLol(p) end end COM_AddCommand("TRScript_Bloops_Playback", Bloops_TapeRecorder_Playback) COM_AddCommand("TRScript_Bloops_Record", Bloops_TapeRecorder_Record) COM_AddCommand("TRScript_Bloops_Rewind", Bloops_TapeRecorder_Rewind) COM_AddCommand("TRScript_Bloops_Pause", Bloops_TapeRecorder_Pause) COM_AddCommand("TRScript_Bloops_IOStartup", IOLoad_BloopsNoPrint) COM_AddCommand("Bloops_TapeRecorder_Show_ToolTips", Bloops_TapeRecorder_ToolTip) COM_AddCommand("Bloops_TapeRecorder_Playback_Speed", setPlaybackSpeed) COM_AddCommand("Bloops_TapeRecorder_Recording_Time", setRecordingTime, COM_ADMIN) COM_AddCommand("Bloops_TapeRecorder_Setup", Bloops_TapeRecorder_Setup) addHook("MapLoad", function() for p in players.iterate if p.bloopsRecordingPersistent p.bloopsRecordingPersistent.record = {} end end end) addHook("ThinkFrame", function() for p in players.iterate if p.mo and p.mo.valid if not p.bloopsRecordingPersistent p.bloopsRecordingPersistent = { record = {}, keyBinds = {}, toolTips = true, playbackSpeed = 1, somestupidvaluethatprobablyshouldnotexist = nil } end if not p.mo.bloopsRecording p.mo.bloopsRecording = { playbacktimer = 0, timeRemaining = recordingTime, rewind = false, pause = false, somestupidvaluethatprobablyshouldnotexist = nil } --CONS_Printf(p,"This is the part where i read I/O or some shit") --and it is that time, Bloops if p == consoleplayer local file = io.openlocal(IOPath, 'r') if file local theArg = file:read('*a') COM_BufInsertText(p,"TRScript_Bloops_IOStartup " + theArg) CONS_Printf(p,"I/O Loaded Hopefully!") else COM_BufInsertText(p,"Bloops_TapeRecorder_Setup r y u i") CONS_Printf(p,"Blank file, creating new one...") end end end if p.mo.bloopsRecording.timeRemaining > 0 and p.mo.bloopsRecording.timeRemaining < recordingTime table.insert(p.bloopsRecordingPersistent.record, {p.mo.x, p.mo.y, p.mo.z, p.drawangle, p.mo.state, p.mo.frame, p.mo.skin, p.mo.color}) p.mo.bloopsRecording.timeRemaining = max(0, $-1) if p.mo.bloopsRecording.timeRemaining == 0 CONS_Printf(p, "Recording finished!") p.mo.bloopsRecording.timeRemaining = recordingTime end local recGhost = P_SpawnGhostMobj(p.mo) recGhost.color = ColorOpposite(p.mo.color) recGhost.fuse = 1 elseif p.mo.bloopsRecording.timeRemaining == recordingTime if p.mo.bloopsRecording.playbacktimer > 0 local curFrame = p.bloopsRecordingPersistent.record[p.mo.bloopsRecording.playbacktimer] local playbackObject = P_SpawnMobj(curFrame[1], curFrame[2], curFrame[3], MT_THOK) playbackObject.fuse = 1 playbackObject.skin = curFrame[7] playbackObject.color = curFrame[8] playbackObject.angle = curFrame[4] playbackObject.state = curFrame[5] playbackObject.frame = (curFrame[6]& ~ FF_TRANSMASK)|TR_TRANS50 if not p.mo.bloopsRecording.pause p.mo.bloopsRecording.playbacktimer = (p.mo.bloopsRecording.rewind) and max(1, $ - p.bloopsRecordingPersistent.playbackSpeed) or min(recordingTime, $ + p.bloopsRecordingPersistent.playbackSpeed) end if p.mo.bloopsRecording.playbacktimer == recordingTime CONS_Printf(p, "Playback finished!") p.mo.bloopsRecording.playbacktimer = 0 end end end end end end) local function TapeRecorder_ToolTips(v, p) if p.mo and p.mo.valid if p.mo.bloopsRecording and p.bloopsRecordingPersistent and p.bloopsRecordingPersistent.toolTips local HUDTexts = {"Record:", "Playback:","Pause:","Rewind:"} local BloopTape = p.mo.bloopsRecording local BloopTapePers = p.bloopsRecordingPersistent local detectionValues = { (BloopTape.timeRemaining > 0 and BloopTape.timeRemaining < recordingTime), (BloopTape.playbacktimer > 0), (BloopTape.pause), (BloopTape.rewind) } for i = 1, 4 local activeText = detectionValues[i] and (((leveltime%10)+1)>4 and V_REDMAP or V_YELLOWMAP) or 0 v.drawString(200, 10+(i*8), HUDTexts[i]+BloopTapePers.keyBinds[i], V_SNAPTOTOP|V_SNAPTORIGHT|V_PERPLAYER|activeText) end v.drawFill(200,50, 110, 10, 20|V_SNAPTOTOP|V_SNAPTORIGHT|V_PERPLAYER) if detectionValues[1] or detectionValues[2] local targValue = (detectionValues[1]) and BloopTape.timeRemaining+1 or BloopTape.playbacktimer local getColor = (detectionValues[2]) and 112 or 32 local playbackTime = ((FU*targValue/recordingTime)*110)/FU v.drawFill(200,50, playbackTime, 10, getColor|V_SNAPTOTOP|V_SNAPTORIGHT|V_PERPLAYER) end v.drawString(200, 60, "Limit:" +recordingTime/TICRATE+"s", V_SNAPTOTOP|V_SNAPTORIGHT|V_PERPLAYER) v.drawString(200, 68, "Speed:" +BloopTapePers.playbackSpeed+"x", V_SNAPTOTOP|V_SNAPTORIGHT|V_PERPLAYER) end end end hud.add(TapeRecorder_ToolTips)