I’m trying to get a ship to not show up in the build tree based on whether or not a research item has been granted. I was thinking of the HW1 research ships, but this one should be a lot simpler actually.
The background of why I even want to do that is:
The ship is a shipyard that should only be built by the AI in order to help balance out CPU skirmishes. The HW2 guys always trounce the HW1 guys, but in order to balance them out, the additional stuff would make them too mighty when a human was playing them. So the solution was to give them an extra build slot for big stuff in a shipyard that only they can build, and then the build speeds between the HW2 guys and the HW1 guys can be about the same.
Anyway, there’s a dummy research item called ‘BuildOff’ that gets granted to all CPU players so that the scripting can go off of that to control which ships to allow. using the ‘!’ modifier for the research and build LUAs, all of the ships and research items that should be available to CPU players or humans are set up and they all work.
I’d like to get this unavailable shipyard out of the build menu though:
The ship I want to remove is called Tai_Shipyard2.
This line is added to the SHIP file:
and this is the lua file in the ship folder:
function Remove_Shipyard(playerIndex) if Player_HasResearch(playerIndex, "BuildOff")==0 then Player_RestrictBuildOption(playerIndex, "Tai_Shipyard2") end end
I’ve tried some other stuff too, but it’s super not working.