-
Notifications
You must be signed in to change notification settings - Fork 162
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
Script API: implemented ScriptName and Type.GetByName() for all applicable types. #2011
Script API: implemented ScriptName and Type.GetByName() for all applicable types. #2011
Conversation
Something for a distant future, but in a conversation we had with @AlanDrake , I realized this or similar methods may be used to initialize global variables in case we completely move to dynamic creation of everything. Imagine the game data was loaded, and objects defined at design-time created, but how do you attach them to the variables to keep things consistent with objects created at runtime? Possibly that's how:
|
I think (More similar to the GetAtRoomXY/GetAtScreenXY methods) |
143e2ff
to
fea2cfd
Compare
Renamed FindByName -> GetByName. |
In regards to getting script names from these objects; I've been thinking of quickly adding a readable ScriptName property to all of them, but then thought to instead delay that, and experiment with creating the most basic parent class which would hold this property, thus avoiding duplicate API. Something like
(which will be the first tiny step to #1228) EDIT: |
fea2cfd
to
c6bd7eb
Compare
Note: removed Region.GetByName, realizing that regions don't have script names for some reason... |
This implements readonly ScriptName property and a static GetByName() method for all the object types that have script names. The method looks up for the object of corresponding type with the given script name, and returns its pointer, or null if such object is not found.
NOTE: passing other type's script name will also return null, for example calling Character.GetByName() with a room object's name.
scriptName
argument is case-sensitive, obviously.