Button on the minimap
Hi all. I created a button on the minimap. But I can’t get it to open another LUA file.
the button itself (triggered by LMB). Lua Code:
The frame that the button should open Lua Code:
|
Your toggle function only displays text in the chat frame - did you check to see if it appeared ?
Lua Code:
If that text appeared then it is working, you just need to add your code to manage the opening and closing of the panel. |
Quote:
|
I've personally not used the Wow Options system, but I would try to use the example in the wiki page below. If you were aiming to have a panel inside the wow options screen like several addons have done before .. you might want to see how close you are to the example in there.
https://warcraft.wiki.gg/wiki/Using_...s_Addons_panel Take note of the known bug mentioned in the small print at the bottom. |
You gave an example of creating a panel. I was looking for how to open it through the “icon on the minimap”. |
Okay.
Which one of these were you hoping to implement ? Each one will involve different set up and calls to show up. 1. Display Panel in pre Dragonflight InterfaceOptionsFrame Use example in https://warcraft.wiki.gg/wiki/Using_...s_Addons_panel to make sure your panel is correctly set up to work with the Interface Options Addons Panel system. And then use `InterfaceOptionsFrame_OpenToCategory(panel)` to open the frame when you click your button ( you might have to call it twice for it to work as per the comment in the small print at the bottom. It will have a close button to close it again - no need to toggle. 2. Display your own custom panel on the main screen like any other frame you create. In this case, make sure your frame has a background/backdrop and any other controls it needs. And then you can use the following function to toggle your panel to show or hide based on its current status when you click your button. Example Code: Lua Code:
But you would have to change this Lua Code:
To this Lua Code:
3. Have your panel show up as part of the Dragonflight SettingsPanel https://warcraft.wiki.gg/wiki/Patch_10.0.0/API_changes gives you some sort of example on how to set up your frame to be part of the settings panel. But not an example on how to jump to your panel. There is a similar Settings.OpenToCategory() function which Fizzle points to in https://www.wowinterface.com/forums/...11&postcount=2 but it only goes to the AddOns tab and not a particular AddOns panel. |
Just copied the Dragonflight Settings example and tested a button click to open and Fizzles code works. It won't go straight to your addon page, but it will go to the addon page list section.
This was the code I used: Lua Code:
|
I need the settings menu for my addon to open.
How it works for me now (a menu with game settings opens) How I want it to work (my addon settings should open) Here is my final code Lua Code:
|
Yes, my last example, 2 lines in the OnClick script will open the settings panel to the addon list page. There doesn't seem to be a way addons can open to their own section of the settings by code. Maybe it is protected and needs the user to select the item in the list.
Where is the code where you set up your settings/options page ? You might still have stuff missing to make it work. And how you have done it will determine whether you need to use Lua Code:
Lua Code:
As a reminder: This link gives you an example on how to use the OLD InterfaceOptionsFrame way of adding a settings page. And includes the example on how to show the page on request. https://warcraft.wiki.gg/wiki/Using_...s_Addons_panel This post from 2 years ago talks through a few problems people have had getting it to work. It might help you. https://www.wowinterface.com/forums/...ad.php?t=57172 Bear in mind that the Lua Code:
Instead it is replaced with Lua Code:
So, you might want to consider using the new Settings functionality added in Dragonflight. This will save you having to figure it out again later when it stops working when the functionality is removed. But you have to set up your settings page to work with Blizzards Settings ( my last block of code gives an example of how one of those ways works - Vertical Display - and the link below also includes the Canvas route and that is the closest to the old InterfaceOptions way). As a reminder: https://warcraft.wiki.gg/wiki/Patch_...s#Settings_API Gives you an example of how to set that up ( my last code block is a copy of this with a button to click it open added. You can then use the following to open up the settings frame and show the addon page ( finally managed to get it work with my example with the following in the OnClick function. Lua Code:
category is set up when you create your settings panel and connect it to the settings system. So .. depending on how you have created your panel, will determine which version you use and whether it will work or not. |
Looks like I didn't succeed =(
I added this to the code of the panel that I want to open: Lua Code:
I also changed the button code on the minimap Lua Code:
As a result, the button works without changes (using the example with the pictures above) |
So is it working as you wanted or not ?
Is it opening to your addon's settings panel ? Is it showing all the controls you set up for it ? Is it saving the settings between play sessions ( if you wanted it to do that ) |
How I have it now (and how it was before): I click on the “icon on the minimap” and the “game settings” open (see picture below)
How I want: When I click the “icon on the minimap”, the settings of my addon “MyAddonOptionsPanel” open. (see picture below) |
Your code must still be missing something which is why I asked to see the code where you create your settings panel. How you create that will determine how you display it.
|
I would suggest you try creating a simple addon that just shows a settings panel, using the example code on the wiki.gg page I linked. Once you have seen how that works, you can add your addon's functionality.
It was what I did to figure out how it worked so I could explain it to you. |
Quote:
Lua Code:
I'm new to writing LUA, but I was advised to use ChatGPT (with the help of it I was able to create the panel code and the "icons on the minimap" code) |
That's understandable.
ChatGPT may not be wise enough to realise new addons are probably best to use new functions rather than ones that will be gone by the next expansion. Looking at your code I can see you have mixed and matched the two ways ( new and old ) which explains why it doesn't quite work as you expected. Let me rig up a version of this panel frame that should work. |
Quote:
|
Okay. These are all the files I needed to make it work. Remember order in the toc is important with separate files.
TOC File - Remember to change Title/Author/Version/SavedVariables/Notes to suit your addon Lua Code:
SettingsPanel.lua - Remember to use unique frame names if you need to use frame names. I have made some notes in here. This has to be loaded before your MinimapButton tries to reference it. Lua Code:
MinimapButton.lua - Didn't have to change much here - just where the category value was stored and the name of the SavedVariables table which isn't used in your code but needs to be set up and the icon I used on the minimap button. Lua Code:
|
Remember the code I attached just has the addon settings panel and the minimap button code. The rest of your addon code will need to be added to the toc file if you use my version of the code as the base of the addon. Or vice versa if you pull in my version of the code to your addon. Remember to remove or comment out the old code the new code is replacing so there isn't any conflict.
Edit: Also, this was tested on the ptr 10.2.7 so we know this code will work with the next patch. |
yes it works. Thank you very much
As I understand it, this part of the code in the “panel” answers: the panel will open through the minimap icon yes/no? Right? Lua Code:
Lua Code:
|
All times are GMT -6. The time now is 09:45 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI