--[[ PROGRAM NAME: LUA SINGE VERSION: 1.1 AUTHOR: KARIS (2020) This file is part of LUA SINGE. LUA SINGE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. LUA SINGE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Thanks to Scott Duensing, RDG. ]]-- iSecs = 0 iLimit = 0 lastSeconds = 0 thisSeconds = 0 sprText = nil sprShadow = nil sLastText = nil iLastColor = -1 iLastShadow = -1 tSecs = 0 tLimit = 0 tlastSeconds = 0 tthisSeconds = 0 bTommy = false bGunMute = false iMuteFrames = 0 MUTE_DELAY = 35 heartbeat = false blinkSecs = 0 lastBlinkSecs = 0 iRevFrames = 0 REV_DELAY = 10 bReversePointer = false revsetx = 0; revsety = 0 iFrameStart = 0; iFrameEnd = 0 CHANNEL_LEFT = 1 CHANNEL_RIGHT = 2 ALL_CHANNELS = 3 bMuteAttract = false RED = 0 BLUE = 1 YELLOW = 2 GREEN = 3 ORANGE = 4 WHITE = 5 GREY = 6; GRAY = 6 LIGHTBLUE = 7 BLACK = 8 function singeRandomize() math.randomseed(os.time()) -- random initialize math.random(); math.random(); math.random() -- warming up end function blinkTimer(thisMS) -- Function blinks every second. blinkSecs = os.clock() if bPause then lastBlinkSecs = blinkSecs else if (blinkSecs - lastBlinkSecs > thisMS) then heartbeat = not heartbeat lastBlinkSecs = blinkSecs end end end function goTimer(thisMS) blinkSecs = os.clock() if bPause then lastBlinkSecs = blinkSecs else if (blinkSecs - lastBlinkSecs > thisMS) then heartbeat = true lastBlinkSecs = blinkSecs end end end function clockRnd() local j = 0 local q = 0 local w = 0 local r = 0 local b1 = true j = os.clock() q, w = math.modf(j) s2 = tostring(w) r = string.find(s2,".") if (r == nil) then s2 = tostring(q) s2 = string.sub(s2,string.len(s2), string.len(s2)) else s2 = string.sub(s2, r + 1) r = string.len(s2) if r == 0 then s2 = tostring(q) s2 = string.sub(s2,string.len(s2), string.len(s2)) elseif r == 2 then s2 = string.sub(s2, 2, 2) elseif r >= 3 then s2 = string.sub(s2, 3, 3) end end w = tonumber(s2) return w end function timerOFF() iSecs = 0 iLimit = 0 end function timerON(thisLong) iSecs = 0 iLimit = thisLong lastSeconds = os.clock() end function timerDue() thisSeconds = os.clock() if bPause then lastSeconds = thisSeconds else if (thisSeconds ~= lastSeconds) then iSecs = iSecs + thisSeconds - lastSeconds lastSeconds = thisSeconds end if (iSecs >= iLimit) then timerOFF() return true else return false end end end function muteSound() iMuteFrames = 0 bGunMute = true end function blinkRev() iRevFrames = 0 bReversePointer = true end function setupClip(thisA, thisB) iFrameStart = thisA iFrameEnd = thisB discSkipToFrame(thisA) end function monoAudio (thisChannel) if thisChannel == CHANNEL_LEFT then discAudio (2, false) discAudio (1, true) elseif thisChannel == CHANNEL_RIGHT then discAudio (1, false) discAudio (2, true) end end function resetChannels() discAudio(1, true) discAudio(2, true) end function muteAudio() discAudio(1, false) discAudio(2, false) end function setFontColor(thisColor) if thisColor == RED then colorForeground(255, 0, 0) elseif thisColor == BLUE then colorForeground(0, 0, 255) elseif thisColor == YELLOW then colorForeground(255, 255, 0) elseif thisColor == GREEN then colorForeground(0, 255, 0) elseif thisColor == ORANGE then colorForeground(255, 150, 0) elseif thisColor == WHITE then colorForeground(255, 255, 255) elseif thisColor == GREY or thisColor == GRAY then colorForeground(128, 128, 128) elseif thisColor == LIGHTBLUE then colorForeground(30, 160, 250) elseif thisColor == BLACK then colorForeground(0,0,0) elseif thisColor == PINK then colorForeground(252,0,148) end end function textPrint(thisMsg, thisx, thisy, thisFont, thisColor, thisShadow) fontSelect(thisFont) setFontColor(thisColor) fontPrint(thisx,thisy,thisMsg) end function getMiddle(thisPhrase) local x = 0 local y = 0 local sprite = fontToSprite(thisPhrase) x = OVLW/2 - spriteGetWidth(sprite) * 0.5 y = OVLH/2 - spriteGetHeight(sprite) * 0.5 spriteUnload(sprite) return x end