exportFunction: Difference between revisions

no edit summary
No edit summary
 
No edit summary
 
Line 9: Line 9:
|returnFail1 = void
|returnFail1 = void
|returnInfo = a boolean, indicating whether the function has been exported or not
|returnInfo = a boolean, indicating whether the function has been exported or not
|notes = To use this function in another resource, use [[findResourceByName|findResourceByName]] in the other resource, which returns a resource object. You can then use [[resource.exports|resource.exports]] or [[resource.getExport|resource.getExport]] to access exported functions.
|note1 = To use this function in another resource, use [[findResourceByName|findResourceByName]] in the other resource, which returns a resource object. You can then use [[resource.exports|resource.exports]] or [[resource.getExport|resource.getExport]] to access exported functions.
|note2 = Only simple types (string, number, boolean, null) are guaranteed to work across resource boundaries. Passing compound types (objects, arrays, tables) is discouraged — depending on the language combination involved, this may cause crashes or undefined behaviour. If structured data must be passed, serialize it to a JSON string before the call and deserialize on the receiving side.
|usage = export a function so it can be used in other resources
|usage = export a function so it can be used in other resources
|exampleJS = bindEventHandler("OnResourceStart", thisResource, function(event, resource) {
|exampleJS = bindEventHandler("OnResourceStart", thisResource, function(event, resource) {
     exportFunction("testFunc", testFunc);
     exportFunction("testFunc", testFunc);
});
});
function testFunc(foo, bar) {
function testFunc(foo, bar) {
     return true;
     return true;
}
}
}}
}}
emailconfirmed
99

edits