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

Set variable in LuaFunction without using globals #102

Open
orange451 opened this issue May 19, 2022 · 1 comment
Open

Set variable in LuaFunction without using globals #102

orange451 opened this issue May 19, 2022 · 1 comment

Comments

@orange451
Copy link

I created a stackoverflow question here:
https://stackoverflow.com/questions/72307489/luaj-set-variable-in-luafunction-without-using-globals

I have a LuaFunction where in I will call the invoke() method and pass in some var-args. I wish to pass some data to this LuaFunction such that it can be referenced by the lua code as if it was a built-in variable.

For example, I want to have a variable named "script". When a script class executes its lua code, and it references the "script" value, I want it to represent that script object, but only for that lua code--I want no other lua code to be able to see this variable.

Currently, I am using Globals via:

globals.set("script", reference);
function.invoke(args);

Lua code:

print(script)
> "Script"

While this does work, I can reference "script" in my lua code, this also sets _G.script, which I do not like.

Does anyone have any ideas for this situation?

@orange451
Copy link
Author

Still unable to resolve this.

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

No branches or pull requests

1 participant