diff --git a/aux-addon.lua b/aux-addon.lua index a34216c..9583041 100644 --- a/aux-addon.lua +++ b/aux-addon.lua @@ -77,7 +77,7 @@ do public.temp { get = function() return setmetatable(t, mt) end, - set = function(t) return make_transient(t) end, + set = function(t) make_transient(t) end, } end do @@ -85,7 +85,7 @@ do public.perm { get = function() return setmetatable(t, mt) end, - set = function(t) return make_persistent(t) end, + set = function(t) make_persistent(t) end, } end @@ -155,15 +155,20 @@ do return {__call=f, __unm=function(self) return setmetatable(self, nil) end} end local set_mt, list_mt, object_mt = collector_mt(insert_keys), collector_mt(insert_values), collector_mt(insert_pairs) - public() - function list() return setmetatable(t, list_mt) end - function set() return setmetatable(t, set_mt) end - function object() return setmetatable(t, object_mt) end - private() + function public.set.get() return setmetatable(t, set_mt) end + function public.list.get() return setmetatable(t, list_mt) end + function public.object.get() return setmetatable(t, object_mt) end +end + +function public.log(...) temp=arg + local msg = '[aux]' + for i=1,arg.n do msg = msg..' '..tostring(arg[i]) end + DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE..msg) end local event_frame = CreateFrame 'Frame' for event in -temp-set('ADDON_LOADED', 'VARIABLES_LOADED', 'PLAYER_LOGIN', 'AUCTION_HOUSE_SHOW', 'AUCTION_HOUSE_CLOSED', 'AUCTION_BIDDER_LIST_UPDATE', 'AUCTION_OWNED_LIST_UPDATE') do + log(event) event_frame:RegisterEvent(event) end @@ -188,12 +193,6 @@ do end) end -function public.log(...) temp=arg - local msg = '[aux]' - for i=1,arg.n do msg = msg..' '..tostring(arg[i]) end - DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE..msg) -end - tab_info = t do local data = -temp-list('search_tab', 'Search', 'post_tab', 'Post', 'auctions_tab', 'Auctions', 'bids_tab', 'Bids') @@ -212,7 +211,7 @@ end do local index - function active_tab.get() return tab_info[index] end + function private.active_tab.get() return tab_info[index] end function on_tab_click(i) call(index and active_tab.CLOSE) index = i diff --git a/control.lua b/control.lua index 5bbb6e1..634f483 100644 --- a/control.lua +++ b/control.lua @@ -46,7 +46,7 @@ end do local id = 0 - function id.get() id = id + 1; return id end + function private.id.get() id = id + 1; return id end end function public.kill_listener(listener_id) diff --git a/core/history.lua b/core/history.lua index 257363f..d734661 100644 --- a/core/history.lua +++ b/core/history.lua @@ -6,7 +6,7 @@ value_cache = t do local cache - function data.get() + function private.data.get() if not cache then local dataset = persistence.dataset cache = dataset.history or t @@ -18,7 +18,7 @@ end do local time = 0 - function next_push.get() + function private.next_push.get() if time() > time then local date = date '*t' date.hour, date.min, date.sec = 24, 0, 0 @@ -28,7 +28,7 @@ do end end -function new_record.get() +function private.new_record.get() return -object('next_push', next_push, 'data_points', t) end diff --git a/core/scan.lua b/core/scan.lua index dd5cc73..c2dad11 100644 --- a/core/scan.lua +++ b/core/scan.lua @@ -37,13 +37,13 @@ do call(on_complete) end - function state.get() + function private.state.get() local _, state = next(filter(scan_states, function(state) return state.id == thread_id end)) return state end end -function query.get() return state.params.queries[state.query_index] end +function private.query.get() return state.params.queries[state.query_index] end function wait_for_callback(...) temp=arg local send_signal, signal_received = signal() diff --git a/libs/module.lua b/libs/module.lua index b4fe628..d2a8f26 100644 --- a/libs/module.lua +++ b/libs/module.lua @@ -51,13 +51,9 @@ do state.declaration_access, state.declaration_name = nil, nil end function declarator_mt:__call(value) local state=_state[self] - if state.declaration_name then - local success, f, getter, setter = pcall(extract, value) - if not success then declaration_error() end - declare(state, state.declaration_access, state.declaration_name, {[FUNCTION]=f, [GETTER]=getter, [SETTER]=setter}) - elseif state.declaration_access or declaration_error() then - state.default_access = state.declaration_access - end + local success, f, getter, setter = pcall(extract, value) + if not (success and state.declaration_name) then declaration_error() end + declare(state, state.declaration_access, state.declaration_name, {[FUNCTION]=f, [GETTER]=getter, [SETTER]=setter}) state.declaration_access, state.declaration_name = nil, nil end end diff --git a/tabs/post/core.lua b/tabs/post/core.lua index 60faa1f..2ce1822 100644 --- a/tabs/post/core.lua +++ b/tabs/post/core.lua @@ -4,13 +4,13 @@ aux 'post_tab' local scan, scan_util, post, history, info, persistence, item_lis local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440 local settings_schema = {'record', '#', {stack_size='number'}, {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}} -function default_settings.get() +function private.default_settings.get() return -object('duration', DURATION_8 , 'stack_size', 1, 'start_price', 0, 'buyout_price', 0, 'hidden', false) end do local data - function data.get() + function private.data.get() if not data then local dataset = persistence.dataset data = dataset.post or t diff --git a/tabs/search/core.lua b/tabs/search/core.lua index 4fe5c4b..7919568 100644 --- a/tabs/search/core.lua +++ b/tabs/search/core.lua @@ -78,7 +78,7 @@ function USE_ITEM(item_info) execute(nil, false) end -function subtab.set(tab) +function private.subtab.set(tab) search_results_button:UnlockHighlight() saved_searches_button:UnlockHighlight() new_filter_button:UnlockHighlight() diff --git a/tabs/search/results.lua b/tabs/search/results.lua index 8e6b463..230d7ca 100644 --- a/tabs/search/results.lua +++ b/tabs/search/results.lua @@ -23,7 +23,7 @@ do local searches = t local search_index = 1 - function current_search.get() return searches[search_index] end + function private.current_search.get() return searches[search_index] end function update_search(index) searches[search_index].status_bar:Hide()