multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.41k stars 438 forks source link

Extend exporting (variable exporting) #311

Closed CrosRoad95 closed 6 years ago

CrosRoad95 commented 6 years ago

Is your feature request related to a problem? Please describe. My idea is to make possible export variables, for read and write. Yes, i already can export variable by using functions.

Describe the solution you'd like New new attribute: <export type="variable" name="variableName" readOnly = "true" /> readOnly = true by default.

New Functions:

mixed value = getVariable( resource, variableName )
bool success = setVariable( resource, variableName, value ) -- return false if is read only.

New event:

"onVariableChanged" with attributes; source of change, resource, variable name, old value, new value

Describe alternatives you've considered There's no alternatives.

Additional context

Pirulax commented 6 years ago

If Im not mistaken, every resource has its own luaVM which means, that "exporting" variables'd be slow, just like the normal call() function

qaisjp commented 6 years ago

Correct

On Wed, Aug 8, 2018, 4:32 PM Pirulax notifications@github.com wrote:

If Im not mistaken, every resource has its own luaVM which means, that "exporting" variables'd be slow, just like the normal call() function

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/multitheftauto/mtasa-blue/issues/311#issuecomment-411449098, or mute the thread https://github.com/notifications/unsubscribe-auth/AA4WajDlX5k2aLTMrrERHLacrMy89QbVks5uOwSkgaJpZM4VyB4L .

Pirulax commented 6 years ago

Maybe use setElementData as a variable, that's faster if you want a 'very' global(TM) variable.

jushar commented 6 years ago

It doesn't introduce new capabilities and might be rather confusing considering that there are exports already.