Save location via SavedVariables
Code
Lua Code:
A separate code is just a button Lua Code:
At the moment, the button returns to the center when using the command /reload Did I redo it correctly? Lua Code:
|
Blizz. will save the frame but if the user removes the addon for any reason, it will reset to the default location if they decide to install the addon again.
Lua Code:
|
Quote:
|
I missed the CreateFrame code for btn in the original post
For Blizz to save the position, the frame has to have a unique name. Lua Code:
|
Quote:
Lua Code:
|
I have no idea what code you're testing so, as a standalone example of a button that can be dragged and saved.
Lua Code:
You will have to move the pieces into your addon. Possibly just the btn:SetUserPlaced(true) and giving the button a name. |
Quote:
Lua Code:
|
Some of that code is completely broken so I assumed you were posting example code and would make changes to the real code. You should be getting errors from BugGrabber/Bugsack . Install them if you haven't yet.
Code:
btn:SetScript("OnClick:, function(self, button, ...) Whereas Code:
btn:SetScript('OnDragStop', btn.StopMovingOrSizing) Here is the code with a print to fill in the OnClick, a fix that may or may not be what you intend for the OnDragStop script and I commented out the updateData() because addon.db isn't created in the code shown. Add it back if it is in another .lua file but the code as is should at least work for demonstrating the SetUserPlaced() saving the button position. Lua Code:
|
Quote:
Lua Code:
This code almost works. It saves the position of the button But the button does not display the table if I press the left mouse button. But if I press the left mouse button and shift and try to move the button, the table window turns on. What could be the problem? |
Programs are stupid. You have to tell them exactly what you want. Maybe something like: (Left buton down, shift-key down = drag. right button = hide button. left button no shift-key toggle show/hide the frame (f))
Lua Code:
You possibly want a way to get the button back after it's hidden other than a /reaload but may not, it's not clear? |
Yes, it worked. The code works completely as intended. Thank you very much. I couldn't have done it without you.
Quote:
If I solve the problem - how do I insert a link to an item in the text that is in the table, I will be able to make my first addon. https://www.wowinterface.com/forums/...ad.php?t=59796 |
I've created this as an all-in-one example including an example addon.db where I've replaced the item name, icon and added the link for some random items (got rid of the icon texture in the frame as it's in the text, but but it's up to you how you organise the stuff).
Added two %s to each enUS string which gets replaced by the icon (size set to 20x20) and hyperlink when the text is set. Again, Example Code so, how you get/display the information for your addon will depend on the what/when of the addons workings. Added a check in the slash command so if you type /hubb btn it will toggle the button Lua Code:
|
Quote:
table.lua Lua Code:
db.lua Lua Code:
|
Quote:
You removed the option to show/hide the button from the slash command (or at least didn't copy the SlashCmdList["HUBB"] = function(msg) code from my example. Your latest code contains a function GetItemLinkById I have no idea what it is or where it's from but it's not Blizz and it's not defined in anything you've posted so colour me confused that it works at all. |
Quote:
Lua Code:
I was assured that it would work in GetItemLinkById. But it looks like we just didn't understand each other. Lua Code:
Your code works 100%. But it displays the items in the chat, rather than displaying a table. And it is the table that I need. An example where instead of {item:194701} there is a link to the item. |
Quote:
Quote:
Delete the lines Lua Code:
(You can delete the OnHyperlinkEnter function as well) Change the OnHyperlinkClick function to: Lua Code:
The other possabilty is you want the click to open the item tooltip rather than doing it OnEnter in which case, the the OnHyperlinkClick function would be: Lua Code:
|
Quote:
https://www.wowinterface.com/forums/...ad.php?t=59796 Here is a table (picture 1) I want to be able to add a link to an item in the description of the text, anywhere in the text. I did this in photo editor GIMP (it turned out a little crooked) |
You still don't say what you want to see when a link is clicked so, using the code you linked and guessing you just want to see the item tooltip when a link is clicked:
The item field added to each entry in addon.db is the (random because I don't know that acual) item ID that will be the link/tooltip (replacing the %s in each announce.enUS field). db.lua file Lua Code:
Lua Code file: Lua Code:
To show/hide the button: Code:
/hubb btn |
Quote:
I set the localization lines correctly, did I do everything right? Lua Code:
|
That looks OK.
The only thing is that you have a deDE for a only one entry in addon.db where Code:
tinsert(data, {item.announce[GetLocale()], item.icon, item.name}) Have Fun! |
Quote:
|
If french (frFR) didn't exists then
Code:
tinsert(data, {item.announce[GetLocale()], item.icon, item.name}) Code:
tinsert(data, {item.announce["frFR"], item.icon, item.name}) Code:
tinsert(data, {nil, item.icon, item.name}) You could use something like the following that will test if the users locale announce field is in addon.db and if not, default to using the enUS text. Lua Code:
This assumes there will be a enUS field in EVERY announce table. You could of course, if you prefer, default to .frFR or .deDE whichever locale oocures in every entry. |
Quote:
Lua Code:
|
Code:
/run print(format("%s %s %s", "Replace", "with", text")) |
Quote:
Lua Code:
I tried this but it didn't work |
This makes it a bit more complicated as you're getting mutiple items for each row so you have to have them all cached before you can do the format().
I have to head out so I'll look at it in the morning. |
Quote:
Lua Code:
And an additional question. - https://www.wowinterface.com/forums/...t=59795&page=2 In the last topic you helped me make a timer. I plan to make another addon in the future that also uses this timer. The problem is that if a player installs 2 of these addons, the timer will not work correctly. I thought it was enough to fix ZAMROTimer to ZAMRO1Timer, but it looks like something else needs to be done? |
Double check that you have no common non local functions or variables. These would overwrite each other and thus cause one to not work properly.
If you can't see anything like this in both addons then, perhaps you can describe what you are seeing happen ? And if you don't have bugsack or buggrabber installed to catch any errors it might be worth doing to help pinpoint where it's breaking. Looking at the last code block Fizzle posted in that thread, just changing the frame name should be enough to make it work. |
Quote:
|
Did you make sure that each display has it's own location ?
You will need to adjust the anchor if you want them both displayed at the same time. If you notice in Fizzle's example code: Lua Code:
If both addons have the same anchor point their information will overlay each other on the screen. If you notice there is a frame_x and frame_y value there. If you are using the same code for your addon you can have each addon have different frame_x/frame_y values so that the frame will not overlay each other. |
Quote:
Lua Code:
|
Assuming you have the same file in each of the addons. Simply changing the frame name on line 8 as well as setting f to be local not global ( that would mess things up there ) and the frame_x and frame_y values on lines 6 and 7 might be all you need to do. Assuming the rest of the code does what the addon was designed to do.
So.. Addon 1 Lua Code:
Addon 2 Lua Code:
Although I see you have the frame dragging code set up to re-arrange as needed. So, the above should work well enough to make both frames separate and accessible and not overidden by the other one. I think having the f - CreateFrame line not be local was the main issue. |
Probably best to make separate threads for each question as the code is getting pretty messy even for just one (hopefully Xrystal has answered your timer question).
Having multiple item links and locales in your addon.db texts complicates things because the order you want the links to display might be different in german to the order displayed in french and might be different again for english. This requires identifying the order each link needs to be in for every locale text. With that in mind, the structure of addon.db needs to change so this is one way you could do it (my german in non-existant so it didn't even try): NOTE: the number if items in each itemOrder should be the same as the number of %s tokens that are in the corresponding text field. (This is probably overkill as it's replacing all the locale texts and you probably only need the ones that will be actually be used but that depends on what the end addon requires so...) Lua Code:
|
Quote:
Lua Code:
|
At some point along the line the addon .db table go messed up and the name field in the first first entry became a table instead of a string.
The 2 files data (addon.db) Lua Code:
Code (everything else) Lua Code:
|
Yes it works. Thank you very much. And the last question (with your help I have already figured out a lot)
I replaced Lua Code:
Lua Code:
|
Because the original table wasn't set up with localised names, we were just dealing with the announce texts.
To add localise names you woud have to convert ALL the name entried to tables: Data Lua Code:
And change the tinsert line in the updateData() function to reflect the change Code Lua Code:
|
Quote:
|
Missing commas, mayube this time.
Lua Code:
Lua Code:
|
Quote:
Lua Code:
|
Then you're using different code. Line 78 in the code I posted (and you re-posted) is either and end or a blank line so, nothing to do with self:SetText()
I can't diagnose what I can't see. My best guess is you didn't use the updateData() function from my code in whatever your using. |
Quote:
1. If I want to make a similar addon, as I understand it, I will need to change (the code below) to which one? Lua Code:
2. how do I add a table title (in different languages) |
Both
Lua Code:
Lua Code:
Probably not a lot of point changing the addon title language unless you are going to post it in language specific sites under different names. If you are just hosting it on WowInterace/Curse/Wago people will find it using the single addon name which would be the same in any language so may as well be the title. To add a title, after: Lua Code:
add: Lua Code:
|
Quote:
|
Quote:
Lua Code:
You can then create FontStrings and set their texts using (set Rewards text): Lua Code:
xxx being the variable used when creating the FontString. You might want to see the wiki on localisation if it gets more complicated. |
Should I create a new lua file tablename.lua? With
Lua Code:
And add this file to table.lua Lua Code:
|
addon.Texts can go in the same file as addon.db as that seems to be where you're putting "data". Assuming that this file is listed in the .TOC file above the other (table.lua) file so it loads first.
Lua Code:
Goes after you've: Lua Code:
You can't fontstring:SetText(...) on a FontString that doesn't exist. |
Quote:
Lua Code:
|
Because you refuse to read and consider what has been written. In the last post, not even considered what was asked.
Most parts of an addon are created, positioned, formatted etc. in relation to something else depending on what you want your addon to do and how you want it to look and work. Not being a mind reader (and I can't read you screen), I'm not about to decide that for you, all I can do is offer suggestions on how you might do things. It's up to you work that information (if you think it might be useful) into your addon. With that in mind, not every code block is literal, someframe, somedrawlayer, somefont are for you to replace with whatever works for you and your addon. |
Quote:
I'll try to figure out the issue again. As I understand it, I can place this part of the code in the code file db.lua Lua Code:
Lua Code:
|
Correct,
Lua Code:
Replace someframe with the frame you want to be the parent of the new FontString The parent will effect the Fonstrings scale and when it's, shown/hidden etc. Replace somedrawlayer and somefont with the relevent information depending on where in the layer stack you want the string displayed and the font/size you want the text to be displayed in. See the docs for CreateFontString and see this page for some of the in-game fonts configurations ie. GameFontNormal, GameFontHighlight etc. etc. etc. You can't use someframe (whichever that frame is) to create the FontString until after the frame itself has been created (The order that code is placed (runs) matters). |
Quote:
https://www.wowinterface.com/downloa...o.php?id=26699 |
Congratulations:banana:
The more you play with it, the more you'll learn. Have Fun! |
All times are GMT -6. The time now is 09:36 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI