All pastes #41771 Raw Edit

haste

public lua v1 · immutable
#41771 ·published 2006-02-15 21:10 UTC
rendered paste body
oRA_Core = {}oRA_Core.Const = {	ChatCmd		= {"/ora"},		ChatOpt 		= {},		Title   		= "oRA_Core",	Version 		= "0.0.1",	Desc    		= "oRA_Core, a CT_RaidAssist clone",	}oRA_Core.Modules = {}oRA_Core.Checks = {}local Const      = oRA_Core.Constlocal Modules	= oRA_Core.Moduleslocal Checks	= oRA_Core.ChecksoRA_Core = AceAddon:new({	name          = Const.Title,	description   = Const.Desc,	version       = Const.Version,	releaseDate   = "",	aceCompatible = 103,	author        = "Haste",	email         = "haste@haste3k.net",	--defaults      = oRA_Core.Default,	db            = AceDatabase:new("oRA_Core_DefaultDB"),	cmd           = AceChatCmdClass:new(Const.ChatCmd,Const.ChatOpt),	category      = "raid",		Disable = function(self)		self:DisableModules()	end,		Enable = function(self)		self:EnableModules()				self:RegisterEvent("CHAT_MSG_RAID", "raidParser")		if(UnitInRaid("player") and self:GetOpt("channel")) then			self:JoinChannel(self:GetOpt("SRaidChannel"))                		elseif(self:GetOpt("SRaidChannel") and not UnitInRaid("player")) then			self:LeaveChannel(self:GetOpt("SRaidChannel"))		end	end,		raidParser = function(self)		local start, endd, chan = string.find(arg1, "<CTMod> This is an automatic message sent by CT_RaidAssist. Channel changed to: (.+)")		if(chan~=nil) then			if(not self:GetOpt("SRaidChannel")) then				self:JoinChannel(chan)			elseif(self:GetOpt("SRaidChannel") and self:GetOpt("SRaidChannel")~=chan) then				self:LeaveChannel(self:GetOpt("SRaidChannel"))				self:JoinChannel(chan)			else				self:DistributeVersion()			end		end	end,		raidDistributeVersion = function(self)		self:Send("V 0.01")	end,		JoinChannel = function(self, chan)		self:SetOpt("SRaidChannel", chan)		self:RegisterEvent("CHAT_MSG_CHANNEL", "raidParseMessage")		self:DistributeVersion()		JoinChannelByName(chan)	end,		LeaveChannel = function(self, currchan)		self:UnregisterEvent("CHAT_MSG_CHANNEL")		LeaveChannelByName(self:GetOpt("SRaidChannel"))		self:SetOpt("SRaidChannel", nil)	end,		raidParseMessage = function(self)		local args = { ["arg1"]=arg1, ["arg2"]=arg2, ["arg3"]=arg3, ["arg4"]=arg4, ["arg5"]=arg5, ["arg6"]=arg6, ["arg7"]=arg7, ["arg8"]=arg8, ["arg9"]=arg9 }		if ( strlower(arg9) == strlower(self:GetOpt("SRaidChannel")) and arg1 and type(arg1) == "string" ) then			if ( not arg1 ) then				return			end						msg = self:Clean(arg1)						for k,v in Checks do				if (string.find(msg, v.regexp)) then					self:TriggerEvent(v.event, args)				end			end		end	end,		isValidRequest = function(self, name)	    if( GetNumRaidMembers() == 0 ) then return FALSE end	    for i = 1, GetNumRaidMembers(), 1 do			local rostername, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(i);			if (rostername == name and rank > 0) then return TRUE end		end		return FALSE	end,		IsPromoted = function(self)	    if(IsRaidLeader() or IsRaidOfficer()) then			return TRUE		else		    self:Msg("You need to be promoted or be the raid leader!")		end	end,		Send = function(self, msg)		msg = string.gsub(msg, "|Hitem:%d+:%d+:%d+:%d+|h(%[[^%|]+%])|h", "%1")		msg = string.gsub(msg, "|c%w%w%w%w%w%w%w%w([^%|]+)|r", "%1")		msg = string.gsub(msg, "s", "$")		msg = string.gsub(msg, "S", "§")				SendChatMessage(msg, "CHANNEL", nil, GetChannelName(self:GetOpt("SRaidChannel")))	end,		Clean = function(self, sMsg)		msg = string.gsub(sMsg, "%$", "s")		msg = string.gsub(msg, "§", "S")			if ( strsub(msg, strlen(msg)-7) == " ...hic!") then			msg = strsub(msg, 1, strlen(msg)-8)		end		return msg	end,------------------------------			Module Loadup			------------------------------	AddModule = function(module)		tinsert(Modules, module)	end,		AddCheck = function(self, event, regexp)		tinsert(Checks, { event=event, regexp=regexp })	end,		EnableModules = function()		for k,v in Modules do v:Enable() end	end,		DisableModules = function()		for k,v in Modules do v:Disable() end	end,})------------------------------------			Load this bitch up!			------------------------------------oRA_Core:RegisterForLoad()------------------------------------			Utils						------------------------------------ace:RegisterFunctions(oRA_Core, {	version = 1.0,		Msg = function(self, ...) self.cmd:msg(unpack(arg)) end,	GetOpt = function(self, var) return self.db:get(self.profilePath,var) end,	SetOpt = function(self, var,val) self.db:set(self.profilePath,var,val) end,})