I understand the limitations (I don't necessarily agree with them all) but exposing the pre-create event constant will do nothing for this as all it does is exposes an event (that is compiler generated) that is intended to be called before the create event is called so pre_create is intended to go hand in glove with the create event (pre_create is called before the create event, for the avoidance of doubt). I do not see how exposing a constant (that is all the value is) would help in any case (it is 14 btw fact fans) It is not intended to be called in any other way.
instance_change
and
instance_copy
can both induce situations where both the Pre-Create and Create events are bypassed. If only the Create event is exposed, there would be a way to fill in for missed Create events, but no way to fill in for missed actions from the Pre-Create event (e.g. important variable definitions in Object Variables).
Personally I would prefer to allow a struct to be passed into the instance_create_* functions the contents of which would cloned into the instance before the create event is called - which from what I know would satisfy the requirements that I have seen.
That would satisfy the use case I presented in this topic, but it may not be a simple clone if the struct contains methods and issues with method ownership are involved. If you look in the demo, I rebind all methods owned by the struct to the created instance, but not methods owned by other things.
In any case, I would love to see a built-in solution to the 20-plus-years-old "pass variable to Create event" issue. Would you be willing to look into it soon, if I file a ticket for it now?
I am also not sure if that would satisfy the use case that YellowAfterlife mentioned in
his reply. This is the library that he is apparently using it in:
GMRoomPack
Yes this is not a legal id (they must be of the same form as all variables i.e. they can start with anything in the set ['_', 'a'-'z', 'A'-'Z',] followed by any number of chars in the set ['_', 'a'-'z', 'A'-'Z', '0'-'9']
Quite frankly, this is something that I would rather see NOT checked anymore, as per the previous beta.
Please DO NOT step up enforcement of these standards in struct keys when they are provided as strings. In fact, please step it down to the minimum possible.
JSON is a major use case for untyped structs and the struct literal syntax. The literal syntax should be at parity with the
[$ ]
accessor when the key is specified as a string (i.e. accepts the same range of things), but in 2.3.7 and below it is not, and it has been a significant pain point. We end up needlessly splitting a definition into two parts, those with "GML legal" keys in a literal, followed by "GML illegal" keys in a bunch of accessors that follow. The behaviour in the previous beta was an answer to a request I made some time ago (#178377), and now it has slipped from our grasps again.
The JSON standard does NOT have demands like what you stated on keys, the only condition is that they are valid strings. Many JSON-based standards, such as linked data, have keys like
@context
and
@id
, and being able to build structs containing those in literal form is useful for API work. Many game-related APIs also use
score
as a key, something that the unquoted struct literal syntax wouldn't allow (i.e.
{ score: 475 }
is currently illegal). Quoted struct keys should allow us direct access to these and more, and they should not be synthetically handicapped.