Monday, April 16, 2012

merging addons without null errors

Hi,

I am try to merge two addons together (done a few now without issue), but one of them, when I merge them together I get a null error.

e.g.

..\AddOns\<addon name>\<name>.lua line 78: attempt to index upvalue 'data' (a nil value)

The addon works fine when its on its own but when merged it does that error.

How can I figure out what is going on?|||if we new the name of the addons we might be able to help.|||One is my own basic addon that just moves the standard blizz UI into the places I want them at, the other is an addon called MoneyTrail.

on its own, it works fine, but when I merge them together I get the following.

Date: 2009-09-16 11:20:56

ID: 1

Error occured in: Global

Count: 1

Message: ..\AddOns\Doomie's_UI\MoneyTrail.lua line 78:

attempt to index upvalue 'data' (a nil value)

Debug:

[C]: ?

Doomie's_UI\MoneyTrail.lua:78: ?()

Doomie's_UI\MoneyTrail.lua:98:

Doomie's_UI\MoneyTrail.lua:96

AddOns:

Swatter, v5.6.4424 (KangaII)

BankItems, v30200

DoomiesUI, v1.0

FuBar, v

BlizRuntimeLib_enUS v3.2.0.30200 <eu>

(ck=78)

Now the section of script its erroring at is


Code:
local function UpdateData()
local money = GetMoney()
if money and money ~= data.money then <---- Line 78
if not data.money then data.money = money end
-- money changed calculate that
local diff = money - data.money
if diff > 0 then
data.gained = data.gained + diff
else
data.spent = data.spent + -1*diff
end
data.diff = data.gained - data.spent
data.money = money
if LDBObj then LDBObj.text = MoneyString(money) end
end
end

-- our addon frame
local addon = CreateFrame("Frame", "MoneyTrail", UIParent)
-- our addon event handler
local function OnEvent(self, event, ...) <----line 96
if self[event] then
self[event](self, event, ...) <-----line 98
end
end
|||How are you merging them together? And also, why? They should work fine as separate addons....

My guess would be that they both have a variable called "data", and by merging them into one LUA file (which is what I assume you mean by "merging them together"), the two of them are now stepping on each other's variables.|||I am merging them together for myself, plus for the challange.

What I have done is taken the needed details from the toc file, put them into mine and then copied the addon folder into mine and made sure the location name in the toc file was correct.

I have tried to rename the data variable to data1 but still the same error. just with data1 instead.

Checking the SavedViarables, it just has this in for it "MoneyTrailDB = nil".|||No one have any ideas on this please?

No comments:

Post a Comment