Jump to content

Recommended Posts

currently, i'm trying to look into how to make it possible to wield Lucy as other characters. there are several other mods that do this, but they seem to just give others the necessary "woodcutter" tag, but this tag also gives Woodie's increased chopping speed which isn't quite what i was looking for in this instance. so i wanted to take a look into how exactly Lucy's code prevents others from picking her up.

i found this function in possessedaxe.lua:

local function IsValidOwner(inst, owner)
    return owner:HasTag("woodcutter")
end

which is later referenced to check whether or not the player picking Lucy up is woodie (because no other character has the "woodcutter" tag), such as here, where it forcibly drops her out of the player's inventory if they don't have the woodcutter tag:

local function OnCheckOwner(inst, self)
    self.checkownertask = nil
    local owner = inst.components.inventoryitem:GetGrandOwner()
    if owner == nil or owner.components.inventory == nil then
        return
    elseif not IsValidOwner(inst, owner) then
        self:Drop()
        inst:PushEvent("axerejectedowner", owner)
    else
        local other = OwnerAlreadyHasPossessedAxe(inst, owner)
        if other ~= nil then
            self:Drop()
            other:PushEvent("axerejectedotheraxe", inst)
        elseif owner:HasTag("player") then
            self:LinkToPlayer(owner)
        end
    end
end

i was thinking if i could modify the IsValidOwner function to include certain other character tags (such as "bernieowner" or "soulstealer"), then it'd let them pick Lucy up as well without giving them the benefits of the "woodcutter" tag

im quite inexperienced with LUA code, though, and i was having difficulty figuring out how exactly to modify the function. any help would be much appreciated!

You can do this by adding the tag "woodcutter" to the players when put lucy axe into inventory and remove it in a flash.

local function OnChangeOwner(inst, owner)
    if not owner:HasTag("woodcutter") then
        owner:AddTag("woodcutter")
        owner:DoTaskInTime(0.2, function() owner:RemoveTag("woodcutter") end)
    end
end

AddPrefabPostInit("lucy", function(inst)
    inst:ListenForEvent("onputininventory", OnChangeOwner)
end)
  • Like 2
9 hours ago, yanecc said:

You can do this by adding the tag "woodcutter" to the players when put lucy axe into inventory and remove it in a flash.

local function OnChangeOwner(inst, owner)
    if not owner:HasTag("woodcutter") then
        owner:AddTag("woodcutter")
        owner:DoTaskInTime(0.2, function() owner:RemoveTag("woodcutter") end)
    end
end

AddPrefabPostInit("lucy", function(inst)
    inst:ListenForEvent("onputininventory", OnChangeOwner)
end)

that works perfectly, thank you so much!

i am quite curious if the initial way i was trying to do it is possible if a bit more convoluted?

Edited by crushcircuit

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...