Merge pull request #3 from qwezertino/qwezert_fixes

Qwezert fixes for use Framework functions if selected module empty and ability to choose and populate exist module
This commit is contained in:
MrNewb authored and GitHub committed 2025-01-10 16:18:11 -05:00
commit 515d4412b1
6 files changed
+66 -64

No files matched your search

+1
View File
@@ -1,6 +1,7 @@
fx_version 'cerulean'
game 'gta5'
lua54 'yes'
use_experimental_fxv2_oal 'yes'
author 'The Order of the Sacred Framework'
description 'A bridge made for the community to use as a base for their own projects. This bridge will allow a single format to work with nearly all commonly used systems while still offering expandability.'
version '0.0.10'
+48 -62
View File
@@ -1,79 +1,65 @@
Bridge = {
modules = {},
}
PlayerLoaded = false
PlayerIdentifier = nil
PlayerJobName = nil
PlayerJobLabel = nil
PlayerJobGradeName = nil
PlayerJobGradeLevel = nil
Bridge = {}
function Bridge.RegisterModule(moduleName, moduleTable)
if not moduleTable then
print("No moduleTable provided for module and no defaultsTable found: ", moduleName)
return
end
if Bridge[moduleName] then
print("Module already registered:", moduleName)
return
end
local wrappedModule = {}
for functionName, func in pairs(moduleTable) do
wrappedModule[functionName] = func
end
print("Registering module:", moduleName)
Bridge[moduleName] = wrappedModule
end
--TODO: Create a way to overide functions or create a new functions for module
Bridge.RegisterModule("Framework", Framework)
Bridge.RegisterModule("Inventory", Inventory)
Bridge.RegisterModule("Notify", Notify)
Bridge.RegisterModule("Utility", Utility)
Bridge.RegisterModule("Progressbar", Progressbar)
Bridge.RegisterModule("Clothing", Clothing)
Bridge.RegisterModule("Menu", Menu)
Bridge.RegisterModule("Language", Language)
Bridge.RegisterModule("Debugger", Debugger)
Bridge.RegisterModule("Doorlock", Doorlock)
Bridge.RegisterModule("Phone", Phone)
Bridge.RegisterModule("Vehicle", Vehicle)
Bridge.RegisterModule("Dispatch", Dispatch)
Bridge.RegisterModule("Weather", Weather)
Bridge.RegisterModule("Target", Target)
Bridge.RegisterModule("Table", Table)
Bridge.RegisterModule("Math", Math)
Bridge.RegisterModule("Prints", Prints)
Bridge.Inventory = Inventory
Bridge.Menu = Menu
Bridge.Language = Language
Bridge.Framework = Framework
Bridge.Doorlock = Doorlock
Bridge.Phone = Phone
Bridge.Notify = Notify
Bridge.Fuel = Fuel
Bridge.Dispatch = Dispatch
Bridge.Weather = Weather
Bridge.Target = Target
Bridge.Table = Table
Bridge.Input = Input
Bridge.Managment = Managment
Bridge.Math = Math
Bridge.VehicleKey = VehicleKey
Bridge.Clothing = Clothing
Bridge.Progressbar = Progressbar
Bridge.Utility = Utility
Bridge.Prints = Prints
CreateThread(function()
for k, v in pairs(Bridge) do
if type(v) == 'table' then
exports(k, function()
return v
for moduleName, moduleFunction in pairs(Bridge) do
if type(moduleFunction) == 'table' then
exports(moduleName, function()
return moduleFunction
end)
v.__index = function(key, value)
IndexingFallback(v, key, value)
end
else
exports(k, v)
exports(moduleName, moduleFunction)
end
end
end)
function IndexingFallback(module, k, v)
if not module[k] then
local func = Framework[k] and type(Framework[k]) == 'function' and Framework[k] or nil
return function(...)
return func(...)
end
end
return module[k]
end
OverRide = function(module, key, value)
module[key] = value
end
RegisterCompatibility = function(key, module)
module = module or {}
module.__index = IndexingFallback
module.OverRide = function(key, value)
OverRide(module, key, value)
end
Bridge[key] = module
end
exports('RegisterCompatibility', RegisterCompatibility)
exports('Bridge', function()
return Bridge
end)
if IsDuplicityVersion() then return end
-- Fill the bridge tables with player data.
function FillBridgeTables()
PlayerLoaded = true
PlayerIdentifier = Framework.GetPlayerIdentifier()
@@ -89,4 +75,4 @@ function ClearClientSideVariables()
PlayerJobGradeName = nil
PlayerJobGradeLevel = nil
StoredOldClothing = {}
end
end
+1
View File
@@ -1,6 +1,7 @@
Inventory = Inventory or {}
Inventory.GetItemInfo = function(item)
print('client funct')
return Framework.GetItemInfo(item)
end
+2 -2
View File
@@ -9,7 +9,7 @@ Inventory.RemoveItem = function(src, item, count, slot, metadata)
end
Inventory.GetItemInfo = function(item)
return false, Print.Error("This Inventory Has Not Been Bridged For An Item Info Feature.")
return false, print("This Inventory Has Not Been Bridged For An Item Info Feature.")
end
Inventory.GetItemCount = function(src, item, metadata)
@@ -25,7 +25,7 @@ Inventory.SetMetadata = function(src, item, slot, metadata)
end
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
return false, Print.Error("This Inventory Has Not Been Bridged For A Stash Feature.")
return false, print("This Inventory Has Not Been Bridged For A Stash Feature.")
end
Inventory.GetImagePath = function(item)
@@ -0,0 +1,7 @@
if GetResourceState('core_inventory') ~= 'started' then return end
Inventory = Inventory or {}
Inventory.TestFunction = function(item)
return 'test funct client inv'
end
@@ -0,0 +1,7 @@
if GetResourceState('core_inventory') ~= 'started' then return end
Inventory = Inventory or {}
Inventory.TestFunction = function(item)
return 'test funct server inv'
end