Hugh Heggen
Chieftain
Hi
I wish to have a building in my mod require that the city be next to a forest.
I have fiddled with a lua file from a lighthouse mod written by SushiSquid but as I have really no idea what I'm doing I would like some help in finishing the lua.
And lastly to make the lua active do I need to import it into VFS or add it in the actions or contents tabs?
I wish to have a building in my mod require that the city be next to a forest.
I have fiddled with a lua file from a lighthouse mod written by SushiSquid but as I have really no idea what I'm doing I would like some help in finishing the lua.
Code:
local iCharcoal = GameInfoTypes.BUILDING_CHARCOAL_FURNACE
local iForest = GameInfoTypes.FEATURE_FOREST
directions = {DirectionTypes.DIRECTION_NORTHEAST, DirectionTypes.DIRECTION_EAST, DirectionTypes.DIRECTION_SOUTHEAST,
DirectionTypes.DIRECTION_SOUTHWEST, DirectionTypes.DIRECTION_WEST, DirectionTypes.DIRECTION_NORTHWEST}
GameEvents.CityCanConstruct.Add(function(iPlayer, iCity, iBuilding)
if (iBuilding == iCharcoal) then
local pCityPlot = Players[iPlayer]:GetCityByID(iCity):Plot()
end
return false
end
return true
end)
function local iOwner = pLandPlot:GetOwner()
for loop, direction in ipairs(directions) do
local pPlot = Map.PlotDirection(pLandPlot:GetX(), pLandPlot:GetY(), direction)
-- Is the adjacent plot owned by the same player as the land plot
if (pPlot ~= nil and iOwner == pPlot:GetOwner()) then
-- Is the adjacent plot a forest
if(pPlot:GetFeatureType() == iForest)) then
return true
end
end
end
end
return false
end
And lastly to make the lua active do I need to import it into VFS or add it in the actions or contents tabs?