Problem with counting in inventory items


PuffinBy
  • Pending

1: In prefabs, evergreen, line 707,

Spoiler

local function OnTimerDone(inst, data)
    if data.name == "decay" then
        -- before we disappear, clean up any crap left on the ground -- too
        -- many objects is as bad for server health as too few!
        local x,y,z = inst.Transform:GetWorldPosition()
        local ents = TheSim:FindEntities(x,y,z,6)
        local leftone = false
        for k,ent in pairs(ents) do
            if ent.prefab == "log"
                or ent.prefab == "pinecone"
                or ent.prefab == "charcoal" then
                if leftone then
                    ent:Remove()
                else
                    leftone = true
                end
            end
        end

        inst:Remove()
    end
end

 

the stump decay function not only removes logs, pinecones, charcoals on the ground, but also those in nearby containers and even the ones in players' inventory who happen to pass by.

 

Spoiler

before 

20180316122528_1.thumb.jpg.1ffb8260350906cf2d63362a0047b698.jpg

after

20180316122542_1.thumb.jpg.979b85f43106c8a143f3787baf120313.jpg

 

2: In butterflyspawner component, line 44. 

This function doesn't sort out butterflies in player's inventory or any container.

Spoiler

local function SpawnButterflyForPlayer(player, reschedule)
    local pt = player:GetPosition()
    local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, 64, { "butterfly" })
    if #ents < _maxbutterflies then
        local spawnflower = GetSpawnPoint(player)
        if spawnflower ~= nil then
            local butterfly = SpawnPrefab("butterfly")
            if butterfly.components.pollinator ~= nil then
                butterfly.components.pollinator:Pollinate(spawnflower)
            end
            butterfly.components.homeseeker:SetHome(spawnflower)
			-- KAJ: TODO: Butterflies can be despawned before getting to the rest of the logic if this is above the homeseeker
            butterfly.Physics:Teleport(spawnflower.Transform:GetWorldPosition())
        end
    end
    _scheduledtasks[player] = nil
    reschedule(player)
end

 

So, butterfly will not spawn for you, if you have 4 stacks of butterflies, no matter the size of each stack.

20180316115823_1.thumb.jpg.0ed2a23639085ff7dc25076b0c481c83.jpg


Steps to Reproduce
1, build a chest near a stump, put logs pinecones in, let the stump decay(I used c_select():PushEvent("timerdome",{name = "decay"}) ). Then logs in chest is gone. 2, get four stacks of butterfly and stand near some flower. See no more butterfly spawns.
  • Like 1
  • Thanks 1


User Feedback




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