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:11
Total downloads:2,118
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/29/14, 06:37 PM  
zireko
 
zireko's Avatar
AddOn Author - Click to view AddOns

Forum posts: 63
File comments: 30
Uploads: 4
Originally Posted by Pure_Decimation
Originally Posted by zireko
Originally Posted by iolitefire
Hiya!

Thank you for putting out a mod like this! I just had a few questions. I have it installed and it looks great.

Is there a way for other people to see my rolls? If so, how can they? Do they need to install the addon?

Thanks in advance!
Well I was thinking about what you said and was planning on it. But I looked into some of the coding and the SendChatMessage in the code is set to private. This means I can't send a message to a group. If anyone else knows a way we can do this let me know. If you have any more questions hit me back in the comments. Sorry I couldn't help more.
There is a method of inputting text into chat that requires the user only to press the enter key to send the message. But a chat message would be too easy for an untrustworthy or greedy member of a group to spoof. I think the only real way to implement his idea would be some kind of network communication that is past the limitations of what can be done from a simple addon.
I know I won't be able to do it for a while but I remember ummm a wow addon that is called carbonite and it some how networks to anyone that has the addon and shares some info. But I know that is way out of my reach currently.
Report comment to moderator  
Reply With Quote
Unread 04/29/14, 06:26 PM  
Pure_Decimation
AddOn Author - Click to view AddOns

Forum posts: 4
File comments: 9
Uploads: 1
Originally Posted by zireko
Originally Posted by iolitefire
Hiya!

Thank you for putting out a mod like this! I just had a few questions. I have it installed and it looks great.

Is there a way for other people to see my rolls? If so, how can they? Do they need to install the addon?

Thanks in advance!
Well I was thinking about what you said and was planning on it. But I looked into some of the coding and the SendChatMessage in the code is set to private. This means I can't send a message to a group. If anyone else knows a way we can do this let me know. If you have any more questions hit me back in the comments. Sorry I couldn't help more.
There is a method of inputting text into chat that requires the user only to press the enter key to send the message. But a chat message would be too easy for an untrustworthy or greedy member of a group to spoof. I think the only real way to implement his idea would be some kind of network communication that is past the limitations of what can be done from a simple addon.
Report comment to moderator  
Reply With Quote
Unread 04/29/14, 07:37 AM  
zireko
 
zireko's Avatar
AddOn Author - Click to view AddOns

Forum posts: 63
File comments: 30
Uploads: 4
Originally Posted by iolitefire
Hiya!

Thank you for putting out a mod like this! I just had a few questions. I have it installed and it looks great.

Is there a way for other people to see my rolls? If so, how can they? Do they need to install the addon?

Thanks in advance!
Well I was thinking about what you said and was planning on it. But I looked into some of the coding and the SendChatMessage in the code is set to private. This means I can't send a message to a group. If anyone else knows a way we can do this let me know. If you have any more questions hit me back in the comments. Sorry I couldn't help more.
Report comment to moderator  
Reply With Quote
Unread 04/29/14, 05:40 AM  
zireko
 
zireko's Avatar
AddOn Author - Click to view AddOns

Forum posts: 63
File comments: 30
Uploads: 4
It's more of a personal dice roll. I haven't made it where others can see it. However if you're in a group of good friends you know or with guild members they should trust your answer giving you don't lie about it. This is why I was saying it's best for the lootdice to be with the lead of the group or raid. I may add a feature in the future that can share with the group. I love to use the LootDice for when I have to make a choice in the story line because sometimes I have a hard time making a decision.
Report comment to moderator  
Reply With Quote
Unread 04/28/14, 04:06 PM  
iolitefire

Forum posts: 0
File comments: 3
Uploads: 0
Hiya!

Thank you for putting out a mod like this! I just had a few questions. I have it installed and it looks great.

Is there a way for other people to see my rolls? If so, how can they? Do they need to install the addon?

Thanks in advance!
Report comment to moderator  
Reply With Quote
Unread 04/28/14, 09:47 AM  
zireko
 
zireko's Avatar
AddOn Author - Click to view AddOns

Forum posts: 63
File comments: 30
Uploads: 4
Thank you so much Pure. It is now working like you said and I'm reading over the code constantly to better understand how this works. You've taught me a lot and I have given you the credit for helping me with the update so much. Thank you again.
Report comment to moderator  
Reply With Quote
Unread 04/27/14, 09:03 PM  
Pure_Decimation
AddOn Author - Click to view AddOns

Forum posts: 4
File comments: 9
Uploads: 1
Originally Posted by zireko
Ok, sorry about that. I went in and fixed the code a little but for some reason I'm still getting the same error. I may still be miss understanding something somewhere. Here is the code that I fixed so far and I'm getting the error with.

LUA

Lua Code:
  1. RollVars = {}
  2. RollVars = {}
  3.  
  4. RollVars.Defaults = {
  5.     ["hideRoll"] = false,
  6.     ["Roll"] = {
  7.         ["offsetx"] = 0,
  8.         ["offsety"] = 0,
  9.         ["point"] = TOPLEFT,
  10.         ["relPoint"] = TOPLEFT,
  11.         },
  12. }
  13.  
  14. function MyAddonRollDice()
  15.     local num = math.random(1,100)
  16.     return num
  17. end
  18.  
  19.  
  20.  
  21. function OnMoveStopRoll()
  22.     _, RollVars.SV.Roll.point, _, RollVars.SV.Roll.relPoint, RollVars.SV.Roll.offsetx, RollVars.SV.Roll.offsety = LootDiceRoll:GetAnchor(0)
  23. end
  24.  
  25.  
  26. local function OnAddOnLoaded(eventCode, addon)
  27.     if addon == "LootDice" then
  28.         RollVars.SV = ZO_SavedVars:New( "Roll_Variables" , 2 , nil , RollVars.Defaults , nil )
  29.         if RollVars.SV ~= nil then
  30.                LoadSavedVars()
  31.         end
  32.         Roll:SetHandler("OnMoveStop", OnMoveStopRoll)
  33.     end
  34. end
  35.  
  36. function LoadSavedVars()
  37.     LootDiceRoll:SetAnchor(RollVars.SV.Roll.point, nil, Roll.SV.Roll.relPoint, Roll.SV.Roll.offsetx, RollVars.SV.Roll.offsety)
  38. end
  39.  
  40. EVENT_MANAGER:RegisterForEvent("LootDice", EVENT_ADD_ON_LOADED, OnAddOnLoaded)
Alright. I found the issues. First off, change the name of your saved vars file in your .txt file to match the new name you placed within the lua file. Secondly, after reviewing my own code, remove the Roll for the LootDiceRoll calls as it is not what we are setting and getting the anchor for. Thirdly, you missnamed a couple of the variables in your SetAnchor call in the LoadSavedVars function. You called the table "Roll" when in it is called "RollVars" in all the other calls of the table. And finally, I removed the OnMouseDown handler from within the xml file and placed this instead in your OnAddOnLoaded function "LootDice:SetHandler("OnMouseDown", MyAddonRollDice)" There may be a few other things I missed, so here is the final code, after all of my edits. Please review it and make sure you understand it as these are core concepts that will be the basis for all mods that you may be doing in the future. Here you go.

Lua

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.     LootDiceRoll:SetText(num)
  16. end
  17.  
  18.  
  19.  
  20. function OnMoveStopRoll()
  21.     _, RollVars.SV.Roll.point, _, RollVars.SV.Roll.relPoint, RollVars.SV.Roll.offsetx, RollVars.SV.Roll.offsety = LootDice:GetAnchor(0)
  22. end
  23.  
  24.  
  25. function OnAddOnLoaded(eventCode, addon)
  26.     if addon == "LootDice" then
  27.         RollVars.SV = ZO_SavedVars:New( "Roll_Variables" , 2 , nil , RollVars.Defaults , nil )
  28.         if (RollVars.SV ~= nil) then
  29.                LoadSavedVars()
  30.         end
  31.         LootDice:SetHandler("OnMoveStop", OnMoveStopRoll)
  32.         LootDice:SetHandler("OnMouseDown", MyAddonRollDice)
  33.     end
  34. end
  35.  
  36. function LoadSavedVars()
  37.     LootDice:SetAnchor(RollVars.SV.Roll.point, nil, RollVars.SV.Roll.relPoint, RollVars.SV.Roll.offsetx, RollVars.SV.Roll.offsety)
  38. end
  39.  
  40. EVENT_MANAGER:RegisterForEvent("LootDice", EVENT_ADD_ON_LOADED, OnAddOnLoaded)

XML

Code:
<GuiXml>
    <Controls>
        <TopLevelControl name="LootDice" mouseEnabled="true" movable="true" hidden="false">
            <Dimensions x="150" y="42" />			
				<Controls>
                <Backdrop name="$(parent)BG" inherits="ZO_ThinBackdrop" />
                <Label name="$(parent)Roll" font="ZoFontWindowTitle" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" horizontalAlignment="CENTER" text="LootDice" >
			
                    <AnchorFill />
				
                </Label>
            </Controls>
        </TopLevelControl>
    </Controls>
</GuiXml>
Txt

Code:
## Title: LootDice - By Zireko
## APIVersion: 100003
## Description: A simple Loot Dice for group runs.
## Version: 1.0
## SavedVariables: Roll_Variables

LootDice.lua 
LootDice.xml
That code is tested and I can guarantee it works. Hope this got everything figured out for you so you can push out a new updated version of the code.
Last edited by Pure_Decimation : 04/27/14 at 09:04 PM.
Report comment to moderator  
Reply With Quote
Unread 04/27/14, 08:24 PM  
zireko
 
zireko's Avatar
AddOn Author - Click to view AddOns

Forum posts: 63
File comments: 30
Uploads: 4
Ok, sorry about that. I went in and fixed the code a little but for some reason I'm still getting the same error. I may still be miss understanding something somewhere. Here is the code that I fixed so far and I'm getting the error with.

LUA

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

Forum posts: 4
File comments: 9
Uploads: 1
[quote=zireko]
Originally Posted by Pure_Decimation
Originally Posted by zireko
(Firstly, go through your variable calls for variables within your table. Cause I see that some of them are not worded properly. Also when you call your "Roll" object, you need to place the parents (your top level control) name in front of it since that is how you call it in the XML file. Let me know if you need a more in depth explanation of these two things.)

When you say there not worded properly do you mean like some that are Roll and some that are roll with the lowercase letter? And can you give me an example of how to place the Roll object in the parents (your top level control) name in front of it?

Ok I have the words fixed now what about the part where you said the parents (your top level control) can you show me an example of that so that I better know where to put it.
I did. Look at the GetAnchor call at the end of that last line of code I fixed. Where I changed the Roll to LootDiceRoll is what I was talking about. Since you call your control in the xml "$(parent)Roll" and your top level control's name is "LootDice", you must combine them together when calling that particular object. Hope this helps.
Report comment to moderator  
Reply With Quote
Unread 04/27/14, 06:38 PM  
zireko
 
zireko's Avatar
AddOn Author - Click to view AddOns

Forum posts: 63
File comments: 30
Uploads: 4
[quote=Pure_Decimation]
Originally Posted by zireko
(Firstly, go through your variable calls for variables within your table. Cause I see that some of them are not worded properly. Also when you call your "Roll" object, you need to place the parents (your top level control) name in front of it since that is how you call it in the XML file. Let me know if you need a more in depth explanation of these two things.)

When you say there not worded properly do you mean like some that are Roll and some that are roll with the lowercase letter? And can you give me an example of how to place the Roll object in the parents (your top level control) name in front of it?

Ok I have the words fixed now what about the part where you said the parents (your top level control) can you show me an example of that so that I better know where to put it.
Report comment to moderator  
Reply With Quote
Unread 04/27/14, 05:27 PM  
Pure_Decimation
AddOn Author - Click to view AddOns

Forum posts: 4
File comments: 9
Uploads: 1
Originally Posted by zireko
(Firstly, go through your variable calls for variables within your table. Cause I see that some of them are not worded properly. Also when you call your "Roll" object, you need to place the parents (your top level control) name in front of it since that is how you call it in the XML file. Let me know if you need a more in depth explanation of these two things.)

When you say there not worded properly do you mean like some that are Roll and some that are roll with the lowercase letter? And can you give me an example of how to place the Roll object in the parents (your top level control) name in front of it?
Here, I'll use this line as an example

Code:
_, RollVars.SV.Dice.point, _, RollVars.SV.roll.relPoint, RollVars.SV.roll.offsetx, RollVars.SV.roll.offsety = Roll:GetAnchor(0)
It should be:

Code:
_, RollVars.SV.Roll.point, _, RollVars.SV.Roll.relPoint, RollVars.SV.Roll.offsetx, RollVars.SV.Roll.offsety = LootDiceRoll:GetAnchor(0)
Report comment to moderator  
Reply With Quote
Unread 04/27/14, 01:15 PM  
zireko
 
zireko's Avatar
AddOn Author - Click to view AddOns

Forum posts: 63
File comments: 30
Uploads: 4
(Firstly, go through your variable calls for variables within your table. Cause I see that some of them are not worded properly. Also when you call your "Roll" object, you need to place the parents (your top level control) name in front of it since that is how you call it in the XML file. Let me know if you need a more in depth explanation of these two things.)

When you say there not worded properly do you mean like some that are Roll and some that are roll with the lowercase letter? And can you give me an example of how to place the Roll object in the parents (your top level control) name in front of it?
Report comment to moderator  
Reply With Quote
Unread 04/27/14, 12:58 PM  
Pure_Decimation
AddOn Author - Click to view AddOns

Forum posts: 4
File comments: 9
Uploads: 1
Originally Posted by zireko
I moved everything around and now I'm getting and error. I think it might be something to do with trying to pull up the savedVar. I'm gonna link all my code lua, xml, and txt and show the picture of the error. Maybe you can see what I'm messing up on. O and Pure thank for all this help.

LUA

Lua Code:
  1. RollVars = {}
  2. RollVars = {}
  3.  
  4. RollVars.Defaults = {
  5.     ["hideRoll"] = false,
  6.     ["Roll"] = {
  7.         ["offsetx"] = 0,
  8.         ["offsety"] = 0,
  9.         ["point"] = TOPLEFT,
  10.         ["relPoint"] = TOPLEFT,
  11.         },
  12. }
  13.  
  14. function MyAddonRollDice()
  15.     local num = math.random(1,100)
  16.     return num
  17. end
  18.  
  19.  
  20.  
  21. function OnMoveStopRoll()
  22.     _, RollVars.SV.Dice.point, _, RollVars.SV.roll.relPoint, RollVars.SV.roll.offsetx, RollVars.SV.roll.offsety = Roll:GetAnchor(0)
  23. end
  24.  
  25.  
  26. local function OnAddOnLoaded(eventCode, addon)
  27.     if addon == "LootDice" then
  28.         RollVars.SV = ZO_SavedVars:New( "Roll_Variables" , 2 , nil , RollVars.Defaults , nil )
  29.         if RollVars.SV ~= nil then
  30.                LoadSavedVars()
  31.         end
  32.         Roll:SetHandler("OnMoveStop", OnMoveStopRoll)
  33.     end
  34. end
  35.  
  36. function LoadSavedVars()
  37.     Roll:SetAnchor(RollVars.SV.roll.point, nil, Roll.SV.roll.relPoint, Roll.SV.roll.offsetx, RollVars.SV.roll.offsety)
  38. end
  39.  
  40. EVENT_MANAGER:RegisterForEvent("LootDice", EVENT_ADD_ON_LOADED, OnAddOnLoaded)

XML

Lua Code:
  1. <GuiXml>
  2.     <Controls>
  3.         <TopLevelControl name="LootDice" mouseEnabled="true" movable="true">
  4.             <Dimensions x="150" y="42" />
  5.                                    
  6.             <OnMouseDown>
  7.                 Roll = MyAddonRollDice()
  8.                 LootDiceRoll:SetText(Roll)
  9.             </OnMouseDown>
  10.                        
  11.             <Controls>
  12.                 <Backdrop name="$(parent)BG" inherits="ZO_ThinBackdrop" />
  13.                 <Label name="$(parent)Roll" font="ZoFontWindowTitle" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" horizontalAlignment="CENTER" text="LootDice" >
  14.                     <AnchorFill />                     
  15.                 </Label>
  16.             </Controls>
  17.         </TopLevelControl>
  18.     </Controls>
  19. </GuiXml>

TXT

Lua Code:
  1. ## Title: LootDice - By Zireko
  2. ## APIVersion: 100003
  3. ## Description: A simple Loot Dice for group runs.
  4. ## Version: 1.0
  5. ## SavedVariables: LootDice_SavedVariables
  6.  
  7. LootDice.lua
  8. LootDice.xml

Firstly, go through your variable calls for variables within your table. Cause I see that some of them are not worded properly. Also when you call your "Roll" object, you need to place the parents (your top level control) name in front of it since that is how you call it in the XML file. Let me know if you need a more in depth explanation of these two things.
Report comment to moderator  
Reply With Quote
Unread 04/27/14, 12:44 PM  
zireko
 
zireko's Avatar
AddOn Author - Click to view AddOns

Forum posts: 63
File comments: 30
Uploads: 4
I moved everything around and now I'm getting and error. I think it might be something to do with trying to pull up the savedVar. I'm gonna link all my code lua, xml, and txt and show the picture of the error. Maybe you can see what I'm messing up on. O and Pure thank for all this help.

LUA

Lua Code:
  1. RollVars = {}
  2. RollVars = {}
  3.  
  4. RollVars.Defaults = {
  5.     ["hideRoll"] = false,
  6.     ["Roll"] = {
  7.         ["offsetx"] = 0,
  8.         ["offsety"] = 0,
  9.         ["point"] = TOPLEFT,
  10.         ["relPoint"] = TOPLEFT,
  11.         },
  12. }
  13.  
  14. function MyAddonRollDice()
  15.     local num = math.random(1,100)
  16.     return num
  17. end
  18.  
  19.  
  20.  
  21. function OnMoveStopRoll()
  22.     _, RollVars.SV.Dice.point, _, RollVars.SV.roll.relPoint, RollVars.SV.roll.offsetx, RollVars.SV.roll.offsety = Roll:GetAnchor(0)
  23. end
  24.  
  25.  
  26. local function OnAddOnLoaded(eventCode, addon)
  27.     if addon == "LootDice" then
  28.         RollVars.SV = ZO_SavedVars:New( "Roll_Variables" , 2 , nil , RollVars.Defaults , nil )
  29.         if RollVars.SV ~= nil then
  30.                LoadSavedVars()
  31.         end
  32.         Roll:SetHandler("OnMoveStop", OnMoveStopRoll)
  33.     end
  34. end
  35.  
  36. function LoadSavedVars()
  37.     Roll:SetAnchor(RollVars.SV.roll.point, nil, Roll.SV.roll.relPoint, Roll.SV.roll.offsetx, RollVars.SV.roll.offsety)
  38. end
  39.  
  40. EVENT_MANAGER:RegisterForEvent("LootDice", EVENT_ADD_ON_LOADED, OnAddOnLoaded)

XML

Lua Code:
  1. <GuiXml>
  2.     <Controls>
  3.         <TopLevelControl name="LootDice" mouseEnabled="true" movable="true">
  4.             <Dimensions x="150" y="42" />
  5.                                    
  6.             <OnMouseDown>
  7.                 Roll = MyAddonRollDice()
  8.                 LootDiceRoll:SetText(Roll)
  9.             </OnMouseDown>
  10.                        
  11.             <Controls>
  12.                 <Backdrop name="$(parent)BG" inherits="ZO_ThinBackdrop" />
  13.                 <Label name="$(parent)Roll" font="ZoFontWindowTitle" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" horizontalAlignment="CENTER" text="LootDice" >
  14.                     <AnchorFill />                     
  15.                 </Label>
  16.             </Controls>
  17.         </TopLevelControl>
  18.     </Controls>
  19. </GuiXml>

TXT

Lua Code:
  1. ## Title: LootDice - By Zireko
  2. ## APIVersion: 100003
  3. ## Description: A simple Loot Dice for group runs.
  4. ## Version: 1.0
  5. ## SavedVariables: LootDice_SavedVariables
  6.  
  7. LootDice.lua
  8. LootDice.xml

Report comment to moderator  
Reply With Quote
Unread 04/27/14, 12:16 AM  
Pure_Decimation
AddOn Author - Click to view AddOns

Forum posts: 4
File comments: 9
Uploads: 1
Originally Posted by zireko
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)
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.  
  19.  
  20. function OnMoveStopRoll()
  21.     _, RollVars.SV.Dice.point, _, RollVars.SV.roll.relPoint, RollVars.SV.roll.offsetx, RollVars.SV.roll.offsety = Roll:GetAnchor(0)
  22. end
  23.  
  24.  
  25. local function OnAddOnLoaded(eventCode, addon)
  26.     if addon == "LootDice" then
  27.         RollVars.SV = ZO_SavedVars:New( "Roll_Variables" , 2 , nil , RollVars.Defaults , nil )
  28.         if RollVars.SV ~= nil then
  29.                LoadSavedVars()
  30.         end
  31.         Roll:SetHandler("OnMoveStop", OnMoveStopRoll)
  32.     end
  33. end
  34.  
  35. function LoadSavedVars()
  36.     Roll:SetAnchor(RollVars.SV.roll.point, nil, Roll.SV.roll.relPoint, Roll.SV.roll.offsetx, RollVars.SV.roll.offsety)
  37. end
  38.  
  39. EVENT_MANAGER:RegisterForEvent("LootDice", EVENT_ADD_ON_LOADED, OnAddOnLoaded)

You were close. That should work now. Just moved the stuff around so the functions were actually getting called.
Last edited by Pure_Decimation : 04/27/14 at 12:17 AM.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: