Selecting Your Buildings

I’m able to select my HQ, barracks, vehicle yards etc. by left clicking on them on the map. This method is OK but maybe not ideal when time is of the essence and your playing on a large map.

So I was wondering if there are any plans to eventually incorporate the building selection process into the build bar on the right hand side of the screen so that when you left click on, say, the build bar icon for your Flight Detection and Control Station it also selects it (bringing up the buildings details on the left side of the screen)? You could then quickly order in an air strike or assign a buildings initial waypoints without having to first find the building on the map.

Or maybe if someone could let me know which lua script to look in to find the function call that is used to select a building when you press mouse button one please? I could then experiment by adding the function call to gui_buildbar.lua to get the build bar to select a building when you left click on its icon, assuming of course that it’s OK to do that? I’ve tried looking in other s44 lua scripts for a piece of code that says something along the lines of - if mouse button one then select building and highlight - but I haven’t found anything yet.

Or maybe there’s another solution that I haven’t thought of?

At the moment and as a work around to selecting a building without having to left click on it I’m giving my buildings group numbers so that when I press 1 for example it selects my HQ, 2 my barracks, etc.

build bar widget can be considered to be 3rd party (if it were up to me, it would not be included in S44, hate the damn thing!) … _Selection

You’d have to track building of each type of factory and have a table of unitIDs so you could select them all, or cycle through or whatever.

An alternative strategy would be to take a look at the “selection buttons” widget. Could be modified reasonably easy to display factories instead (with the same issue of tracking creation/destruction), but you’ll need to find some screen space to put it. :wink:

Yes, I agree, the build bar isn’t ideal, are there any alternatives?

Thanks for the link and suggestions, it’s just what I need to get me started. I’m looking forward to finding a solution to quick factory selection.

Also worth looking at gui_plane_autoselect.lua widget, which tracks creation / loss of aircraft and allows selection in a similar way to selection buttons (they share a common codebase)

I think I may have found a solution to quickly selecting your factories/buildings no matter where you might be on the map without having to first find the factory before clicking on it.

What I did was to add a few lines of code to ‘function MenuHandler(x,y,button)’ in gui_buildbar.lua by jK.

This is the first time I’ve written any lua code so apologies in advance if I’ve made mistakes. I haven’t really had a chance to test it so feedback is welcome.

How to use -

When your playing a game and need to quickly select, say, your ‘Flight Detection and Control Station’ to call in some air support, all you need to do is left click on it’s icon on the build bar. The buildings order panel should then appear on the left side of the screen, allowing you to select the appropriate aircraft.

Thank you FLOZi for all your help, appreciated!

This is ‘function MenuHandler(x,y,button)’ in gui_buildbar.lua with the additions:

function MenuHandler(x,y,button)

  if button>3 then



  if button==1 then

    local icoRect = {}

    _,icoRect[2],icoRect[3],_ = GetFacIconRect(pressedFac)

      icoRect[1],icoRect[4]   = icoRect[3]-repIcoSize,icoRect[2]-repIcoSize

    if IsInRect(x,y, icoRect) then

      --repeat icon clicked

      local unitID = facs[pressedFac+1].unitID

      local ustate = GetUnitStates(unitID)

      local onoff  = {1}

      if ustate["repeat"] then onoff = {0} end

      Spring.GiveOrderToUnit(unitID, CMD.REPEAT, onoff, { })

      Spring.PlaySoundFile(sound_click, 0.97)

    else--if (bar_openByClick) then

      if (not menuHovered)and(openedMenu == pressedFac) then

        openedMenu = -1

        Spring.PlaySoundFile(sound_click, 0.9)


        menuHovered= false

        openedMenu = pressedFac



--lets you select a factory where ever you are on the map

--by left clicking the appropriate buidbar button

         unitID = facs[pressedFac+1].unitID

         local unitDefID = GetUnitDefID(unitID)

          if UnitDefs[unitDefID].isFactory then			




        Spring.PlaySoundFile(sound_click, 0.9)



  elseif button==2 then

    local x,y,z = Spring.GetUnitPosition(facs[pressedFac+1].unitID)


  elseif button==3 then

    Spring.Echo("BuildBar: Entered greedy waypoint mode")

    Spring.PlaySoundFile(sound_waypoint, 1)

    waypointMode = 2 -- greedy mode

    waypointFac  = openedMenu

    openedMenu   = -1

    pressedFac   = -1

    hoveredFac   = -1


    blured = false




Care to the whole thing? I’ll take a look over it and update the one in the repo. :wink:

Thanks. :slight_smile:

Thanks :wink: … ision=3410