+ Reply to Thread
Results 1 to 5 of 5

Thread: Events, Creating Bars, Removing Bars

  1. #1
    Telaran Treaborne's Avatar
    Join Date
    Sep 2013
    Posts
    62

    Post Events, Creating Bars, Removing Bars

    I am trying to create bars that appear when an event is received, and at the moment just trying to test if I can create at least 1 bar.

    What I want to do:
    • Increase the number of bars displayed to 10, 20, or 30 bars. And include a slash parameter allowing user to change how many are displayed and save the value.
    • Each bar displayed would get a timer attached to them.
    • Decay the bars over a period of 5 minutes then remove them. And include a slash parameter to change the decay timer.
    • Make the bars move able.
    • Make a button that when clicked shows or hides the bars.

    The main.lua:
    Code:
    local ABTAddonData, PrivateTable = ...
    local Addon, private = ...
    local addon_name = "ABT"
    local addon_messageId="ABT:0.0.1"
    
    local bar=nil
    local waiter=Inspect.Time.Real()
    local waittime=30
    
    ABT = {
    	version=ABTAddonData.toc.Version
    }
    local function L(x) return Translations.ABT.L(x) end
    local myzone = "unknown"
    local myshard = "unknown"
    local lastrecvd = "nothing"
    local waitingtosend = 0
    local foundzone = 0
    local message = "nothing"
    local ignorethis = 0
    local redfont = "#FF0000"
    local greenfont = "#00FF00"
    
    function ABT.printVersion()
    	LibVersionCheck.register("ABT", ABT.version)
    	print(L("ABT Version ") .. (ABT.version) .. L(" installed!"))
    end
    
    -- Begin ABT
    abt = {}
    abtStatusTable = {}
    -- End ABT
    
    
    -- Bar Testing
    abtStatusTable={}
    			print("Status Table Created")
    			local function refresh(handle, parameter)
    				if (parameter == "update") then
    				local isn = Inspect.Shard()
    								local abtEventName = isn.name
    								local abtShardName = Inspect.Shard().name
    								local abtZoneName = Inspect.Unit.Detail("player").locationName
    								local abtTime = os.date("%I:%M:%S", Inspect.Time.Real()+2400)
    								function S_UDx()nH = string.format("%02.f", math.floor((S.ex-S.pex)/3600))
    									nM = string.format("%02.f", math.floor((S.ex-S.pex)/60 - (nH*60)))
    									nS = string.format("%02.f", math.floor((S.ex-S.pex) - nH*3600 - nM *60))
    									if S.ex > 3600 then 
    										abtTime:SetText(" "..nH..":"..nM..":"..nS)
    									elseif S.ex > 60 then 
    										abtTime:SetText(" 00:"..nM..":"..nS)
    									else 
    										abtTime:SetText(" 00:00:"..nS)
    									end 
    								end
    								local abtBarEventName=abtEventName
    								local abtBarEventIn=abtBarEventName .." in " .. abtZoneName
    								local abtBarMessage=abtBarEventIn .. "@" .. abtShardName
    								local abtBarName=abtBarMessage:len()+2
    								abtAccepted={
    									["event"]=abtEventName,
    									["zone"]=abtZoneName,
    									["shard"]=abtShardName,
    									["barname"]=abtBarName,
    									["cooldown"]=abtTime,
    								}
    								abtStatusTable["accepted"]=abtAccepted			
    								print("Table abtStatusTable: " .. unpack(abtStatusTable))
    								
    				elseif (parameter == "") then
    					print("Invalid: /abt")
    					print("Commands are: /abt update, clear")
    				elseif (parameter == "clear") then
    					print("Command: /abt " .. parameter .. " not implemented.")
    				else
    					print("Unknown: /abt " .. parameter)
    					print("Commands are: /abt update, clear")
    				end
    			end
    			
    local function eventAdd(event, zone, shard, barname, cooldown)
    print("Function eventAdd started")
    					-- local bar = (table.remove(inactiveBars) or createBar())
    	print("Event = " .. event .. " Zone = " .. zone.. " shard = " .. shard.. " Time = " .. cooldown)
    	resync = true
    	
    	activeBars[ourtime] = bar
    	bar:SetVisible(true)
    	bar.text(event .. " active on " .. zone .. " @ " .. shard " Time " .. cooldown) -- Noticed your using a . here
    	refresh()
    	print("Function eventAdd ended")
    end
    
    local function createBar()
    print("Function createBar started")
    	local bar = UI.CreateFrame("Frame", "bar", context)
    	
    	bar:SetPoint("TOP", UIParent, "TOP")
    
    	bar.text = UI.CreateFrame("Text", "Text", bar)
    
    	bar.solid = UI.CreateFrame("Frame", "Solid", bar)
    	bar.solid:SetLayer(-1)
    
    	bar.text:SetText("test")
    	bar.text:SetHeight(bar.text:GetHeight())
    
    	bar.text:SetPoint("TOPLEFT", bar, "TOPRIGHT")
    	bar:SetPoint("BOTTOM", bar.text, "BOTTOM")
    
    	bar.solid:SetPoint("TOPLEFT", bar, "TOPLEFT")
    	bar.solid:SetPoint("BOTTOMRIGHT", bar, "BOTTOMRIGHT")
    
    	bar:SetWidth(320)
    print("Function eventActiveBar started")
    	function bar.eventActiveBar(event)
    	-- Using . rather than : as : isnt needed for mapping a function, might also fix your problem
    		if not event then dump("Event was not Triggered") return end
    		-- Debug dump, we dont like nils
    		
    		local eventN = event
    		
    		print(event .. " stored in eventN eventActiveBar")
    		
    		if eventN then
    			print(eventN .. " is active in eventActiveBar(eventN)")
    			
    			self:SetBackgroundColor(0.5, 0.3, 0.3, 0.3)
    			self.solid:SetBackgroundColor(0.5, 0.3, 0.3)
    			self.text:SetFontSize(20)
    			self.text:SetHeight(self.text:GetHeight())
    			self.text:SetText(eventN)
    			self.solid:SetVisible(true)
    			print("eventActiveBar created")
    		else
    			print("No eventActiveBar created")
    			print("Function eventActiveBar ended")
    		end
    		print("Function createBar ended")
    	end
    print("starting return bar")
    	return bar end
    	
    local function updateEnd()
    end
    -- Bar Testing
    
    
    
    
    
    Command.Message.Accept(nil, addon_messageId)
    Command.Event.Attach(Command.Slash.Register("abt"), refresh, "ABT")
    
    table.insert(Event.System.Update.Begin, {eventAdd, "ABT", "ABTBegin"})
    Command.Event.Attach(Event.System.Update.End, updateEnd, "ABTEnd")
    Command.Event.Attach(Event.Addon.SavedVariables.Save.Begin, abt_save, "ABTSaveBegin")
    Command.Event.Attach(Event.Addon.SavedVariables.Load.End, abt_load, "ABTLoadEnd")
    Current Error:
    Code:
    Error: ABT/main.lua:84: attempt to concatenate local 'cooldown' (a nil value)
        In ABT / ABTBegin, event Event.System.Update.Begin
    stack traceback:
    	ABT/main.lua:84: in function <ABT/main.lua:81>
    ____________
    Rift Addons
    [ Zone Event Tracker ] [ Power of Nightmares ] [ Sync Mo Friends ]

  2. #2
    Telaran Treaborne's Avatar
    Join Date
    Sep 2013
    Posts
    62

    Default

    Quote Originally Posted by Noshei
    not sure if I would recommend using:
    table.insert(Event.System.Update.Begin, {eventAdd, "ABT", "ABTBegin"})
    I feel like that will cause you a lot of issues, and it is certainly why you are getting spammed with that error message
    I removed that line and now have this:
    Code:
    Error: ABT/main.lua:68: attempt to concatenate a nil value
        In ABT / ABT, event Event.Slash.abt
    stack traceback:
    	[C]: in function '__concat'
    	ABT/main.lua:68: in function <ABT/main.lua:38>
    I removed the unpack() from line 68:
    Code:
    Error: ABT/main.lua:68: attempt to concatenate global 'abtStatusTable' (a table value)
        In ABT / ABT, event Event.Slash.abt
    stack traceback:
    	[C]: in function '__concat'
    	ABT/main.lua:68: in function <ABT/main.lua:38>
    I removed the print() line now no errors reported in console, but still no bars appearing.
    Last edited by Treaborne; 01-11-2015 at 11:48 AM.
    ____________
    Rift Addons
    [ Zone Event Tracker ] [ Power of Nightmares ] [ Sync Mo Friends ]

  3. #3
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    local bar = UI.CreateFrame("Frame", "bar", context)

    What is context?

    Normally you would do something like

    local context = UI.CreateContext(Addon.identifier)

    You add the funcitons abt_load and abt_save as handlers, but these functions dont seem to exist.

    activeBars[ourtime] = bar

    What is 'ourtime' - it is never set, so will always be nil

    Also what is bar - you have a local bar = nil at the top of the file, but this doesnt serem to be set anywhere, all the other references I can see to bar are local to the function it is used in.

    You are using Event.System.Update.Begin, and seem to think the function that gets called has these arguments:

    local function eventAdd(event, zone, shard, barname, cooldown)

    It doesnt get called with these, which is why you are getting nil values - use tostring() on naything you print out that you are not 100% sure will not be nil:

    print("Event = " .. tostring(event) .. " Zone = " .. tostring(zone).. " shard = " .. tostring(shard).. " Time = " .. tostring((cooldown))
    Last edited by Adelea; 01-12-2015 at 03:29 AM.
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  4. #4
    Telaran Treaborne's Avatar
    Join Date
    Sep 2013
    Posts
    62

    Default

    Awesome was wondering how the tostring was used, and got everything working late last night. Changed a few things and got the bars to create using a slash command, and can now drag it around.

    Problems:
    None of the bars expire, and last until a reload or logout.

    Goal:
    Ideally I want to create something similiar to the Gadgets Buff bar, but for tracking notifications. The notification bars would have a solid background, a decay timer to remove them after a default time, player set time, or possibly till a right click clears it, and a mouse over would be used for displaying details about the notification. Some how I would like to integrate all this into Gadgets to allow for a cleaner look, and hopefully make it easier to configure.

    Note that this code for 'A Bar Test' is just that a bar test, and not considered usable as a real addon. And as a means to better understand how bars are created, and although it works there is a of functionality missing. Code added below:
    Code:
    local ABTAddonData, PrivateTable = ...
    local Addon, private = ...
    
    local abtsizes={
    ["e"]="0",
    ["a"]="0",
    ["z"]="0",
    ["b"]="100",
    }
    
    abtcontext = UI.CreateContext("abtcontext")
    abtcontext = UI.CreateFrame("Frame", "Bar", abtcontext)	
    abtcontext:SetBackgroundColor(0,0,0,1)
    abtcontext:SetPoint("TOP", UIParent, "TOP")
    abtcontext:SetHeight(30)
    abtcontext:SetWidth(100)
    abtcontext.text = UI.CreateFrame("Text", "Text", abtcontext)
    
    	abtbar = UI.CreateFrame("Frame", "abtBar", abtcontext)
    	abtcontext.text:SetText("Events")
    	abtcontext.text:SetPoint("CENTER", abtcontext, "CENTER")
    	local f12 = 12
    	local f24 = math.floor(f12 * 2)
    	abtcontext.text:SetFontSize(f24)
    	
    	abtbar:SetPoint("TOPLEFT", abtcontext, "BOTTOMLEFT")
    	
    	abtbar:SetBackgroundColor(0,1,0,0.5)
    	abtbar:SetAlpha(0.7)
    	abtbar:SetLayer(-1)
    	abtbar:SetWidth(100)
    	
    	abtzone = UI.CreateFrame("Frame", "abtZone", abtbar)
    	abtzone = UI.CreateFrame("Text", "Text", abtbar)
    	
    	
    	
    	abtevent = UI.CreateFrame("Frame", "abtEvent", abtbar)
    	abtevent = UI.CreateFrame("Text", "Text", abtbar)
    	
    	
    	abtshard = UI.CreateFrame("Frame", "abtShard", abtbar)
    	abtshard = UI.CreateFrame("Text", "Text", abtbar)
    	
    	abtzone.time = Inspect.Time.Real()
    	abtevent.time = Inspect.Time.Real()
    	abtshard.time = Inspect.Time.Real()
    
    
    	
    	
    function createBar(handle, event, zone, shard, cooldown)	
    	
    	local f100 = 14
    	local f80  = math.floor(f100 * 1.2)
    	
    	abtevent:SetFontSize(f80)
    	abtshard:SetFontSize(f80)
    	abtzone:SetFontSize(f80)
    	
    	local h = abtevent:GetHeight()
    	
    	abtzone:SetText(" active on " .. zone)
    	abtevent:SetText("Unstable Event")
    	abtshard:SetText(" @ " .. shard)
    		abtzone:SetVisible(true)
    		abtshard:SetVisible(true)
    		abtevent:SetVisible(true)
    
    	local e=abtevent:GetWidth()
    	local z=abtzone:GetWidth()
    	local s=abtshard:GetWidth()
    	local b=e+z+s
    	print(b)
    	abtbar:SetWidth(b+32)
    	resync = true
    	abtevent:SetPoint("CENTERLEFT", abtbar, "CENTERLEFT", 16, 0)
    	abtshard:SetPoint("CENTERLEFT", abtzone, "CENTERRIGHT")
    	abtzone:SetPoint("CENTERLEFT", abtevent, "CENTERRIGHT")
    	
    	end
    
    function eventAdd(handle, event, zone, shard, cooldown)
    nowtime=Inspect.Time.Real()
          if (nowtime >= abtzone.time+30) then
    		abtzone:SetVisible(false)
    		abtshard:SetVisible(false)
    		abtevent:SetVisible(false)
    	abtzone.time = Inspect.Time.Real()+5
    	abtevent.time = Inspect.Time.Real()+5
    	abtshard.time = Inspect.Time.Real()+5
    	local abtbar = createBar(handle, event, zone, shard, cooldown)
    	else
    		
    	local abtbar = createBar(handle, event, zone, shard, cooldown)
    	resync = true
    	end
    end
    	
    function eventAlert(handle)
    
    	local consoles=Inspect.Console.List()
    	local newShardName = Inspect.Shard().name
    	local isn = Inspect.Shard()
    		abtEventName = isn.name
    		abtShardName = Inspect.Shard().name
    		abtZoneName = Inspect.Unit.Detail("player").locationName
    		abtTime = Inspect.Time.Real()+2400
    		abtTimeDecay = abtTime+30
    
    	local event=abtEventName
    	local zone=abtZoneName
    	local shard=abtShardName
    	local cooldown=abtTimeDecay
    				
    	eventAdd(handle, event, zone, shard, cooldown)
    end
    
    abtbar:EventAttach(Event.UI.Input.Mouse.Left.Down, function(self, h)
    	self.MouseDown = true
    	local mouseData = Inspect.Mouse()
    	self.sx = mouseData.x - abtcontext:GetLeft()
    	self.sy = mouseData.y - abtcontext:GetTop()
    	end, "Event.UI.Input.Mouse.Left.Down")
    
    abtbar:EventAttach(Event.UI.Input.Mouse.Cursor.Move, function(self, h)
    		if self.MouseDown then
    			local nx, ny
    			local mouseData = Inspect.Mouse()
    			nx = mouseData.x - self.sx
    			ny = mouseData.y - self.sy
    			abtcontext:SetPoint("TOPLEFT", UIParent, "TOPLEFT", nx,ny)
    
    			resync=true
    		end
    	end, "Event.UI.Input.Mouse.Cursor.Move")
    
    abtbar:EventAttach(Event.UI.Input.Mouse.Left.Up, function(self, h)
    		if self.MouseDown then
    			self.MouseDown = false
    		end
    	nx = abtbar:GetLeft()
    	ny = abtbar:GetTop()
    		
    	end, "Event.UI.Input.Mouse.Left.Up")
    
    	
    
    
    Command.Event.Attach(Command.Slash.Register("abt"), eventAlert, "ABT")
    My question now is how would I get multiple bars attached to the bottom of events and push the oldest down.

    In theory I would like it to look like this
    EVENTS
    • Event 4
    • Event 3
    • Event 2
    • Event 1

    So by that list the most recent event "Event 4" is at the top, and the first event "Event 1" is at bottom.

    Last edited by Treaborne; 01-14-2015 at 07:53 PM.
    ____________
    Rift Addons
    [ Zone Event Tracker ] [ Power of Nightmares ] [ Sync Mo Friends ]

  5. #5
    Telaran Treaborne's Avatar
    Join Date
    Sep 2013
    Posts
    62

    Thumbs up

    Got everything working now,

    Thanks for all the help here in forums and in the #riftuidev channel, greatly appreciate the assistance it helped very much.
    ____________
    Rift Addons
    [ Zone Event Tracker ] [ Power of Nightmares ] [ Sync Mo Friends ]

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts