mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
refactor: rename imports
BREAKING! Since the folder name determines the import name (i.e. lib.callbacks), use better names and lowerCamelCase.
This commit is contained in:
@@ -23,11 +23,11 @@ game 'gta5'
|
|||||||
--[[ Resource Information ]]--
|
--[[ Resource Information ]]--
|
||||||
name 'ox_lib'
|
name 'ox_lib'
|
||||||
author 'Linden'
|
author 'Linden'
|
||||||
version '1.5.0'
|
version '2.0.0'
|
||||||
repository 'https://github.com/overextended/ox_lib'
|
repository 'https://github.com/overextended/ox_lib'
|
||||||
description 'A library of shared functions to utilise in other resources.'
|
description 'A library of shared functions to utilise in other resources.'
|
||||||
|
|
||||||
[[ Manifest ]]--
|
--[[ Manifest ]]--
|
||||||
dependencies {
|
dependencies {
|
||||||
'/server:5104',
|
'/server:5104',
|
||||||
'/onesync',
|
'/onesync',
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
--- Call on frame to disable all stored keys.
|
--- Call on frame to disable all stored keys.
|
||||||
--- ```
|
--- ```
|
||||||
--- DisableControlActions()
|
--- disableControls()
|
||||||
--- ```
|
--- ```
|
||||||
local DisableControlActions = {}
|
local disableControls = {}
|
||||||
|
|
||||||
---@param ... number
|
---@param ... number
|
||||||
function DisableControlActions:Add(...)
|
function disableControls:Add(...)
|
||||||
local keys = type(...) == 'table' and ... or {...}
|
local keys = type(...) == 'table' and ... or {...}
|
||||||
for i=1, #keys do
|
for i=1, #keys do
|
||||||
local key = keys[i]
|
local key = keys[i]
|
||||||
@@ -18,7 +18,7 @@ function DisableControlActions:Add(...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@param ... number
|
---@param ... number
|
||||||
function DisableControlActions:Remove(...)
|
function disableControls:Remove(...)
|
||||||
local keys = type(...) == 'table' and ... or {...}
|
local keys = type(...) == 'table' and ... or {...}
|
||||||
for i=1, #keys do
|
for i=1, #keys do
|
||||||
local key = keys[i]
|
local key = keys[i]
|
||||||
@@ -32,22 +32,22 @@ function DisableControlActions:Remove(...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@param ... number
|
---@param ... number
|
||||||
function DisableControlActions:Clear(...)
|
function disableControls:Clear(...)
|
||||||
local keys = type(...) == 'table' and ... or {...}
|
local keys = type(...) == 'table' and ... or {...}
|
||||||
for i=1, #keys do
|
for i=1, #keys do
|
||||||
self[keys[i]] = nil
|
self[keys[i]] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local Keys = {}
|
local keys = {}
|
||||||
local DisableControlAction = DisableControlAction
|
local DisableControlAction = DisableControlAction
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
|
|
||||||
return setmetatable(DisableControlActions, {
|
return setmetatable(disableControls, {
|
||||||
__index = Keys,
|
__index = keys,
|
||||||
__newindex = Keys,
|
__newindex = keys,
|
||||||
__call = function()
|
__call = function()
|
||||||
for k in pairs(Keys) do
|
for k in pairs(keys) do
|
||||||
DisableControlAction(0, k, true)
|
DisableControlAction(0, k, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
7
init.lua
7
init.lua
@@ -2,19 +2,18 @@ if not _VERSION:find('5.4') then
|
|||||||
error('^1Lua 5.4 must be enabled in the resource manifest!^0', 3)
|
error('^1Lua 5.4 must be enabled in the resource manifest!^0', 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
-- Module
|
-- Module
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- env
|
-- env
|
||||||
local lualib = 'ox_lib'
|
local lualib = 'ox_lib'
|
||||||
local file = IsDuplicityVersion() and 'server' or 'client'
|
|
||||||
|
|
||||||
-- micro-optimise
|
-- micro-optimise
|
||||||
local rawget = rawget
|
|
||||||
local rawset = rawset
|
|
||||||
local LoadResourceFile = LoadResourceFile
|
local LoadResourceFile = LoadResourceFile
|
||||||
|
local file = IsDuplicityVersion() and 'server' or 'client'
|
||||||
|
local rawset = rawset
|
||||||
|
local rawget = rawget
|
||||||
|
|
||||||
local function loadModule(self, module)
|
local function loadModule(self, module)
|
||||||
local dir = ('imports/%s'):format(module)
|
local dir = ('imports/%s'):format(module)
|
||||||
|
|||||||
Reference in New Issue
Block a user