Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

You must be 18+ to view this content

LonaRPG may contain content you must be 18+ to view.

The creator of this page has specified that it contains mature themes and content. Please enter your birthdate to verify you are 18 or older:

or Return to itch.io

For Modders. Simple way to overwrite strings by mod.

A topic by AleDerXan created Oct 31, 2024 Views: 684 Replies: 2
Viewing posts 1 to 3
(4 edits)

0.9.3.0 works.

0.9.4.0.2 works to.

This method allow to overwrite strings from "main game folder of Text" by similar folder from mod.
This method overwrite not a full files, but only existing strings in mod text files.
And after this, you can use $game_text for your custom mods translation and strings.
After this code game see your files not in modfolder, but in it's own text folder.

(9 edits)

In 09402 first version of code works propertly.  Second to. But i think that UMM don't. So second version isn't actual now.

(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