- Joined
- Mar 17, 2012
- Messages
- 1,220
- Reaction score
- 152
- Primarily Uses
The $imported variable. I wasn't always a huge fan of it... until I made a topic questioning why scripters use it. Once I read the responses to it, I understood its purpose. Since then, I grew to love it for the usefulness it provides. It makes for a great way to check if certain scripts were imported and provide some workarounds or expanded options based around that. Until I started thinking about the things it lacked, such as version checking.
When you think about it, doesn't this seem a little redundant?
$imported[:hello_world] = true
Especially when you could check if the key exists by using this?
Why don't we start doing more with it? Let's expand the number of ways a scripter can check for another user's imported scripts. Let's add some data to our keys. Let's start doing things like this:
If anyone (scripters especially) is for this idea, we could get started on putting together suggestions on making $imported better. Let's come up with some implementations we can all agree upon and use for our scripts.Edit: If anyone would like to lead the discussion, that would be nice.
Edit 2: I never explained why using a hash instead of a boolean value for our $imported keys would be beneficial to us.
For one, we can store information about our scripts into our hashes. If this were to be widely adopted by the community, the implementations of certain name/value pairs we can think of and mostly agree on would provide scripters an array of new options they can use to check for compatibility with their own scripts along with other submitted scripts. You do not have to use these new options for compatibility checks if you don't want to. You would still be able to determine if a script is imported by checking if $imported has a particular key you're looking for stored in its hash.
Two, scripters may be able to use all of this new information to their advantage by creating scripts and snippets centered around the $imported variable. For example, a script logger.
Three, if we were to use hashes for our keys instead of boolean values, the door would always be open for discussions and share new ideas on what we can do to further expand and improve $imported.
When you think about it, doesn't this seem a little redundant?
$imported[:hello_world] = true
Code:
if $imported[:hello_world]
Code:
$imported.has_key?(:hello_world)
Code:
$imported[:hello_world] = { :key1 => value1, :key2 => value2, :key3 => value3}
Edit 2: I never explained why using a hash instead of a boolean value for our $imported keys would be beneficial to us.
For one, we can store information about our scripts into our hashes. If this were to be widely adopted by the community, the implementations of certain name/value pairs we can think of and mostly agree on would provide scripters an array of new options they can use to check for compatibility with their own scripts along with other submitted scripts. You do not have to use these new options for compatibility checks if you don't want to. You would still be able to determine if a script is imported by checking if $imported has a particular key you're looking for stored in its hash.
Two, scripters may be able to use all of this new information to their advantage by creating scripts and snippets centered around the $imported variable. For example, a script logger.
Three, if we were to use hashes for our keys instead of boolean values, the door would always be open for discussions and share new ideas on what we can do to further expand and improve $imported.
Last edited by a moderator:

