--[[
OCDLib by Short Circuit
For use by OCD people/ponies who want cool functions for Lua. :P
]]--
--VERSION: 0.1
OCDLib = {}
--Pre-formatted error handler.
function OCDLib.errorDetection( func )
error( "OCDLib." .. func .. " experienced an error of some type." )
end
function OCDLib.makeSomeRoom( spaces )
--Checks if any specific number of spaces is needed.
--(If not, return 2.)
if spaces ~= nil then
for i = 1, spaces do
--\n also works... just don't feel like it. :P
print( "" )
end
--Again, if no specific spaces are returned, use 2 as the default.
elseif spaces == nil then
for i = 1, 2 do
print( "" )
end
--If something fails somehow... use our errorDetection function! :D
else
OCDLib.errorDetection( "makeSomeRoom" )
end
end
--DOS/Windows like pause function.
function OCDLib.pauseAndWait( textstr )
--If you want, define the text to be printed here.
if textstr ~= nil then
print( textstr )
elseif textstr == nil then
--If no text is defined, default to this.
print( "Press Enter to continue..." )
--If something fails somehow... use our errorDetection function! :D
else
OCDLib.errorDetection( "pauseAndWait" )
end
--Actually wait for enter. :P
io.read()
end
--Psuedo true randomness generator.
function OCDLib.trueRandom( min, max )
--Init the randomseed and throw away the first few numbers as they may not always be random.
math.randomseed( os.time() )
--Make a dumping ground for useless numbers.
uselessDumpingGrounds = {}
for i = 1,5 do
--Insert the useless numbers into our dumping grounds.
uselessDumpingGrounds[i] = math.random()
end
--Clear up the memory space used by our dumping grounds.
uselessDumpingGrounds = nil
if min and max ~= nil then
random = math.random( min, max )
--Check for anything that might cause errors...
elseif min == nil then
random = math.random( max )
elseif max == nil then
random = math.random( min, 10 )
elseif min and max == nil then
random = math.random( 10 )
--If something fails somehow... use our errorDetection function! :D
else
OCDLib.errorDetection( "trueRandom" )
end
return random
end
function OCDLib.credits( scriptname, creator, date, use )
if scriptname ~= nil then
print( "Script name: " .. scriptname )
elseif scriptname == nil then
return
elseif creator ~= nil then
print( "Author: " .. creator )
elseif creator == nil then
return
elseif date ~= nil then
print( "Created on: " .. date )
elseif date == nil then
return
elseif use ~= nil then
print( "Used for: " .. use )
elseif use == nil then
return
else
OCDLib.errorDetection( "credits" )
end
end