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

Improve E2 Constants #2846

Merged
merged 2 commits into from
Nov 15, 2023
Merged

Improve E2 Constants #2846

merged 2 commits into from
Nov 15, 2023

Conversation

Vurv78
Copy link
Contributor

@Vurv78 Vurv78 commented Nov 13, 2023

  • Moved constant handling from tokenizer to compiler
  • Constants can now be these types: array vector angle string number (rather than just number and string)
  • Constants have descriptions in the E2Helper
  • Constants have extension filled in the E2Helper
  • Added _VECTOR_ORIGIN

E2Lib.registerConstant now takes a third optional parameter for the description of the constant for the E2Helper.

Note that arrays can only accept other vector/angle/string/number.

How it works

Basically

print(_VECTOR_ORIGIN)

Is the same as

print(vec(0, 0, 0))

This is also how it worked previously except it only accepted numbers and strings.

RFC

Any other constants to be added?

@thegrb93
Copy link
Contributor

Can you run functions using the constants? What prevents _VECTOR_ORIGIN:setX(23)?

@Vurv78
Copy link
Contributor Author

Vurv78 commented Nov 13, 2023

Can you run functions using the constants? What prevents _VECTOR_ORIGIN:setX(23)?

The constants desugar to creating the objects yourself, so they're practically C #defines. So you'd just be doing vec(0,0,0):setX(23) (although the set* functions don't actually mutate the object anyway)

@Denneisk
Copy link
Member

Vec origin should be vec() for optimization reasons but I understand that's not how it works here.
_ANGLE_ORIGIN = ang(0, 0, 0)
_VECTOR_UP = vec(0, 0, 1)

@Vurv78
Copy link
Contributor Author

Vurv78 commented Nov 15, 2023

Not sure about _ANGLE_ORIGIN as a name so I'm just going to add _VECTOR_UP for the time being, thanks

@Vurv78 Vurv78 merged commit 84f1f54 into wiremod:master Nov 15, 2023
1 check failed
@Vurv78 Vurv78 deleted the constants2 branch November 15, 2023 21:59
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

Successfully merging this pull request may close these issues.

3 participants