Buildinghelper - abort building

edited July 2015 in Questions

I'm trying to stop people building in an area of my TD map - I've managed to block the area with an entity and detect if that entity is present but I can't figure out how to tell buildinghelper to not create the ghost particle and/or abort building.

Heres my current code:

keys:OnBuildingPosChosen(function(vPos)
        --print("OnBuildingPosChosen")
        -- in WC3 some build sound was played here.
        -- check if in no build trigger
        local inTrigger = false
        local CHECKINGRADIUS = 10

        for _,thing in pairs(Entities:FindAllInSphere(vPos, CHECKINGRADIUS) )  do
            if (thing:GetName() == "no_build") then
                 inTrigger = true
                 print("no place here")
            else
                 inTrigger = false
                 print("ok to place here")
            end

            if (inTrigger == true) then
                FireGameEvent( 'custom_error_show', { player_ID = pID, _error = "Building cannot be placed there!" } )
            --cancel building
            print("cancelled")
            return
            end
        end

    end)

I chose to put it in this function because this occurs when you click which 'feels' correct.

I thought return would kill it but I guess its inside another function, that would probably leave the building ghost lingering too; any ideas?

Comments

  • Posts: 1,670

    The version of BuildingHelper using Scaleform is deprecated. Try the updated version here: https://github.com/snipplets/Dota-2-Building-Helper

    That being said, old BH managed the building positions way before they were placed, and OnBuildingPosChosen is not the proper place to check if the position is correct, chosen mean the position is correct and you can proceed with other orders (like moving allies away from the building position).

    Anyway, the new version is using the new functions added GridNav:IsBlocked(pos) and GridNav:IsTraversable(pos) which makes preventing placements way easier.

    The concept of Modding Community doesn't go well together with Competitive Business
    My Project Page || My GitHub Profile ||

  • Posts: 11

    Think I'm using the newest version, I want to stop building in my lanes so I can't use the navgrid (i think?); I'll attempt to put my blocking logic into action!