Jump to content

Recommended Posts

You mean modifying the function CanMorph? If you don't want to replace the entire prefabs/chester.lua, then you'll have to use upvalue hacking.

You can reach CanMorph through inst.MorphChester. Rezecib's upvalue hacker is here. Put that in your mod's scripts/tools, then you can do:

local UpvalueHacker = require("tools/upvaluehacker")

local function yourCanMorphFunction(inst)
    --your modified version of CanMorph
end

AddPrefabPostInit("chester", function(inst)
    if inst.MorphChester then --this is set to nil in DoMorph
        UpvalueHacker.SetUpvalue(inst.MorphChester, yourCanMorphFunction, "CanMorph")
    end
end)

You can name your custom function "CanMorph" instead of "yourCanMorphFunction". I just named it that for clarity.

Edited by Bumber64
16 hours ago, Bumber64 said:

You mean modifying the function CanMorph? If you don't want to replace the entire prefabs/chester.lua, then you'll have to use upvalue hacking.

You can reach CanMorph through inst.MorphChester. Rezecib's upvalue hacker is here. Put that in your mod's scripts/tools, then you can do:


local UpvalueHacker = require("tools/upvaluehacker")

local function yourCanMorphFunction(inst)
    --your modified version of CanMorph
end

AddPrefabPostInit("chester", function(inst)
    if inst.MorphChester then --this is set to nil in DoMorph
        UpvalueHacker.SetUpvalue(inst.MorphChester, yourCanMorphFunction, "CanMorph")
    end
end)

You can name your custom function "CanMorph" instead of "yourCanMorphFunction". I just named it that for clarity.

thank you!

19 hours ago, Bumber64 said:

You mean modifying the function CanMorph? If you don't want to replace the entire prefabs/chester.lua, then you'll have to use upvalue hacking.

You can reach CanMorph through inst.MorphChester. Rezecib's upvalue hacker is here. Put that in your mod's scripts/tools, then you can do:


local UpvalueHacker = require("tools/upvaluehacker")

local function yourCanMorphFunction(inst)
    --your modified version of CanMorph
end

AddPrefabPostInit("chester", function(inst)
    if inst.MorphChester then --this is set to nil in DoMorph
        UpvalueHacker.SetUpvalue(inst.MorphChester, yourCanMorphFunction, "CanMorph")
    end
end)

You can name your custom function "CanMorph" instead of "yourCanMorphFunction". I just named it that for clarity.

This made my game stuck at "Launching server..." and lagged my PC so much :(
Repeated it 3 times... Removing this code form from my mod gets it back to normal... Any ideas?

The logs file went up to 1+ GB. No kidding.

I really wanna make upvalue hacker work. Even though I'm not sure how exactly I can modify local functions with it in prefab files (without replacing them)

Edited by GrowthMindset

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...