Quantcast
Download
(4 Kb)
Download
Updated: 08/17/20 04:09 PM
Pictures
File Info
Compatibility:
Stonethorn (6.1.5)
Updated:08/17/20 04:09 PM
Created:04/06/20 01:41 PM
Monthly downloads:147
Total downloads:1,046
Favorites:4
MD5:
6.1.5
DuesPaid
Version: 3.7
by: TuckerScorpions [More]
DuesPaid is a reminder addon to pay your guild dues.

DuesPaid has 4 settings in the options menu.
1) Display the message in a popup window or the notifications window
2) The day to show your message
3) Custom header to display
4) Custom message to display

Needed libraries:
LibMainMenu-2.0
LibNotifications
3.7 fixed issue with not showing up in minion
3.5 changed default day to Monday
3.4 changed yes/no button to have best practice code
3.3 changed many global variables to local designations
3.2 fixed notifications so it only removes the correct one
changed code to have unique variables
Special thanks to Baertram and Scootworks for help with the code and best practices advice
3.1 Removed LibStub and all references of it from DuesPaid.lua and DuesPaid.txt
Optional Files (0)


Archived Files (7)
File Name
Version
Size
Uploader
Date
3.6
4kB
TuckerScorpions
08/17/20 02:39 PM
3.5
4kB
TuckerScorpions
08/05/20 01:20 PM
3.4
4kB
TuckerScorpions
04/14/20 07:56 AM
3.3
4kB
TuckerScorpions
04/12/20 10:09 AM
3.2
4kB
TuckerScorpions
04/08/20 03:06 PM
3.1
4kB
TuckerScorpions
04/07/20 02:25 PM
3.0
4kB
04/06/20 01:41 PM


Post A Reply Comment Options
Unread 08/17/20, 04:23 PM  
TuckerScorpions
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 3
Uploads: 1
Originally Posted by BigM
Not showing in Minion. You need to delete rename file to get numbers out.

1596655202-DuesPaid does not unzip to proper place in addons.
Thank you for pointing this issue out to me. I had it package wrong. Rookie mistake!
Last edited by TuckerScorpions : 08/17/20 at 04:24 PM.
Report comment to moderator  
Reply With Quote
Unread 08/05/20, 09:26 PM  
BigM
 
BigM's Avatar

Forum posts: 15
File comments: 366
Uploads: 0
Not showing in Minion. You need to delete rename file to get numbers out.

1596655202-DuesPaid does not unzip to proper place in addons.
Report comment to moderator  
Reply With Quote
Unread 04/12/20, 07:19 PM  
TuckerScorpions
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 3
Uploads: 1
Thanks for everything and all the help. I have learned a lot.
.
Originally Posted by Baertram
Looks good now, only this function should be added to your global DUESPAIDTable:

Code:
function resetWindowClose(settingChoice)
->
Lua Code:
  1. function DUESPAIDTable.resetWindowClose(settingChoice)

And in your XML file call the function then with the DUESPAIDTable global in front:
Code:
<OnClicked>
   self:GetOwningWindow():SetHidden(true)								
   DUESPAIDTable.resetWindowClose(true)						
</OnClicked>
Report comment to moderator  
Reply With Quote
Unread 04/12/20, 12:28 PM  
Baertram
 
Baertram's Avatar
AddOn Author - Click to view AddOns

Forum posts: 3095
File comments: 3718
Uploads: 63
Looks good now, only this function should be added to your global DUESPAIDTable:

Code:
function resetWindowClose(settingChoice)
->
Lua Code:
  1. function DUESPAIDTable.resetWindowClose(settingChoice)

And in your XML file call the function then with the DUESPAIDTable global in front:
Code:
<OnClicked>
   self:GetOwningWindow():SetHidden(true)								
   DUESPAIDTable.resetWindowClose(true)						
</OnClicked>
Last edited by Baertram : 04/12/20 at 12:28 PM.
Report comment to moderator  
Reply With Quote
Unread 04/10/20, 08:59 AM  
Baertram
 
Baertram's Avatar
AddOn Author - Click to view AddOns

Forum posts: 3095
File comments: 3718
Uploads: 63
You still have A LOT of global variables in your DuesPaid.lua file!
Check function popupMenu e.g.
xyz
title
question
LN_provider

They all miss the local in front and thus they are global and overwrite all variables with the same name...
Or you need to add them to your table DuesPaid instead so they don't float through the _G table!

Please check all your code again, maybe use a helping editor like Eclipse or IntelliJ.
Especially check your functions!
function OnAddonLoaded(event, addon)
Should be:
local function OnAddonLoaded(event, addon)

Or:
function DPAID.OnAddonLoaded(event, addon)

Check the forums here for example UIs which support ESO lua, if you set them up:
https://www.esoui.com/forums/forumdisplay.php?f=173

Also:
If you use EVENT_MANAGER:RegisterForUpdate you need to unregister the update as well again! Or it will be called every 1 second again and again and again:
EVENT_MANAGER:RegisterForUpdate(ADDON_NAME, 1, popupMenu)
Read here: https://wiki.esoui.com/Running_LUA-Code_asynchroneously#RegisterForUpdate

And why do you use 2 globals for your addon? DPAID and DUESPAIDTable? Just use DPAID and add your variables to it in settings.lua
Last edited by Baertram : 04/10/20 at 09:03 AM.
Report comment to moderator  
Reply With Quote
Unread 04/07/20, 07:27 PM  
Scootworks
 
Scootworks's Avatar
AddOn Author - Click to view AddOns

Forum posts: 290
File comments: 148
Uploads: 26
Originally Posted by TuckerScorpions
Thank you for taking the time and showing me all these updates that I should make to my addon. I would like it the best it can be. As a first time programmer I am still learning. I will definitely take care of this. If anyone has any other suggestions, I am 100% happy to hear them and learn.
heyho. thanks for your addon. i recommend to change your notification stuff a bit:

Lua Code:
  1. local function RemoveNotification(notificationId)
  2.     local provider = LN_provider
  3.     table.remove(provider.notifications, notificationId)
  4.     provider:UpdateNotifications()
  5. end
  6.  
  7. local function acceptNotification(data)
  8.     DUESPAID.Settings.SavedSettings[1] = false
  9.     RemoveNotification(data.notificationId)
  10. end
  11.  
  12. local function declineNotification(data)
  13.     DUESPAID.Settings.SavedSettings[1] = true
  14.     RemoveNotification(data.notificationId)
  15. end
  16.  
  17. -- Function to add custom notification
  18. local function addNotification()
  19.     -- Custom notification info
  20.     local msg = {
  21.             dataType                = NOTIFICATIONS_YES_NO_DATA,
  22.             secsSinceRequest        = ZO_NormalizeSecondsSince(0),
  23.             message                 = DUESPAID.Settings.SavedSettings[4],
  24.             heading                 = DUESPAID.Settings.SavedSettings[3],
  25.             texture                 = "EsoUI/Art/MainMenu/menuBar_notifications_down.dds",
  26.             shortDisplayText        = "!",
  27.             controlsOwnSounds       = false,
  28.             keyboardAcceptCallback  = function(data) acceptNotification(data) end,
  29.             keybaordDeclineCallback = function(data) declineNotification(data) end,
  30.             gamepadAcceptCallback   = function(data) acceptNotification(data) end,
  31.             gamepadDeclineCallback  = function(data) declineNotification(data) end,
  32.         }
  33.         if shown == "1" then
  34.             shown = "0"
  35.             local provider = LN_provider
  36.             provider.notifications[1] = msg
  37.             provider:UpdateNotifications()
  38.         end
  39. end

on your current solution, it will always deletes all notification, even if you have more than one (maybe). with the solution above, it will only delete the notification you clicked on.
__________________
EU Server - SŁĄuGhTerHĜuSe
Report comment to moderator  
Reply With Quote
Unread 04/07/20, 07:02 PM  
Baertram
 
Baertram's Avatar
AddOn Author - Click to view AddOns

Forum posts: 3095
File comments: 3718
Uploads: 63
Well and a few more hints or let me say "No gos":
In your settings.lua you have defined some global variables which pollute the _G (global variables table) namespce now with non-unique variables names like
"message"

If any other addon or even ZOs vanila code uses a variable with the same name, which is most likely if you deifne it like "message" or "text", it's now overwritten.

Please define a table for your addon in your own namespace, like:

--In your first file that is called from your txt (manifest) file:
Lua Code:
  1. myAddonsTable = {}
  2. local myAddon = myAddonsTable  --local short reference to your global table

You already use DUESPAID in your one file, so why not reuse it even for the settings and the other files?

In any other file which is called later from your txt file reuse this global table like this:
Lua Code:
  1. myAddonsTable = myAddonsTable or {}
  2. local myAddon = myAddonsTable  --local short reference to your global table

Add your variables needed in several files ONLY to this global namespace of your addon:
myAddon.message ="Hello world"
-> will put the variable message to your global table myAddonsTable which is then accessible either by myAddonsTable.message or myAddon.message (if you have defined the short local for a reference lookup) in all of your files where you have defined myAddonsTable = myAddonsTable or {} at the top.


And keep all other variables which are not needed in any other file local.
Define them like
local myVarOnlyNeededHereInThisFile or
local myVarOnlyNeededHereInThisForLoop or
local myVarOnlyNeededHereInThisIf

Info about lua tables:
https://wiki.esoui.com/LUA_Tables

Multi language support
If you want to add multi language support have a look here:
https://wiki.esoui.com/Addon_manifest_(.txt)_format
https://wiki.esoui.com/Addon_manifest_(.txt)_format#Variable_Expansion


Code:
About your LibNotifications:
Currently your functions accept/decline will delete ALL of your messages
Lua Code:
  1. local function acceptNotification()
  2.     DUESPAID.Settings.SavedSettings[1] = false
  3.     LN_provider.notifications = {}
  4.     LN_provider:UpdateNotifications()
  5. end
  6.  
  7. local function removeNotification()
  8.     DUESPAID.Settings.SavedSettings[1] = true
  9.     LN_provider.notifications = {}
  10.     LN_provider:UpdateNotifications()
  11. end

LN_provider.notifications = {} this empties the table with the notifications. No matter which notification you press -> all of your added ones will be gone.

Each notification entry got a data table with a notificaitonId.
So you need to only remove the entry where you have clicked on, using the notificationId of the data table:

Lua Code:
  1. local function RemoveNotification(data)
  2.                     table.remove(provider.notifications, data.notificationId)
  3.                     provider:UpdateNotifications()
  4.                 end
  5.  
  6.  
  7. --In your defined provider's keyboard accept or delince functions:
  8. keyboardAcceptCallback    = function(data)
  9.                             --Do your code here
  10.                                  ....
  11.                             --Remove the notification then afterwards
  12.                             RemoveNotification(data)
  13.                         end,

You can use addons like ZGOO or mer Torchbug to inspect the controls below your mouse, or to look into e..g the global NOTIFICATIONS table.
Last edited by Baertram : 04/07/20 at 07:10 PM.
Report comment to moderator  
Reply With Quote
Unread 04/07/20, 01:16 PM  
TuckerScorpions
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 3
Uploads: 1
Thank you for taking the time and showing me all these updates that I should make to my addon. I would like it the best it can be. As a first time programmer I am still learning. I will definitely take care of this. If anyone has any other suggestions, I am 100% happy to hear them and learn.

Originally Posted by Baertram
Thanks for the addon but please do NOT use LibStub anymore! It's obsolete.
You should NEVER add it to new addons anymore if not needed and LibNotifications as well as LibAddonMenu-2.0 provide global variables you can use instead.
So please change your txt file from

wrong:
Code:
## DependsOn: LibStub LibNotification LibAddonMenu-2.0
Beside LibStub should never be added as a dependency of your addon directly, but only to the libraries needed. They got their own txt file where LibStub is added (as optional dependency meanwhile as it is obsolete).

correct:
Code:
## DependsOn: LibNotification>=7 LibAddonMenu-2.0>=28
Adding the version of the libraries via >= in your txx files assures that the versions will be needed which provide the global variables which you need to access the libraries.
You'll find their version in the txt file of the lib, e.g. LibAddonMenu-2.0.txt at the ##AddOnVersion: tag!


In your code remove the LibStub stuff totally and use the global variables of the libraries instead. You'll find them on the library description pages or in their changelog:

LibNotifications
LibAddonMenu2


If you are unsure check this wiki entry here for more information about libraries, versioning and why LibStub will be gone soon (since Summerset...):
https://wiki.esoui.com/Libraries#Library_versioning

And if you have taken your code from any example, please tell us where it's still old and not updated so ppl will get the changes about LibStub and stop spreading old code!
Report comment to moderator  
Reply With Quote
Unread 04/07/20, 12:37 PM  
Baertram
 
Baertram's Avatar
AddOn Author - Click to view AddOns

Forum posts: 3095
File comments: 3718
Uploads: 63
Thanks for the addon but please do NOT use LibStub anymore! It's obsolete.
You should NEVER add it to new addons anymore if not needed and LibNotifications as well as LibAddonMenu-2.0 provide global variables you can use instead.
So please change your txt file from

wrong:
Code:
## DependsOn: LibStub LibNotification LibAddonMenu-2.0
Beside LibStub should never be added as a dependency of your addon directly, but only to the libraries needed. They got their own txt file where LibStub is added (as optional dependency meanwhile as it is obsolete).

correct:
Code:
## DependsOn: LibNotification>=7 LibAddonMenu-2.0>=28
Adding the version of the libraries via >= in your txx files assures that the versions will be needed which provide the global variables which you need to access the libraries.
You'll find their version in the txt file of the lib, e.g. LibAddonMenu-2.0.txt at the ##AddOnVersion: tag!


In your code remove the LibStub stuff totally and use the global variables of the libraries instead. You'll find them on the library description pages or in their changelog:

LibNotifications
LibAddonMenu2


If you are unsure check this wiki entry here for more information about libraries, versioning and why LibStub will be gone soon (since Summerset...):
https://wiki.esoui.com/Libraries#Library_versioning

And if you have taken your code from any example, please tell us where it's still old and not updated so ppl will get the changes about LibStub and stop spreading old code!
Last edited by Baertram : 04/07/20 at 12:39 PM.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: