Jump to content

Recommended Posts

I'm wanting to add a few things to my character

I'd like to add something that prevents him from wearing body armor and equipping weapons

I'd like something that gives him a light aura at 25% and above

And I'd like to know how to add food restrictions, he can only eat living creatures (like captured ones)

Thanks!

21 hours ago, AVoraciousLatia said:

I'm wanting to add a few things to my character

I'd like to add something that prevents him from wearing body armor and equipping weapons

I'd like something that gives him a light aura at 25% and above

And I'd like to know how to add food restrictions, he can only eat living creatures (like captured ones)

Thanks!

I won't be able to give you a copy paste code answer, but I can give you an idea on how to go about the equipment.

So with equipment you'll need to setup a listener on your character to know when they've equipped something. I believe there should be a listener you can use in the equippable.lua component. Once you have your listener setup you'll need to determine if the item being equipped is a weapon or armor. This part is tricky as anything that goes into the handslot can used as a weapon such as an axe since it uses the weapon component. I think the easiest way is to create a table of each item you want to check and perform a for loop to check if the equipped item is inside your table. If it is then toss it on the ground.

Here's a rough example

local function check_equip(inst)
    local equips = {}
    equips[1] = "axe"
    equips[2] = "spear"

    for key, value in pairs(equips) do
        if value == inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) then
            --drop the item
        end
    end
end

Hopefully this gets you in the right direction and helps out.

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