Quantcast Guild Dues - ESOUI
Thread Tools Display Modes
08/19/18, 07:04 PM   #1
ESOARMY's Avatar
Join Date: Nov 2016
Posts: 10
Guild Dues

So there I was last week knee deep in White Gold Tower and I get a message from one of the Generals.. "bidding closes in 15 minutes, please pay your dues to stay in the guild" and boom! The idea for a new addon was born. "Guild Dues" puts a small icon, keybind or slash command to quickly create and send your dues to the guild master. The only problem is, it doesn't work. I am not that great with lua and tried to piece this together from examples throughout the week. It feels like I am close but it keeps giving me errors. I think if I can get a simple working version I will be able to expand with menus for all the variables such as dues, minimum gold to keep, guild master name, subject text, body text and maybe more. It is very simple at the moment and not working of course. This is my first addon so any help would be appreciated and name in the credits. Here is what I have so far. Please forgive me for being such a noob if the solution is extremely apparent. Thanks

Lua Code:
  1. GuildDues = {}
  3. GuildDues.name = "GuildDues"
  6. function GuildDues:Initialize()
  7.     self.MyGold = GetCurrentMoney()
  9.     EVENT_MANAGER:RegisterForEvent(self.name, EVENT_MONEY_UPDATE, self.OnPlayerMoneyUpdate)
  10.     self.savedVariables = ZO_SavedVars:New("GuildDuesSavedVariables", 1, nil, {})
  11.     self:RestorePosition()
  13. end
  15. local function createDonationButton(owningWindow)
  16.     local button = WINDOW_MANAGER:CreateControl(owningWindow:GetName().."GuildDues", owningWindow, CT_BUTTON)
  17.     local b = button
  18.     b:SetDimensions(34, 34)
  19.     b:SetNormalTexture("ESOUI/art/chatwindow/chat_mail_up.dds")
  20.     b:SetMouseOverTexture("ESOUI/art/chatwindow/chat_mail_over.dds")
  21.     b:SetHandler("OnClicked",function()PayDues(b) end)
  22.     b:SetAnchor(BOTTOMLEFT,owningWindow, BOTTOMLEFT,5,5)
  23.     return button
  24. end
  27. function GuildDues.OnAddOnLoaded(event, addonName)
  28.   if addonName == GuildDues.name then
  29.     GuildDues:Initialize()
  30.   end
  31. end
  34. local function PayDues(self)
  35.     local r = "@GuildLeader"
  36.     local s = "Here are my Guild Dues"
  37.     local p = self.MyGold
  40.     if p < 5000 then
  41.      d("Weekly dues are 5k, you do not have enough." )
  42.     end
  44.     if p < 10000 then
  45.     d("We insist you keep more than half of what you owe." )
  46.     end  
  48.     else
  49.         p = p - p + 5000
  50.         SCENE_MANAGER:Show('mailSend')
  51.         zo_callLater(function()
  52.             ZO_MailSendToField:SetText(r)
  53.             ZO_MailSendSubjectField:SetText(s)
  54.             QueueMoneyAttachment(p)
  55.             ZO_MailSendBodyField:TakeFocus() end, 200)
  56.     end
  57. end
  59. SLASH_COMMANDS["/pay"] = PayDues
  60. ZO_CreateStringId("SI_BINDING_NAME_PAY_DUES", "Pay Dues")
  61. EVENT_MANAGER:RegisterForEvent(GuildDues.name, EVENT_ADD_ON_LOADED, GuildDues.OnAddOnLoaded)
  Reply With Quote
08/20/18, 04:58 AM   #2
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 2,536
You call self:RestorePosition() but where is teh function GuildDues:RestorePosition() in your code?

The function createDonationButton is never executed so this button will not be created at all.
You'd need to put this function code at the top of your file as you have defined it locally and code in lua which is local neds to be on top of the call to that function.

Then you'd be able to put the call to "createDonationButton()" inside your function GuildDues:Initialize() e.g.

I'd avice you to read the wiki for "Getting started with addond evelopment" and not copy just code from other addons to your addon. You need to learn and undertand what you do and appearantly you are not understanding it so far.

Please go and visit the wiki, read the "Getting started part" and then "build the example addon":

Learn it, and then come back to your project to rebuild it (at best without the object stuff like GuildDues:Initialize() but normally like function GuildDues.Initialize().
The object stuff (check online fpr object oriented development) is only needed if you plan to build several objects of your class GuildDues. And I don't think you need this here.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Guild Dues

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off