View Single Post
04/24/14, 08:29 PM   #9
archpoet
Cunning Linguist
 
archpoet's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 19
Yep, namespace conflict: confirmed.

Basically I copied and pasted your code as written and just changed the name of the function to RollDice() in both the lua and the xml and it worked no issue.



Code:
function RollDice()
    local num = math.random(1,100)
    return num
end
Code:
            <OnMouseDown>
                Roll = RollDice()
                LootDiceRoll:SetText(Roll)
            </OnMouseDown>
In my opinion this is not an issue in strict Lua, (nor do other strongly typed interpreted languages suffer from this issue.)
I feel like this arises because the Game compiles the Lua and the XML elements into globally scoped lexical objects. Which in context makes sense why they would apparently conflict on names.

Last edited by archpoet : 04/24/14 at 08:35 PM.
  Reply With Quote