Jump to content

file: unable to load file.


marcelluss

Recommended Posts

Hello, I made a system in the likeness of a bridge - the essence is to get functions and so on from one resource for use in another (I did this in order to use my libraries) - the problem is that there are two functions for registering a file and getting it ( using)

I do this and debaging everything, the path she gets an example :shadow_fonts/client.lua - but when using this path, file Open gives an error that it cannot find the path to the file, I rechecked the correctness of the name 100 times when registering the file and the path to the folder, but not to which one.

 

ShadowBridge = {
    ShadowBridgeData = {};
    --[[void]] ShadowBridge = function(this)
        print("[ShadowBridge] Bridge constructor succesfull started!");
    end,
    --[[bool]] Export = function(this, p_tree, src, path)
        local fullpath_to_file = (":"..p_tree.name.."/"..path);
        --print(fullpath_to_file);
        if not (fileExists(fullpath_to_file)) then
            return false;
        end

        this.ShadowBridgeData[src] = {
            --[[Resource]] parent = p_tree,
            --[[String]] src = src,
            --[[String]] full_path = fullpath_to_file,
        }

        print(inspect(this.ShadowBridgeData))

        return true;
    end,
    --[[string]] Import = function(this, src)
        local file = fileOpen(this.ShadowBridgeData[src].full_path);
        print(this.ShadowBridgeData[src].full_path)
        local rawdata = fileRead(file, fileGetSize(file)); fileClose(file);
        return rawdata;
    end,
}

--[[Raw Code]] function GetBridge()
    return [[
        function using(src_name)
            loadstring(exports.shadow_framework:Import(src_name))();
        end
        function bridge_register(src_name, file_path)
            return exports.shadow_framework:Export(src_name, file_path)
        end

    ]]
end

--[[String]] function Import(src_name)
    return ShadowBridge:Import(src_name);
end

--[[Bool]] function Export(src_name, file_path)
    return ShadowBridge:Export(sourceResource, src_name, file_path);
end

 

example usage : imagine that I have a fonts client resource and a client.lua file

-- client --

loadstring(exports.shadow_framework:GetBridge())();
bridge_register("fonts", "client.lua");

function test()
    print("hello world")
end

 

now the second example in another script, let's say main and the client.lua file - ( note that the client part is also where I want to use functions from another script )

-- client --

loadstring(exports.shadow_framework:GetBridge())();
using "fonts"

 

but it gives the following errors

https://imgur.com/a/TOYMa7k

 

and yes, by the way, here are more places of the bridge resource

<meta>
    <script src="framework_bridge.lua" type="shared" />

    <export function="Import" type="server" />
    <export function="Import" type="client" />

    <export function="Export" type="server" />
    <export function="Export" type="client" />

    <export function="GetBridge" type="server" />
    <export function="GetBridge" type="client" />

    <oop>true</oop>
</meta>

 

Edited by marcelluss
Link to comment
  • Moderators
10 hours ago, marcelluss said:

I rechecked the correctness of the name 100 times when registering the file and the path to the folder, but not to which one.

clientside or serverside?

Where did you transfer the file to clientside btw? If you are going to share things, for clientside and serverside, then make sure that both directories got the file.

Link to comment
11 hours ago, IIYAMA said:

clientside or serverside?

Where did you transfer the file to clientside btw? If you are going to share things, for clientside and serverside, then make sure that both directories got the file.

I apologize for my English, maybe I expressed myself incorrectly. I'm not trying to get the code from the client side to the server side or vice versa! the file from where I got the code and the code from the file from where I used it were both on the client side. But I have already fixed these errors, and to be more precise, somehow the error disappeared after restarting the server, but after that I ran into the problem of loading loadstring using the function, but I solved this problem as well. For some reason, when using the register_bridge function, I kept a path with a different resource name example [my resource was called shadow_fonts] - and it placed shadowfonts in the table. Well, again, I fixed that, too.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...