Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

Flufferbat

Help me stop picking up..

Recommended Posts

Flufferbat    0

Ok so I'm not a coder or anything but I like to fiddle with stuff so made this Mod: https://steamcommunity.com/sharedfiles/filedetails/?id=1702617912 

Anyway I want to get the orangeamulet AKA: The Lazy Forager to stop picking up certain stuff like Traps for eg.

My theory is i need to change the amulet.lua in prefabs and include that? but i'm not sure..

Any help would be greatly appreciated and yea i'l say you helped and link your profile or whatever lol :p

This just would be so much better if you didn't have to remove the amulet to go check your traps or place them even..

Share this post


Link to post
Share on other sites
Flufferbat    0

Is this what i need to change? or do i need to change the :TheSim:FindEntities files? (This is from the amulet.lua in the prefabs folder).

EDIT: I missed this bit off the top it says trap so hmm.. But um yea how do i add a changed version of it, I mean i know i have to put the files in my mod and reference them but do i just need the amulet.lua or more?

---ORANGE
local function SpawnEffect(inst)
    local pt = inst:GetPosition()
    local fx = SpawnPrefab("small_puff")
    fx.Transform:SetPosition(pt.x, pt.y, pt.z)
    fx.Transform:SetScale(0.5,0.5,0.5)
end

local function getitem(player, amulet, item)
    --Amulet will only ever pick up items one at a time. Even from stacks.
    SpawnEffect(item)
    amulet.components.finiteuses:Use(1)
    
    if item.components.stackable then
        item = item.components.stackable:Get()
    end

-- vv Its got to be this right? how do i change this so it doesn't pick them up at all?? also want to stop seeds being picked up

-- Also noticed it doesn't seem to do what it says and still picks up traps you just placed or that are not "sprung"

-- EDIT: I think maybe deleting this "item.components.trap and " might do it..

if item.components.trap and item.components.trap:IsSprung() then
        item.components.trap:Harvest(player)
        return
    end
    
    player.components.inventory:GiveItem(item)
end
-- ^^ bit i missed

local function pickup(inst, owner)
    local pt = owner:GetPosition()
    local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, TUNING.ORANGEAMULET_RANGE)

    for k,v in pairs(ents) do
        if v.components.inventoryitem and v.components.inventoryitem.canbepickedup and v.components.inventoryitem.cangoincontainer and not
            v.components.inventoryitem:IsHeld() then

            if not owner.components.inventory:IsFull() then
                --Your inventory isn't full, you can pick something up.
                getitem(owner, inst, v)
                return

            elseif v.components.stackable then
                --Your inventory is full, but the item you're trying to pick up stacks. Check for an exsisting stack.
                --An acceptable stack should: Be of the same item type, not be full already and not be in the "active item" slot of inventory.
                local stack = owner.components.inventory:FindItem(function(item) return (item.prefab == v.prefab and not item.components.stackable:IsFull()
                    and item ~= owner.components.inventory.activeitem) end)
                if stack then
                    getitem(owner, inst, v)
                    return
                end
            end
        end
    end
    
end

local function onequip_orange(inst, owner) 
    owner.AnimState:OverrideSymbol("swap_body", "torso_amulets", "orangeamulet")
    inst.task = inst:DoPeriodicTask(TUNING.ORANGEAMULET_ICD, function() pickup(inst, owner) end)
end

local function onunequip_orange(inst, owner) 
    owner.AnimState:ClearOverrideSymbol("swap_body")
    if inst.task then inst.task:Cancel() inst.task = nil end
end

Share this post


Link to post
Share on other sites
Flufferbat    0

Well i tried deleting "if item.components.trap and" also adding 

""PrefabFiles = {
    "amulet"

}""

to my file and added a prefabs folder with the new amulet.lua in the scripts folder didn't do anything, then i deleted the whole: 

if item.components.trap and item.components.trap:IsSprung() then
        item.components.trap:Harvest(player)
        return
    end

still didnt do anything lol..

Share this post


Link to post
Share on other sites
YiinHikari    29

Ummmm not clue about what you are doing, I mean not clue how to help you, but I will say that you may get more help if the post is more understandable. Try using the spoiler or other options you have to modify your future posts (or edit the previous ones if you like) to make more clear what is code, what is comment (inside the code), what is explanation, etc. I hope you acomplish what you are trying to do with this mod! Good luck!

Share this post


Link to post
Share on other sites
Flufferbat    0

Um.. right.. ok.. whatever.. don't really think I could be any clearer.. I mean honestly I even included the download link, like if you want to see the rest of the code why not just download it, also I can't see how this is confusing.. I said pretty clearly what I wanted..

Share this post


Link to post
Share on other sites