mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

Add option to seal type in "setElementData"

Open CrosRoad95 opened this issue 2 years ago • 2 comments

CrosRoad95 avatar Nov 14 '24 17:11 CrosRoad95

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.

shadylua avatar Nov 14 '24 18:11 shadylua

  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.

CrosRoad95 avatar Nov 14 '24 18:11 CrosRoad95