WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Save location via SavedVariables (https://www.wowinterface.com/forums/showthread.php?t=59800)

Fizzlemizz 02-25-24 01:40 AM

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.

Hubb777 02-25-24 01:55 AM

Quote:

Originally Posted by Fizzlemizz (Post 343443)
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.

Yes, indeed, I made changes to another file. It's my mistake, sorry. And a couple more questions (I understand that I just bombarded you with questions) these will be the last.

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:
  1. local f = CreateFrame("Frame", "SimpleScrollFrameTableDemo", UIParent, "BasicFrameTemplateWithInset")

2. how do I add a table title (in different languages)

Fizzlemizz 02-25-24 02:12 AM

Both

Lua Code:
  1. local f = CreateFrame("Frame", "Addon_1_Name_Frame", UIParent, "BasicFrameTemplateWithInset")

Lua Code:
  1. local f = CreateFrame("Frame", "Addon_2_Name_Frame", UIParent, "BasicFrameTemplateWithInset")

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:
  1. local f = CreateFrame("Frame", "SimpleScrollFrameTableDemo", UIParent, "BasicFrameTemplateWithInset")

add:
Lua Code:
  1. f.Title = f:CreateFontstring(nil, "ARTWORK", "GameFontNormal")
  2. f.Title:SetPoint("TOP", 0, -4)
  3. f.Title:SetText("Your Addon Name")

Hubb777 02-25-24 02:17 AM

Quote:

Originally Posted by Fizzlemizz (Post 343445)
Both

Lua Code:
  1. local f = CreateFrame("Frame", "Addon_1_Name_Frame", UIParent, "BasicFrameTemplateWithInset")

Lua Code:
  1. local f = CreateFrame("Frame", "Addon_2_Name_Frame", UIParent, "BasicFrameTemplateWithInset")

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:
  1. local f = CreateFrame("Frame", "SimpleScrollFrameTableDemo", UIParent, "BasicFrameTemplateWithInset")

add:
Lua Code:
  1. f.Title = f:CreateFontstring(nil, "ARTWORK", "GameFontNormal")
  2. f.Title:SetPoint("TOP", 0, -4)
  3. f.Title:SetText("Your Addon Name")

It looks like the problem with different languages has played a cruel joke again. Not the addon name, but my table name. For example, I will name the table “Possible rewards” or “List of pets”, I would like this inscription to also have a translation.

Fizzlemizz 02-25-24 02:41 AM

Quote:

Originally Posted by Hubb777 (Post 343446)
It looks like the problem with different languages has played a cruel joke again. Not the addon name, but my table name. For example, I will name the table “Possible rewards” or “List of pets”, I would like this inscription to also have a translation.

Create a table for your texts (1 sub-table for each with text you want on screen that contains the localised version of the title/whatever. eg.

Lua Code:
  1. addon.Texts = {
  2.     Rewards = {
  3.         enUS = "Possible Rewards",
  4.         deDE = "German for Possible Rewards",
  5.     },
  6.     Pets = {
  7.         enUS = "List of pets",
  8.         deDE = "German List of pets",
  9.     },
  10. }

You can then create FontStrings and set their texts using (set Rewards text):
Lua Code:
  1. xxx:SetText(addon.Texts.Rewards[GetLocal()] or addon.Texts.Rewards.enUS) -- enUS being the default is the GetLocale() entry doesn't exist.

xxx being the variable used when creating the FontString.

You might want to see the wiki on localisation if it gets more complicated.

Hubb777 02-25-24 02:59 AM

Should I create a new lua file tablename.lua? With
Lua Code:
  1. addon.Texts = {
  2.     Rewards = {
  3.         enUS = "Possible Rewards",
  4.         deDE = "German for Possible Rewards",
  5.     },
  6.     Pets = {
  7.         enUS = "List of pets",
  8.         deDE = "German List of pets",
  9.     },
  10. }

And add this file to table.lua
Lua Code:
  1. Pets:SetText(addon.Texts.Rewards[GetLocal()] or addon.Texts.Rewards.enUS) -- enUS being the default is the GetLocale() entry doesn't exist.

Fizzlemizz 02-25-24 08:32 AM

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:
  1. Pets:SetText(addon.Texts.Rewards[GetLocal()] or addon.Texts.Rewards.enUS) -- enUS being the default is the GetLocale() entry doesn't exist.

Goes after you've:
Lua Code:
  1. local Pets = someframe:CreateFontString(nil, somedrawlayer, somefont)

You can't fontstring:SetText(...) on a FontString that doesn't exist.

Hubb777 02-25-24 10:55 PM

Quote:

Originally Posted by Fizzlemizz (Post 343449)
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:
  1. Pets:SetText(addon.Texts.Rewards[GetLocal()] or addon.Texts.Rewards.enUS) -- enUS being the default is the GetLocale() entry doesn't exist.

Goes after you've:
Lua Code:
  1. local Pets = someframe:CreateFontString(nil, somedrawlayer, somefont)

You can't fontstring:SetText(...) on a FontString that doesn't exist.

This is the code I got
Lua Code:
  1. local Pets = someframe:CreateFontString(nil, somedrawlayer, somefont)
  2. Pets:SetText(addon.Texts.Rewards[GetLocal()] or addon.Texts.Rewards.enUS)
  3. addon.Texts = {
  4.     Rewards = {
  5.         enUS = "Possible Rewards",
  6.         deDE = "German for Possible Rewards",
  7.     },
  8.     Pets = {
  9.         enUS = "List of pets",
  10.         deDE = "German List of pets",
  11.     },
  12. }
Wherever I insert it, either the button disappears or it cannot be pressed. And if everything is pressed, there is no result.

Fizzlemizz 02-26-24 08:59 AM

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.

Hubb777 02-26-24 10:28 PM

Quote:

Originally Posted by Fizzlemizz (Post 343458)
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.

Hello. Sorry for the misunderstanding. It’s just that English is not my native language (I’m writing from the Czech Republic). For some of the text I have to use Google Translate (which makes it even more difficult to understand).

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:
  1. addon.Texts = {
  2.     Rewards = {
  3.         enUS = "Possible Rewards",
  4.         deDE = "German for Possible Rewards",
  5.     },
  6.     Pets = {
  7.         enUS = "List of pets",
  8.         deDE = "German List of pets",
  9.     },
  10. }
And this part in code table.lua
Lua Code:
  1. local Pets = someframe:CreateFontString(nil, somedrawlayer, somefont)
  2. Pets:SetText(addon.Texts.Rewards[GetLocal()] or addon.Texts.Rewards.enUS)

Fizzlemizz 02-27-24 09:33 AM

Correct,

Lua Code:
  1. local Pets = someframe:CreateFontString(nil, somedrawlayer, somefont)

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).

Hubb777 03-02-24 11:56 PM

Quote:

Originally Posted by Fizzlemizz (Post 343464)
Correct,

Lua Code:
  1. local Pets = someframe:CreateFontString(nil, somedrawlayer, somefont)

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).

Hello. After several days I still couldn't figure it out (I'm stupid). I made the addon without these changes, it turned out pretty good.
https://www.wowinterface.com/downloa...o.php?id=26699

Fizzlemizz 03-03-24 11:13 AM

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:18 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI