Jump to content
Sign in to follow this  
Alumian

[Help] Ellipsis Operator in LUA Scripting - Addon Backporting

Recommended Posts

Hi Everyone,

I'm working on backporting an addon from TBC to Classic and the only issue I'm having at the moment is getting around the ellipsis operators. I understand that this operator is used so that a variable number of arguments may be parsed through a function, in this case the function is:

function mod:Report(fmt, ...)
	if EPGP.db.profile.report_channel ~= "NONE" then
		local msg = string.format(fmt, . . .)
		local str = "EPGP:"
		for _,s in pairs({strsplit(" ", msg)}) do
			if #str + #s >= 250 then
				SendChatMessage(str, EPGP.db.profile.report_channel)
				str = "EPGP:"
			end
			str = str .. " " .. s
		end
		SendChatMessage(str, EPGP.db.profile.report_channel)
	end
end

I understand that World of Warcraft 1.12.1 runs off LUA Version 5.0 (I think) and as such this functionality is not available.

Could someone please offer a suggestion on how to work around this?

 

Thanks

Share this post


Link to post
Share on other sites

Pack it in a table, like the ellipsis does:

call:

mod:Report("%s is = %d ",{"someVal",2})

function:

function mod:Report(fmt, arg)
    local test=string.format(fmt,unpack(arg))
    message(test)
end

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×