Monday, April 16, 2012

LUA / XML error

Hi All ,

Well first time visiting a developer forum for addons.

But i have been working on modifying an out of date addon to suite our personal guild needs. now i have removed alot of junk from the previous version and adding new features.

Now not being .lua minded and work more with web/dba's iv hit a wall in the code.

the code
Code:
star = {
name = L["tools-crowd-control-star-title"],
desc = L["tools-crowd-control-star-descr"],
type = 'group',
order = 8,
args = {
type = {
name = L["tools-crowd-control-common-type-title"],
desc = L["tools-crowd-control-common-type-descr"],
type = 'text',
usage = L["tools-crowd-control-common-type-usage"],
get = function() return ChemicalFu.db.profile.starType end,
set = function(newValue) ChemicalFu.db.profile.starType = newValue end,
validate = {"None", "Sheep", "Banish", "Fear", "Seduce", "Enslave", "Shackle", "Mind Control", "Hibernate", "Trap", "Sap", "Turn Evil", "MT", "OT"}
},
name = {
name = L["tools-crowd-control-common-name-title"],
desc = L["tools-crowd-control-common-name-descr"],
type = 'text',
usage = L["tools-crowd-control-common-name-usage"],
get = function() return ChemicalFu.db.profile.starName end,
set = function(newValue) ChemicalFu.db.profile.starName = newValue end
},
clear = {
name = L["tools-crowd-control-common-clear-title"],
desc = L["tools-crowd-control-common-clear-descr"],
type = 'execute'

func = function()
ChemicalFu.db.profile.starType = L["tools-crowd-control-common-clear-type-default"]
ChemicalFu.db.profile.starName = L["tools-crowd-control-common-clear-name-default"]
end
}
}
},

and the error i recieve

FuBar_ChemicalFu-3.29\ChemicalFu.lua:1766: '}' expected (to close '{' at line 1761) near 'func'

<in C code>: in function `pcall'

thanks to anyone who can show me where this code may be going wrong.

Cheers|||Hi TFBrom,

Firstly, I hope your text editor doesn't normally indent code like that because I can't help thinking "Well, no wonder they're having errors!"

Basically, the error reported is because you're missing a comma at the end of the line before the function declaration in the 'clear' entry...

However, you also have a second error in that you have an EXTRA comma right at the very end of the code, after the final curly bracket. This will also cause an error.

I have put comments in the code -- IN CAPITAL LETTERS


Code:
star = {
name = L["tools-crowd-control-star-title"],
desc = L["tools-crowd-control-star-descr"],
type = 'group',
order = 8,
args = {
type = {
name = L["tools-crowd-control-common-type-title"],
desc = L["tools-crowd-control-common-type-descr"],
type = 'text',
usage = L["tools-crowd-control-common-type-usage"],
get = function() return ChemicalFu.db.profile.starType end,
set = function(newValue) ChemicalFu.db.profile.starType = newValue end,
validate = {"None", "Sheep", "Banish", "Fear", "Seduce", "Enslave", "Shackle", "Mind Control", "Hibernate", "Trap", "Sap", "Turn Evil", "MT", "OT"},
},
name = {
name = L["tools-crowd-control-common-name-title"],
desc = L["tools-crowd-control-common-name-descr"],
type = 'text',
usage = L["tools-crowd-control-common-name-usage"],
get = function() return ChemicalFu.db.profile.starName end,
set = function(newValue) ChemicalFu.db.profile.starName = newValue end,
},
clear = {
name = L["tools-crowd-control-common-clear-title"],
desc = L["tools-crowd-control-common-clear-descr"],
type = 'execute', -- ADDED A REQUIRED COMMA !!!
func = function()
ChemicalFu.db.profile.starType = L["tools-crowd-control-common-clear-type-default"]
ChemicalFu.db.profile.starName = L["tools-crowd-control-common-clear-name-default"]
end,
},
},
} -- REMOVED AN EXTRANEOUS COMMA !!! WE ARE NOW OUTSIDE THE ARRAY DECLARATION



P.S. I actually added some extra commas after the final entries in the array lists also; Even though these aren't required, its a habit of mine just to be consistent about how each entry in the array is formatted, rather than the last entries being special cases. e.g. see the new commas after the second and third to last curly brackets...|||Lol thanks i should have seen it oh the test editor i use doesnt display it like that as its part of Visual Studio but cop and paste probably failed lol when i stuck the code in thanks alot btw it solved that issue but onto the next...


Code:
 show ={ 
name = L["macro-bt-gorefiend-const-show-title"],
desc = L["macro-bt-gorefiend-const-show-descr"],
type = 'execute',
func = function()
SendChatMessage(L["macro-bt-gorefiend-const-show-01-msg"], "RAID")
SendChatMessage(L["macro-bt-gorefiend-const-show-02-msg"], "RAID")
SendChatMessage(L["macro-bt-gorefiend-const-show-03-msg"], "RAID")
SendChatMessage(L["macro-bt-gorefiend-const-show-04-msg"], "RAID")
SendChatMessage(L["macro-bt-gorefiend-const-show-05-msg"], "RAID")
SendChatMessage(L["macro-bt-gorefiend-const-show-06-msg"], "RAID")
SendChatMessage(L["macro-bt-gorefiend-const-show-07-msg"], "RAID")
SendChatMessage(L["macro-bt-gorefiend-const-show-08-msg"], "RAID")
SendChatMessage(L["macro-bt-gorefiend-const-show-09-msg"], "RAID")
SendChatMessage(L["macro-bt-gorefiend-const-show-10-msg"], "RAID")
SendChatMessage(L["macro-bt-gorefiend-const-show-11-msg"], "RAID")
end,
},
},
}

Tools = {
name = L["mainmenu-tools-title"],
type = 'group',
desc = L["mainmenu-tools-descr"],
args = {
recruiter = {
name = L["tools-recruiter-title"],
desc = L["tools-recruiter-descr"],
type = 'group',
args = {
start = {
name = L["tools-recruiter-start-title"],
desc = L["tools-recruiter-start-descr"],
type = 'execute',
func = function()
ChemicalFu:RecruitCharacterCancel()
ChemicalFu:RecruitCharacter()
end
},

FuBar_ChemicalFu-3.29\ChemicalFu.lua:1199: '}' expected (to close '{' at line 1040) near 'Tools'

<in C code>: in function `pcall'|||nvm i sorted that one|||Code:
ChemicalFu:RegisterChatCommand({"/chemfu"}, ChemicalFu.consoleOptions),
ChemicalFu.OnMenuRequest = (ChemicalFu.consoleOptions),

FuBar_ChemicalFu-3.29\ChemicalFu.lua:1846: '}' expected (to close '{' at line 1819) near '='

<in C code>: in function `pcall'

Bahhhh!!|||Code:
  ChemicalFu:RegisterChatCommand({"/chemfu"}, ChemicalFu.consoleOptions);
ChemicalFu.OnMenuRequest == ChemicalFu.consoleOptions;


-- == -----------------------------------------------------------------------
-- == -- Check if the sender issued a 'chemfufu' command. --
-- == -----------------------------------------------------------------------
if string.lower(Args[1]) ~= L["event-command-name-chemfu"] then

if ChemicalFu.db.profile.responderStatus == "On" then
ChemicalFu:DoBusyResponder(sender, msg)
end

return;
end

-- == -----------------------------------------------------------------------
-- == -- Process the 'chemfu' command. --
-- == -----------------------------------------------------------------------
local command; if Args[2] then command = string.lower(Args[2]); end

-- == -----------------------------------------------------------------------
-- == -- Sender requested chemfu command help. --
-- == -----------------------------------------------------------------------
if command == nil then
ChemicalFu:SendWhisperCommandHelp(sender)
return
end

-- == -----------------------------------------------------------------------
-- == -- Sender requested cctargets info. --
-- == -----------------------------------------------------------------------
if command == "cctargets" then
ChemicalFu:AnnounceCrowdControlTargets("WHISPER", sender)
return
end

-- == -----------------------------------------------------------------------
-- == -- If we haven't returned yet, command must have been unrecognised. --
-- == -----------------------------------------------------------------------
ChemicalFu:SendMessage(L["event-command-unknown-01-msg"], "WHISPER", " ", sender)
ChemicalFu:SendMessage(L["event-command-unknown-02-msg"], "WHISPER", " ", sender)

end

-- ============================================================================
-- == SendWhisperCommandHelp(recipient) ==
-- == ==
-- == This function sends hints via whispers on the available whisper-based ==
-- == commands currently recognised by ChemicalFu to the named recipient. ==
-- ============================================================================

function ChemicalFu:SendWhisperCommandHelp(recipient)

ChemicalFu:SendMessage(L["event-helpinfo-01-msg"], "WHISPER", " ", recipient)
ChemicalFu:SendMessage(L["event-helpinfo-02-msg"], "WHISPER", " ", recipient)
ChemicalFu:SendMessage(L["event-helpinfo-03-msg"], "WHISPER", " ", recipient)
ChemicalFu:SendMessage(L["event-helpinfo-04-msg"], "WHISPER", " ", recipient)

end

-- ============================================================================
-- == SendWhisperGuildInfo(recipient) ==
-- == ==
-- == This function sends a summary of guild information via the whisper ==
-- == channel to the named recipient. ==
-- ============================================================================

function ChemicalFu:SendWhisperGuildInfo(recipient)

ChemicalFu:SendMessage(L["event-guildinfo2-01-msg"], "WHISPER", " ", recipient)
ChemicalFu:SendMessage(L["event-guildinfo2-02-msg"], "WHISPER", " ", recipient)
ChemicalFu:SendMessage(L["event-guildinfo2-03-msg"], "WHISPER", " ", recipient)
ChemicalFu:SendMessage(L["event-guildinfo2-04-msg"], "WHISPER", " ", recipient)
ChemicalFu:SendMessage(L["event-guildinfo2-05-msg"], "WHISPER", " ", recipient)

end

-- ============================================================================
-- == GetArgs(message, separator) ==
-- == ==
-- == This function receives a string and converts it into a list of ==
-- == arguments, using space as the separator character. ==
-- ============================================================================

function ChemicalFu:GetArgs(message, separator)

if message == nil then
message = ""
end

local args = {}
local i = 0


-- search for seperators in the string and return the separated data
for value in string.gmatch(message, "[^"..separator.."]+") do
i = i + 1
args[i] = value
end

return args

end

Well this code in the addon that is giving troubles now ..

hense why it needed the update...|||I'm confused, what's your current issue? Where are lines 1846/1819? All these issues are going to be the same kind of thing, the parser can't match your brackets properly because you're either missing brackets, have extra brackets, or have some other delimeter like a comma in the wrong place.


Quote:




P.S. I actually added some extra commas after the final entries in the array lists also; Even though these aren't required, its a habit of mine just to be consistent about how each entry in the array is formatted, rather than the last entries being special cases. e.g. see the new commas after the second and third to last curly brackets...




I love the way Lua lets you do this as well, it means when you come back later to add a new entry in the table you can add one line of code without forgetting to add the comma to the previous line every time!|||Quote:








I'm confused, what's your current issue? Where are lines 1846/1819? All these issues are going to be the same kind of thing, the parser can't match your brackets properly because you're either missing brackets, have extra brackets, or have some other delimeter like a comma in the wrong place.

I love the way Lua lets you do this as well, it means when you come back later to add a new entry in the table you can add one line of code without forgetting to add the comma to the previous line every time!




Well i gathered that from the last post. I went through the whole code to be able to find anything missing on the original when i run the addon. Iv tried everything from added comma's everywhere it still hits with the same error closing brackets and putting brackets in did not change the error.



But i will go through it again atm the first line of code was originally in there with only ; to close the code but still gives an error on line 1846

...>>ChemicalFu:RegisterChatCommand({"/chemfu"}, ChemicalFu.consoleOptions);

ChemicalFu.OnMenuRequest = ChemicalFu.consoleOptions;

as there is 3000 lines of code im going through every error i get on the way to fix or try and fix. This is the only line atm which is giving an error and cannot move down the list till its sorted all others i have checked as Telic said make sure comma's and so on are in the right place this code had alot of comma's in the wrong place lol|||I thnk i should be able to sort it as the code is becoming a lil easier to work with scince i changed teh Editor to Crimson.|||:)..........

No comments:

Post a Comment