Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement to exports #345

Open
CrosRoad95 opened this issue Aug 26, 2018 · 4 comments
Open

Improvement to exports #345

CrosRoad95 opened this issue Aug 26, 2018 · 4 comments
Labels
enhancement New feature or request
Milestone

Comments

@CrosRoad95
Copy link
Contributor

CrosRoad95 commented Aug 26, 2018

Is your feature request related to a problem? Please describe.
I want to improve exports because are very neglected.
List of ideas i would add/change in current export system.

  1. meta.xml contain static exports list. You can manipulate exports list via mta functions.

  2. you can export functions in table using dot. example:
    <export function="myFunctions.func1" type="shared"/>
    and you can use this by
    call( resource, "myFunctions.func1", arg1, arg2, ... )

  3. you can export variables too ( in table too like above ). <export variable="variableName" type="shared" readonly="true"/> readonly argument means do you can overwrite this variable

  4. event called every exported variable changed. cancelEvent makes that variable will not change

  5. functions to manipulate exports:
    addExport( function/string theFunction [, bool readOnly = true ] ) -- for adding new exports, script will detect if this is function or variable. if you provide function, script check function name, and do this function is in table. If you provide table, then all function and variables will be added.
    deleteExport( function/string theFunction ) -- for deleting exports. * cause delete every exports
    getVariable( resource, variableName ) -- return value under variable in other resource
    setVariable( resource, variableName, newValue ) -- set value under variable in other resource. Return false if variable is readonly.
    event: onVariableChanged with arguments: variableName, oldValue, newValue and source = source of change.

  6. Make possible to exports memes.

if you have suggestion, please describe in comment.

@znvjder
Copy link
Contributor

znvjder commented Aug 26, 2018

Currently exports are interpreted by lua code so it can be slower than call().
The OnVariableChanged event is purely technically useless, it would only spam with newly created variables.
Just add require function or something that. Loads resource and you can read code from it, something like headers in cpp.

@qaisjp qaisjp added the enhancement New feature or request label Aug 27, 2018
@botder botder added this to the Backlog milestone Mar 3, 2019
@Pirulax
Copy link
Contributor

Pirulax commented Nov 13, 2020

Adding 'onVariableChanged' is near to impossible, as simple variables dont have metatables.
The only way would be to force variables to be declared as global, because then they'd be in _G to which we can add a metatable, atlough that would slow thing down a lot, so.. Not recommended.

I think the variable change side of this issue can be closed.

As for the addExport and deleteExport part:
Not a bad idea, but I dont see any benefit from it.
Could you give us some examples where it would be useful?

@botder
Copy link
Member

botder commented Aug 10, 2021

Is this feature still needed or can this be closed?

@thisdp
Copy link
Contributor

thisdp commented Feb 10, 2022

Adding 'onVariableChanged' is near to impossible, as simple variables dont have metatables. The only way would be to force variables to be declared as global, because then they'd be in _G to which we can add a metatable, atlough that would slow thing down a lot, so.. Not recommended.

I think the variable change side of this issue can be closed.

As for the addExport and deleteExport part: Not a bad idea, but I dont see any benefit from it. Could you give us some examples where it would be useful?

to prevent meta.xml from thousands of lines just for exporting functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants