Jump to content

#[string "scripts/components/container_replica.lua"]:291: attempt to call method 'HasItemWithTag' (a nil value)


ZeroCiel
  • Fixed

When I try to use 【replica.Container: HasItemWithTag (" Musha_forge_fuel ", 1)】

The game crashed.

Also, When I try to use  [doer.replica.inventory:HasItemWithTag("Musha_forge_fuel", 1)]

The game crashed.

The code like this

local function FindForge(inst)
    local ForgeTAG = {"musha_forge"}
    local Forge = FindEntity(inst, 6, nil, ForgeTAG)

    return Forge and not Forge:HasTag("CAN_FORGE")
end

AddComponentAction(
    "INVENTORY",
    "inventoryitem",
    function(inst, doer, actions, right)
        if FindForge(inst) and inst.replica.inventoryitem and inst.replica.equippable and inst:HasTag("musha_armor_forge") and doer.replica.inventory:HasItemWithTag("Musha_forge_fuel", 1) then
            local item = doer.replica.inventory:GetEquippedItem(EQUIPSLOTS.BODY)
            if item and item.replica.container and not item.replica.container:HasItemWithTag("Musha_forge_fuel", 1) then
                table.insert(actions, ACTIONS.MUSHA_ARMOR_FORGE)
            elseif not item then
                table.insert(actions, ACTIONS.MUSHA_ARMOR_FORGE)
            end
        end
    end
)

This problem occurs when a player has a backpack.

01.thumb.png.73b25dae87f11b77a0c9533396a070fe.png

 

02BUG.png

03.png


Steps to Reproduce

use 【doer.replica.inventory:HasItemWithTag(tag, amount) or inst.replica.container:HasItemWithTag(tag, amount】

hmm...Did you need more?




User Feedback


A developer has marked this issue as fixed. This means that the issue has been addressed in the current development build and will likely be in the next update.

One thing to notice is that

This file(container_classified) is missing (inst.HasItemWithTag = HasItemWithTag)

But inventory_classified has this code.

I tried to add this part of code to it, but it still went crash.

So I'm not sure If I did this right

Edited by ZeroCiel

Share this comment


Link to comment
Share on other sites



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