local gen = require("generalLibrary")
local function isInTradingHouseRadius(unit)
for _,nearbyTile in pairs(gen.getTilesInRadius(unit.location,2)) do
if nearbyTile.defender == unit.owner then
for nearbyUnit in nearbyTile.units do
if nearbyUnit.type == unitAliases.TradingHouse then
return true
end
end
end
end
return false
end
local function isInTradingHouseRadius(unit)
for nearbyUnit in gen.nearbyUnits(unit.location,2,unit.location.z) do
if nearbyUnit.type == unitAliases.TradingHouse then
return true
end
end
return false
end
local function isInTradingHouseRadius(unit)
local tribe = unit.owner
for otherUnit in civ.iterateUnits() do
if otherUnit.type == unitAliases.TradingHouse and
otherUnit.owner == tribe and
gen.distance(unit,otherUnit) <= 2 then
return true
end
end
return false
end
discreteEvents.onKeyPress(function(keyCode)
local unit = civ.getActiveUnit()
if keyCode == keyboard.two and unit.type == unitAliases.Paraibo and isInTradingHouseRadius(unit) then do
civ.ui.text("Testing!")
end
end
end)