Skip to content

prcScript

Ben Hall edited this page Sep 3, 2019 · 8 revisions

prcScript provides a custom Lua environment to edit files.

example code:

Param.open_dir = "Path/To/Root/Folder/of/Game/Files"
Param.save_dir = "mods" -- can specify absolute or relative paths

local start = clock()

do
    local root = Param:open("fighter/common/param/fighter_param.prc")
    local t = root:by_label("fighter_param_table"):to_table()

    local mods = {
        mario = {
            scale = 2,
            jostle_weight = 0,
        },
        pikachu = {
            scale = 0.1,
            jump_count_max = 3,
            landing_attack_air_frame_n = 1
        }
    }

    do
        --convert the indeces of the table from strings to their hash
        local _mods = {}
        for name, t in pairs(mods) do
            _mods[hash("fighter_kind_"..name)] = t
        end
        mods = _mods
    end

    for _, p in ipairs(t) do
        local ft_kind_hash = p:by_label("fighter_kind").value
        local mod_table = mods[ft_kind_hash]

        if mod_table then
            for param_name, value in pairs(mod_table) do
                p:by_label(param_name).value = value
            end
        end
    end

    Param:save(root) -- saves to "mods/fighter/common/param/fighter_param.prc"
end

print("elapsed: "..clock() - start)
Clone this wiki locally