Hiding Posted April 4, 2023 Share Posted April 4, 2023 Hello, how to call a function from another resources, for example I have a resource called "one-resource", which contains a function called firstFunction(). How do I get access to this function from the other resource called "second-resource"? Link to comment
FLUSHBICEPS Posted April 4, 2023 Share Posted April 4, 2023 in the resource with the function u need to add the function to the exports in meta.xml <export function="firstFunction" type="server" /> in the second resource use the call function to access the exported function local oneResource = getResourceFromName("one-resource") local result = call(oneResource, "firstFunction", arg1, arg2, ...) just make sure one resource is running before calling its functions from second resource 1 Link to comment
AngelAlpha Posted April 5, 2023 Share Posted April 5, 2023 (edited) in the one-resource add to meta <export function="firstFunction" type="server"/> <!-- if function on server side --> <export function="firstFunction" type="client"/> <!-- if function on client side --> <export function="firstFunction" type="shared"/> <!-- if function can used on server and client side --> and in two-resource use exports["one-resource"]:firstFunction( [args] ) -- or exports.one-resource:firstFunction( [args] ) Edited April 5, 2023 by AngelAlpha 1 Link to comment
Hiding Posted April 5, 2023 Author Share Posted April 5, 2023 Thank you guys so much, I already get it Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now