You cannot enforce how people want to write headers.
If you force them to write them as ruby, then you can at the very least parse it as ruby.
Are we talking bytes of "wasted" memory and nanoseconds of start-up time?
You cannot enforce how people want to write headers.
Are we talking bytes of "wasted" memory and nanoseconds of start-up time?
Indeed, one cannot enforce how to write a header. I guess if there was a 'standard' way of doing it, that most everyone incorporated, it would be highly useful for raising compatibility. But unless everyone adopted it, I dont really see any advantage - other than holding more detail in the $imported. Which - if you where the only one using it, would only cause yourself more workload...
class VersionObject attr_accessor :current_version attr_accessor :versions def initialize(name, current_version) @current_version = current_version @versions = [current_version] end # This is called when your object already exists. def add_version(version_int) @current_version = version_int @versions.push(version_int) end # Check if the currently installed script is the correct verison. def match?(checked_version) return (@current_version == checked_version) end # Check if the currently installed script is newer # than the one required in the function call. def older?(checked_version) return (@current_version < checked_version) end # Check if the currently installed script is newer # than the one required in the function call. def newer?(checked_version) return (@current_version > checked_version) end end$imported = {} if $imported.nil?if $imported["SomeRandomScript"].nil? $imported["SomeRandomScript"] = VersionObject.new("SomeRandomScript",1000)else $imported["SomeRandomScript"].add_version(1000)end$imported = {} if $imported.nil?if $imported["SomeRandomScript"].nil? $imported["SomeRandomScript"] = VersionObject.new("SomeRandomScript",1001)else $imported["SomeRandomScript"].add_version(1001)endif !$imported["SomeRandomScript"].nil? p "1.0.0.2 match? " + $imported["SomeRandomScript"].match?(1002).to_s p "1.0.0.2 newer? " + $imported["SomeRandomScript"].newer?(1002).to_s p "1.0.0.2 older? " + $imported["SomeRandomScript"].older?(1002).to_sendclass TestClassA def initialize @bacon = "tasty" end endclass TestClassB < TestClassA attr_reader :bacon @test = $imported["SomeRandomScript"] if @test.match?(1001) def initialize @bacon = "bacon" end else def initialize @bacon = "taco" end end end$durka = TestClassB.newp $durka.bacon
Its not like you need to organize your classes like that, it was just an example. A fairly lazy one.
durka = TestClassB.newp durka.bacon
I usually program in globals when I'm making examples of objects to access elsewhere.
Original thread: https://forums.rpgmakerweb.com/threads/improving-imported-7-23-update-start-suggesting-keys-values.30078/