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 option to seal type in "setElementData" #3856

Open
1 task done
CrosRoad95 opened this issue Nov 14, 2024 · 2 comments
Open
1 task done

Add option to seal type in "setElementData" #3856

CrosRoad95 opened this issue Nov 14, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@CrosRoad95
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Add another argument to setElementData like "bool sealType" which will make element data type can not be set after. For example:

setElementData(localPlayer, "number", 1,  sealType = true) -- initial set, everything okey
setElementData(localPlayer, "number", 2,  sealType = true) -- "seal" is ignored in this case, value changed to 2 because previously it was number, now this is number
setElementData(localPlayer, "number", false) -- error, unable to change because expected "number"
removeElementData(localPlayer, "number"); -- or destroy element to change element data type
setElementData(localPlayer, "number", false, sealType = true ) -- ok, now this is boolean
setElementData(localPlayer, "number", 1 ) -- error, expected boolean, got number

And make this hard error okey?

Describe the solution you'd like

don't use setElementData

Describe alternatives you've considered

don't use setElementData

Additional context

setElementData = evil, but i will propose more brillant improvments to this function that is root of most problems 😘

Security Policy

  • I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.
@CrosRoad95 CrosRoad95 added the enhancement New feature or request label Nov 14, 2024
@shadylua
Copy link
Contributor

hey the idea of adding a sealType option to setElementData seems really interesting and useful. It could be a good security measure to prevent potential errors when trying to accidentally change data types. I have a few questions:
The exact purpose and the conditions under which this sealType feature would be activated should be clarified.
For example:
1- What will happen if a new value is assigned to a sealed data type? Will it trigger a warning or an error?
2- Will this feature apply to all data types, or are you planning to use it only for specific types?

Defining these clearly will make both the development process and the documentation much easier.

@CrosRoad95
Copy link
Contributor Author

  1. trigger hard error
  2. apply only to lua types, number, string, table

First time element data get set should let you set type.
And indeed, it could decrease amount of errors you make, you may don't know that certain script set some element data incorrectly.

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

2 participants