Download
(1 Kb)
Download
Updated: 11/03/14 06:01 PM
Pictures
File Info
Compatibility:
Live (1.0)
Updated:11/03/14 06:01 PM
Created:04/25/14 07:59 PM
Monthly downloads:20
Total downloads:2,159
Favorites:3
MD5:
LootDice
Version: 3.5
by: zireko [More]
(UPDATE) 3.5: This update is just to the APIVersion so that it doesn't say the addon is out of date.

(UPDATE 3.0) In this update I've cleaned up some of the code and made the code more local functions so not to conflict with other addons. If you have suggetions or problems with the code please let me know. If you can provide info on fixing/cleaning the code please leave the info in comments.

(UPDATE) I have been out of the game a while and have just returned. I do not know if I will be updating this addon or if I will be continuing with a new one. So please feel free to use my code I worked on with this addon. I hope this can help anyone new to addons.

(UPDATE) I went a head and updated this so that it should now load instead of having to be loaded in out of date. Still for any new addon authors feel free to use my code and learn from it. This is a very small code and great to start with. Also feel free to us the code as a base for any type of addon you want to make with it.

This is my very first addon. LootDice allows you to get a totally random roll and can be used by guild members or anyone that leads a group to get a random roll for loot or anything that you might want to roll for. Also this is a stand alone addon so it doesn't require you to be in a group or have any other addon for it to run.

2.0 is now out with the new fix so that it will now save to the location of where you last put it. I had a lot of help from Pure_Decimation do to there hard work teaching me we finally have the code working.

Credit: Pure_Decimation - stuck with me teaching me every detail and writing much of the code to help me understand how things work.

Please go easy on me this is my first time programming anything other than old school html websites.

If there is any problem with the addon please let me know in comments.
Optional Files (0)


Archived Files (4)
File Name
Version
Size
Uploader
Date
3.0
1kB
zireko
10/28/14 06:07 AM
2.5
1kB
zireko
10/26/14 06:23 AM
2.0
1kB
zireko
04/28/14 09:38 AM
1.0
1kB
04/25/14 07:59 PM


Post A Reply Comment Options
Unread 04/26/14, 03:24 PM  
zireko
 
zireko's Avatar
AddOn Author - Click to view AddOns

Forum posts: 63
File comments: 30
Uploads: 4
I know I must be putting the code in the wrong order or something. Not sure exactly where I'm messing up but I feel it's close.

Lua Code:
  1. RollVars = {}
  2.  
  3. RollVars.Defaults = {
  4.     ["hideRoll"] = false,
  5.     ["Roll"] = {
  6.         ["offsetx"] = 0,
  7.         ["offsety"] = 0,
  8.         ["point"] = TOPLEFT,
  9.         ["relPoint"] = TOPLEFT,
  10.         },
  11. }
  12.  
  13. function MyAddonRollDice()
  14.     local num = math.random(1,100)
  15.     return num
  16. end
  17.  
  18. Roll:SetHandler("OnMoveStop", OnMoveStopRoll)
  19.  
  20. Roll:SetAnchor(RollVars.SV.roll.point, nil, Roll.SV.roll.relPoint, Roll.SV.roll.offsetx, RollVars.SV.roll.offsety)
  21.  
  22. function OnMoveStopRoll()
  23.     _, RollVars.SV.Dice.point, _, RollVars.SV.roll.relPoint, RollVars.SV.roll.offsetx, RollVars.SV.roll.offsety = Roll:GetAnchor(0)
  24. end
  25.  
  26.  
  27. local function OnAddOnLoaded(eventCode, addon)
  28.     if addon == "LootDice" then
  29.         LootDice_SavedVariables = { "LootDice V 1.0", isAddOnEnabled = true}
  30.         d("LootDice_SavedVariables.isAddOnEnabled = "..tostring(LootDice_SavedVariables.isAddOnEnabled))
  31.     end
  32. end
  33.  
  34. RollVars.SV = ZO_SavedVars:New( "Roll_Variables" , 2 , nil , RollVars.Defaults , nil )
  35.  
  36. EVENT_MANAGER:RegisterForEvent("LootDice", EVENT_ADD_ON_LOADED, OnAddOnLoaded)
Report comment to moderator  
Reply With Quote
Unread 04/26/14, 02:54 PM  
zireko
 
zireko's Avatar
AddOn Author - Click to view AddOns

Forum posts: 63
File comments: 30
Uploads: 4
So create something similar to that and then you need to call the saved vars file creation like this:

Code:
PureVars.SV = ZO_SavedVars:New( "Pure_Variables" , 2 , nil , PureVars.Defaults , nil )
The the arguments in the ZO_SavedVars:New function are as follows: ("Name of saved vars file", "version" (increment this if you need the current file to be replaced), "namespace" (you probably won't use this, so just set nil), "defaults" (This is what we created above), and leave the last as nil as well.[/quote]

The first part I think I got down. The part where I have to enter it into the savedVars I don't seem to understand very good.

This is my SavedVar currently but I don't understand it very good at all. So I'm trying to figure out exactly where to place the code and do like you said.

Lua Code:
  1. local function OnAddOnLoaded(eventCode, addon)
  2.     if addon == "LootDice" then
  3.         LootDice_SavedVariables = { "LootDice V 1.0", isAddOnEnabled = true}
  4.         d("LootDice_SavedVariables.isAddOnEnabled = "..tostring(LootDice_SavedVariables.isAddOnEnabled))
  5.     end
  6. end
  7.  
  8. EVENT_MANAGER:RegisterForEvent("LootDice", EVENT_ADD_ON_LOADED, OnAddOnLoaded)
Report comment to moderator  
Reply With Quote
Unread 04/26/14, 02:20 PM  
Pure_Decimation
AddOn Author - Click to view AddOns

Forum posts: 4
File comments: 9
Uploads: 1
Originally Posted by zireko
I tried that in my code which now looks like the lua below. It doesn't seem to work. I pulled out the anchor tags and it goes to the top left and can't move it.

LUA

Lua Code:
  1. function MyAddonRollDice()
  2.     local num = math.random(1,100)
  3.     return num
  4. end
  5.  
  6. Roll:SetHandler("OnMoveStop", OnMoveStopRoll)
  7.  
  8. Roll:SetAnchor(RollVars.SV.roll.point, nil, Roll.SV.roll.relPoint, Roll.SV.roll.offsetx, RollVars.SV.roll.offsety)
  9.  
  10. function OnMoveStopRoll()
  11.     _, RollVars.SV.Dice.point, _, RollVars.SV.roll.relPoint, RollVars.SV.roll.offsetx, RollVars.SV.roll.offsety = Roll:GetAnchor(0)
  12. end
  13.  
  14. local function OnAddOnLoaded(eventCode, addon)
  15.     if addon == "LootDice" then
  16.         LootDice_SavedVariables = { "LootDice V 1.0", isAddOnEnabled = true}
  17.         d("LootDice_SavedVariables.isAddOnEnabled = "..tostring(LootDice_SavedVariables.isAddOnEnabled))
  18.     end
  19. end
  20.  
  21. EVENT_MANAGER:RegisterForEvent("LootDice", EVENT_ADD_ON_LOADED, OnAddOnLoaded)
You need to set up a default profile for you saved variables. Mine looks like this:

Code:
PureVars = {}
PureVars.Defaults = {
	["hideGold"] = false,
	["hideClock"] = false,
	["text"] = "",
	["gold"] = {
		["offsetx"] = 0,
		["offsety"] = 0,
		["point"] = TOPLEFT,
		["relPoint"] = TOPLEFT,
		},
	["clock"] = {
		["offsetx"] = 0,
		["offsety"] = 0,
		["point"] = TOPLEFT,
		["relPoint"] = TOPLEFT,
		}
}
So create something similar to that and then you need to call the saved vars file creation like this:

Code:
PureVars.SV = ZO_SavedVars:New( "Pure_Variables" , 2 , nil , PureVars.Defaults , nil )
The the arguments in the ZO_SavedVars:New function are as follows: ("Name of saved vars file", "version" (increment this if you need the current file to be replaced), "namespace" (you probably won't use this, so just set nil), "defaults" (This is what we created above), and leave the last as nil as well.
Report comment to moderator  
Reply With Quote
Unread 04/26/14, 09:06 AM  
zireko
 
zireko's Avatar
AddOn Author - Click to view AddOns

Forum posts: 63
File comments: 30
Uploads: 4
I tried that in my code which now looks like the lua below. It doesn't seem to work. I pulled out the anchor tags and it goes to the top left and can't move it.

LUA

Lua Code:
  1. function MyAddonRollDice()
  2.     local num = math.random(1,100)
  3.     return num
  4. end
  5.  
  6. Roll:SetHandler("OnMoveStop", OnMoveStopRoll)
  7.  
  8. Roll:SetAnchor(RollVars.SV.roll.point, nil, Roll.SV.roll.relPoint, Roll.SV.roll.offsetx, RollVars.SV.roll.offsety)
  9.  
  10. function OnMoveStopRoll()
  11.     _, RollVars.SV.Dice.point, _, RollVars.SV.roll.relPoint, RollVars.SV.roll.offsetx, RollVars.SV.roll.offsety = Roll:GetAnchor(0)
  12. end
  13.  
  14. local function OnAddOnLoaded(eventCode, addon)
  15.     if addon == "LootDice" then
  16.         LootDice_SavedVariables = { "LootDice V 1.0", isAddOnEnabled = true}
  17.         d("LootDice_SavedVariables.isAddOnEnabled = "..tostring(LootDice_SavedVariables.isAddOnEnabled))
  18.     end
  19. end
  20.  
  21. EVENT_MANAGER:RegisterForEvent("LootDice", EVENT_ADD_ON_LOADED, OnAddOnLoaded)
Report comment to moderator  
Reply With Quote
Unread 04/25/14, 10:49 PM  
Pure_Decimation
AddOn Author - Click to view AddOns

Forum posts: 4
File comments: 9
Uploads: 1
Look here for help with the anchor not saving. I just had the same problem and this should be able to help you.

http://www.esoui.com/forums/showthread.php?t=1152
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: