Quantcast AceConfig OptionsTable Radio Help - WoWInterface
Thread Tools Display Modes
12-14-17, 11:25 AM   #1
Smallinger
A Deviate Faerie Dragon
 
Smallinger's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 14
AceConfig OptionsTable Radio Help

Hello, i working my first time with AceConfig Options Table and AceDB,

if i press on one of the radio i got this error.
Code:
attempt to index field 'repairMode' (a string value)
i have a table with follow information
Code:
local repairModeList = {
	["1"] = "Own gold",
	["2"] = "Guild bank",
}
i have under RegusterDefaults a Variable with the name
Code:
self.db:RegisterDefaults({
	char = {
		autoRepair = true,
		printRepairGold = true,
		repairMode = "1",
	}
})
and in the Table for AceConfig OptionsTable a radio like this.

Code:
repairMode = {
	order	= 17,
	type 	= "select",
	name    = "Repair mode",
	desc    = "",
	style	= "radio",
	values 	= repairModeList,
	get   	= function(key) return self.db.char.repairMode[key.arg] end,
	set   	= function(key, value) self.db.char.repairMode[key.arg] = value end,
},
i hope anyone can help me..
  Reply With Quote
12-14-17, 11:40 AM   #2
Ammako
A Cobalt Mageweaver
 
Ammako's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 229
Well you already set repairMode as a string ("1"), and then you try to reuse it as a table, which is bound to cause issues no matter what for what you're trying to do.
__________________
█████████████
█████████████
█████████████
█████████████
  Reply With Quote
12-14-17, 12:09 PM   #3
Smallinger
A Deviate Faerie Dragon
 
Smallinger's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 14
Originally Posted by Ammako View Post
Well you already set repairMode as a string ("1"), and then you try to reuse it as a table, which is bound to cause issues no matter what for what you're trying to do.
Hey Ammako thx for your answer, is there a possibility to get the key and safe it as a String ? or is there a better way ?

so that i can check the code with like
Code:
if (repairMode == "1") then
example code here...
elseif (repairMode == "2") then
example code here...
end
  Reply With Quote
12-14-17, 12:39 PM   #4
Ammako
A Cobalt Mageweaver
 
Ammako's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 229
When making option menus and stuff I like to name the variables after what they are; in this case it would be repairModeRadioButton.
That way you guarantee that there will be no conflicts with accidentally naming two variables the same thing.

Maybe you can set some variables as local, too, but idk how Ace works and if it would allow it.
__________________
█████████████
█████████████
█████████████
█████████████

Last edited by Ammako : 12-14-17 at 12:42 PM.
  Reply With Quote
12-14-17, 12:58 PM   #5
Smallinger
A Deviate Faerie Dragon
 
Smallinger's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 14
Ok, thx for the tipp with the Variables names,

i test it a little bit an got a fix with
Code:
repairMode = {
	order	= 17,
	type 	= "select",
	name    = "Repair mode",
	desc    = "",
	style	= "radio",
	values 	= repairModeList,
	get   	= function(info, value) return self.db.char.repairMode end,
	set   	= function(info, value) self.db.char.repairMode = value end,
},
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » AceConfig OptionsTable Radio Help

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off