[go: up one dir, main page]

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

Add optional importing of variables/procedures #489

Open
phobos2077 opened this issue Aug 6, 2023 · 1 comment
Open

Add optional importing of variables/procedures #489

phobos2077 opened this issue Aug 6, 2023 · 1 comment
Labels

Comments

@phobos2077
Copy link
Collaborator
phobos2077 commented Aug 6, 2023

Need some ways to check if variable was exported before fetching/storing (and possibly crashing the script). This should allow for global scripts to communicate without hard requirements.

Concrete motivation for this: my damage mod script needs to read/write some data for other global script to use. But if these external vars doesn't exist, it can work normally as a stand-alone damage mod, because it doesn't depend on them.

@phobos2077
Copy link
Collaborator Author
phobos2077 commented Jun 3, 2024

So there's 2 ways to approach this (at least):

  1. Add new opcode/metarule to check if given exported var exists:
import variable super_var;
//...
value := super_var
   if external_var_exists(@super_var) // can use stringify operator here to not confuse ssl optimizer
   else 0;
  1. Change vanilla op_fetch_external to just print error and return 0 but continue script. op_store_external similarly can just print error and continue. Not sure how "correct" this is but it will solve the main issue. You can check against 0 to see if some variable was set or not.

@dekrus thoughts?

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

No branches or pull requests

1 participant