Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit)

Update. 09404

This def in original game in 09404 now the same as in UMM.

So second version of code now will works in 09404 and older versions of game.

And it's able to make it simplier. If remove from code support for older versions of the game.


class Text
    
    alias_method :alias_load_file_Orig_modname, :load_file unless method_defined?(:alias_load_file_Orig_modname)
    def load_file(part = nil, file)
        mod_file = File.exists?("#{$modname_modFolder}/#{@parts[part]}/#{file}.txt")
        orig_file = File.exists?("#{@parts[part]}/#{file}.txt")
        if mod_file && orig_file
            hashh = alias_load_file_Orig_modname(part, file).merge(load_file_mod_modname(part, file))
        elsif mod_file
            hashh = load_file_mod_modname(part, file)
        else
            hashh = alias_load_file_Orig_modname(part, file)
        end
        
        return hashh
    end
    
    def load_file_mod_modname(part = nil, file)
        begin
            sth=File.read("#{$modname_modFolder}/#{@parts[part]}/#{file}.txt")
            return parse(sth.to_s.encode("utf-8"))
        rescue => ex
            msgbox "ERROR: missing translation file #{$modname_modFolder}/#{@parts[part]}/#{file}.txt"
            return Hash.new
        end
    end
    
end