Skip to content

Commit 006ea0b

Browse files
committed
Converted all functions to = function
1 parent 47c40aa commit 006ea0b

10 files changed

Lines changed: 35 additions & 35 deletions

File tree

api/connection.lua

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ local SERVER_DEFAULTS = {
3636
}
3737

3838
local MPAPI_update_ref = MPAPI.update
39-
function MPAPI.update()
39+
MPAPI.update = function()
4040
if _mqtt_instance then
4141
_mqtt_instance:update()
4242
end
@@ -47,14 +47,14 @@ end
4747
-- API FUNCTIONS
4848
-----------------------------
4949

50-
function MPAPI.on_loaded(fn)
50+
MPAPI.on_loaded = function(fn)
5151
if _ready then
5252
return fn()
5353
end
5454
_ready_callbacks[#_ready_callbacks + 1] = fn
5555
end
5656

57-
function MPAPI.connect(opts)
57+
MPAPI.connect = function(opts)
5858
opts = opts or {}
5959
_last_opts = opts
6060

@@ -100,7 +100,7 @@ function MPAPI.connect(opts)
100100
_connection:connect()
101101
end
102102

103-
function MPAPI.disconnect()
103+
MPAPI.disconnect = function()
104104
if _connection then
105105
_connection:disconnect()
106106
end
@@ -114,38 +114,38 @@ function MPAPI.disconnect()
114114
set_connection_state_status_text()
115115
end
116116

117-
function MPAPI.is_connected()
117+
MPAPI.is_connected = function()
118118
if _connection then
119119
return _connection:get_state()
120120
end
121121
return 'disconnected'
122122
end
123123

124-
function MPAPI.get_mqtt()
124+
MPAPI.get_mqtt = function()
125125
return _mqtt_instance
126126
end
127127

128-
function MPAPI.get_connection()
128+
MPAPI.get_connection = function()
129129
return _connection
130130
end
131131

132-
function MPAPI.get_last_opts()
132+
MPAPI.get_last_opts = function()
133133
return _last_opts
134134
end
135135

136-
function MPAPI.is_ready()
136+
MPAPI.is_ready = function()
137137
return _ready
138138
end
139139

140140
-----------------------------
141141
-- INTERNAL FUNCTIONS
142142
-----------------------------
143143

144-
function MPAPI._internal.set_ready(ready)
144+
MPAPI._internal.set_ready = function(ready)
145145
_ready = ready
146146
end
147147

148-
function MPAPI._internal.run_ready_callbacks()
148+
MPAPI._internal.run_ready_callbacks = function()
149149
for _, fn in ipairs(_ready_callbacks) do
150150
local ok, err = pcall(fn)
151151
if not ok then
@@ -155,7 +155,7 @@ function MPAPI._internal.run_ready_callbacks()
155155
_ready_callbacks = {}
156156
end
157157

158-
function MPAPI._internal.get_discord_link_url(callback)
158+
MPAPI._internal.get_discord_link_url = function(callback)
159159
local conn = _connection
160160
if not conn or conn:get_state() ~= 'connected' then
161161
callback('Not connected', nil)
@@ -168,7 +168,7 @@ function MPAPI._internal.get_discord_link_url(callback)
168168
conn.api:get_discord_link_url(conn.jwt_token, callback)
169169
end
170170

171-
function MPAPI._internal.set_use_discord_name(value, callback)
171+
MPAPI._internal.set_use_discord_name = function(value, callback)
172172
local conn = _connection
173173
if not conn or conn:get_state() ~= 'connected' then
174174
callback('Not connected', nil)
@@ -197,7 +197,7 @@ function MPAPI._internal.set_use_discord_name(value, callback)
197197
end)
198198
end
199199

200-
function MPAPI._internal.set_preferred_joker(value, callback)
200+
MPAPI._internal.set_preferred_joker = function(value, callback)
201201
local conn = _connection
202202
if not conn or conn:get_state() ~= 'connected' then
203203
callback('Not connected', nil)
@@ -223,7 +223,7 @@ function MPAPI._internal.set_preferred_joker(value, callback)
223223
end)
224224
end
225225

226-
function MPAPI._internal.unlink_discord(callback)
226+
MPAPI._internal.unlink_discord = function(callback)
227227
local conn = _connection
228228
if not conn or conn:get_state() ~= 'connected' then
229229
callback('Not connected', nil)

api/mod_registry.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ end
3737
-- API FUNCTIONS
3838
-----------------------------
3939

40-
function MPAPI.register_mod(opts)
40+
MPAPI.register_mod = function(opts)
4141
if not opts.id then
4242
MPAPI.sendWarnMessage('register_mod: missing id')
4343
return
@@ -73,18 +73,18 @@ function MPAPI.register_mod(opts)
7373
update_account_button()
7474
end
7575

76-
function MPAPI.get_active_mod()
76+
MPAPI.get_active_mod = function()
7777
return _active_mod
7878
end
7979

80-
function MPAPI.get_active_mod_data()
80+
MPAPI.get_active_mod_data = function()
8181
if not _active_mod then
8282
return
8383
end
8484
return _registered_mods[_active_mod]
8585
end
8686

87-
function MPAPI.get_registered_mods()
87+
MPAPI.get_registered_mods = function()
8888
local result = {}
8989
-- Official mods first, in order
9090
for _, official in ipairs(_official_mods) do
@@ -101,7 +101,7 @@ end
101101
-- INTERNAL FUNCTIONS
102102
-----------------------------
103103

104-
function MPAPI._internal.activate_mod(id)
104+
MPAPI._internal.activate_mod = function(id)
105105
local mod = _registered_mods[id]
106106
if not mod then
107107
MPAPI.sendWarnMessage('activate_mod: unknown mod ' .. tostring(id))
@@ -123,7 +123,7 @@ function MPAPI._internal.activate_mod(id)
123123
update_account_button()
124124
end
125125

126-
function MPAPI._internal.deactivate_mod()
126+
MPAPI._internal.deactivate_mod = function()
127127
if not _active_mod then
128128
return
129129
end

api/ui_element.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ local _id_counter = 0
4242
-- el:as_overlay() -- Open as overlay menu
4343
-- el:get_uibox() -- Returns the current UIBox (uibox mode only)
4444
-- el:get_id() -- Returns the stable ID string
45-
function MPAPI.ui_element(build_fn)
45+
MPAPI.ui_element = function(build_fn)
4646
local id = next_id()
4747
local el = {}
4848

@@ -162,7 +162,7 @@ function MPAPI.ui_element(build_fn)
162162
return el
163163
end
164164

165-
function MPAPI.disableable_button(args)
165+
MPAPI.disableable_button = function(args)
166166
local build_fn = function()
167167
local enabled = resolve_enabled(args)
168168
local build_args = MPAPI.shallow_copy(args)
@@ -187,7 +187,7 @@ function MPAPI.disableable_button(args)
187187
return MPAPI.ui_element(build_fn)
188188
end
189189

190-
function MPAPI.disableable_toggle(args)
190+
MPAPI.disableable_toggle = function(args)
191191
local build_fn = function()
192192
local enabled = resolve_enabled(args)
193193
local build_args = MPAPI.shallow_copy(args)
@@ -203,7 +203,7 @@ function MPAPI.disableable_toggle(args)
203203
return MPAPI.ui_element(build_fn)
204204
end
205205

206-
function MPAPI.disableable_option_cycle(args)
206+
MPAPI.disableable_option_cycle = function(args)
207207
local build_fn = function()
208208
local enabled = resolve_enabled(args)
209209
local build_args = MPAPI.shallow_copy(args)

lib/config.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
-- Gets a value from the MPAPI config by its key
2-
function MPAPI._internal.config_get(key)
2+
MPAPI._internal.config_get = function(key)
33
return MPAPI.config[key]
44
end
55

66
-- Sets a value from the MPAPI config by its key
7-
function MPAPI._internal.config_set(key, value)
7+
MPAPI._internal.config_set = function(key, value)
88
MPAPI.config[key] = value
99
SMODS.save_mod_config(MPAPI)
1010
end

lib/text.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Takes a string and max length
22
-- Returns the string if its length is <= max
33
-- Returns a substring with ... at the end that is exactly max long
4-
function MPAPI.truncate(s, max)
4+
MPAPI.truncate = function(s, max)
55
if not s or #s <= max then
66
return s
77
end

lib/ui.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Walk a UI node tree, calling visitor(node, config) on each node
2-
function MPAPI.walk_nodes(node, visitor)
2+
MPAPI.walk_nodes = function(node, visitor)
33
if not node then
44
return
55
end
@@ -30,7 +30,7 @@ end
3030
-- Returns a Joker card using the user's preferred joker id
3131
-- Can be easily added to UI using { n = G.UIT.O, config = { object = card } }
3232
-- card_parameters get added to the underlying card values
33-
function MPAPI.create_account_avatar(card_parameters)
33+
MPAPI.create_account_avatar = function(card_parameters)
3434
local joker_id = MPAPI.connection_state.preferred_joker or 'j_joker'
3535
local center = G.P_CENTERS[joker_id] or G.P_CENTERS['j_joker']
3636
local card = Card(0, 0, G.CARD_W, G.CARD_H, G.P_CARDS.empty, center, card_parameters)

lib/util.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Copies a table including internal references
2-
function MPAPI.shallow_copy(t)
2+
MPAPI.shallow_copy = function(t)
33
local out = {}
44
for k, v in pairs(t) do
55
out[k] = v

ui/account_overlay.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ local settings_row
1111
-- UI FUNCTIONS
1212
-----------------------------
1313

14-
local function create_UIBox_account_overlay()
14+
local create_UIBox_account_overlay = function()
1515
if MPAPI.connection_state.state ~= 'connected' then
1616
return G.FUNCS.exit_overlay_menu()
1717
end

ui/avatar_selection.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ local _joker_tables = {}
8181
-- UI FUNCTIONS
8282
-----------------------------
8383

84-
local function create_UIBox_avatar_selection()
84+
local create_UIBox_avatar_selection = function()
8585
_joker_tables = {}
8686

8787
create_card_rows()

ui/main_menu.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local attach_account_button
88
-- UI FUNCTIONS
99
-----------------------------
1010

11-
local function create_UIBox_account_button()
11+
local create_UIBox_account_button = function()
1212
local status_colour = G.C.RED
1313
if MPAPI.connection_state.state == 'connected' then
1414
status_colour = G.C.WHITE
@@ -203,7 +203,7 @@ MPAPI.account_button = MPAPI.ui_element(create_UIBox_account_button)
203203
-----------------------------
204204

205205
local _set_main_menu_UI_ref = set_main_menu_UI
206-
function set_main_menu_UI()
206+
set_main_menu_UI = function()
207207
local active = MPAPI.get_active_mod_data()
208208

209209
if active and active.main_menu_ui then

0 commit comments

Comments
 (0)