Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(8 edits) (+1)

Yes. There is a way to emulate that.

—————

test json, made for Noer Tavern Waifu. But we can add another barters to this file. And add more than one item to barters. Or we can do it in more than one file.

{
    "barters": [{
        "npc_name": "59_69",
        "items":  [{
            "item_name": "ItemSurBot", 
            "custom_price": null, 
            "price_mult": 1, 
            "rndMin": 1,
            "rndMax": 5
        }]
    }],
}


Test code:

module DataManager
    class << self
        alias_method :load_mod_database_TEST, :load_mod_database
    end
    
    def self.load_mod_database
        load_mod_database_TEST
        $TEST_mod_name = "Mod TEST"
        $TEST_modFolder = "ModScripts/_Mods/#{$TEST_mod_name}"
        $data_NameBarters_TEST = {}
        FileGetter.getFileList("#{$TEST_modFolder}/Data/Barters/*.json").each{|file|
            add_new_goods(file)
        }
    end
    
    def self.add_new_goods(path)
        temp_hash = nil
        
        begin
            temp_hash = JSON.decode(open(path).read)
        rescue 
            msgbox("Error in Json == [[ #{path} ]] :: def self.add_new_goods")
        end
        return if temp_hash == nil
        
        temp_hash["barters"].each{|barter|
            goods = []
            barter["items"].each{|item|
                item_name = item["item_name"]
                custom_price = item["custom_price"]
                price = (item["price_mult"])*($data_ItemName[item_name].price.to_i)
                minNum = item["rndMin"]
                maxNum = item["rndMax"]
                goods += [[*$data_ItemName[item_name].get_type_and_id, custom_price, price.round, Random.new.rand(minNum..maxNum) ]]
            }
            if $data_NameBarters_TEST[barter["npc_name"]] == nil
                $data_NameBarters_TEST[barter["npc_name"]] = goods
            else
                $data_NameBarters_TEST[barter["npc_name"]] += goods
            end
        }
    end
end
        
module GIM_ADDON
    
    alias_method :alias_manual_trade_TEST, :manual_trade unless method_defined?(:alias_manual_trade_TEST)
        
    def manual_trade(good,charStoreHashName=nil, charStoreTP=0, charStoreExpireDate=nil, noSell=false, noBuy=false)
        goods = $data_NameBarters_TEST["#{charStoreHashName}"]
        good += goods if goods != nil
        alias_manual_trade_TEST(good, charStoreHashName, charStoreTP, charStoreExpireDate, noSell, noBuy)
    end
        
end