Skip to content

Instantly share code, notes, and snippets.

@scfmod
Last active December 29, 2018 17:00
Show Gist options
  • Save scfmod/ca3f1fef8074f5f930bd158b55b54df4 to your computer and use it in GitHub Desktop.
Save scfmod/ca3f1fef8074f5f930bd158b55b54df4 to your computer and use it in GitHub Desktop.
PlaceAnywhere - Land owner check override and terrainDeformation override
local overrideAreaOwnerCheck = false
local dismissTerrainDeformation = false
-- ...
function PlaceAnywhere:loadMap(name)
-- ...
-- override area owner check
PlacementScreenController.isPlacementValid = Utils.overwrittenFunction(PlacementScreenController.isPlacementValid, PlaceAnywhere.isPlacementValid);
-- override terrain deformation
Placeable.addPlaceableLevelingArea = Utils.overwrittenFunction(Placeable.addPlaceableLevelingArea, PlaceAnywhere.addPlaceableLevelingArea);
Placeable.addPlaceableRampArea = Utils.overwrittenFunction(Placeable.addPlaceableRampArea, PlaceAnywhere.addPlaceableRampArea);
end
function PlaceAnywhere:addPlaceableLevelingArea(superFunc, ...)
if dismissTerrainDeformation then
return true
else
return superFunc(self, ...)
end
end
function PlaceAnywhere:addPlaceableRampArea(superFunc, ...)
if dismissTerrainDeformation then
return true
else
return superFunc(self, ...)
end
end
function PlaceAnywhere:isPlacementValid(superFunc, ...)
if overrideAreaOwnerCheck then
return true
else
return superFunc(self, ...)
end
end
-- ...
-- For testing
function PlaceAnywhere:keyEvent(u, sym, m, i)
if i and sym == Input.KEY_0 then
dismissTerrainDeformation = not dismissTerrainDeformation
print('dismissTerrainDeformation = ' .. tostring(dismissTerrainDeformation))
elseif i and sym == Input.KEY_9 then
overrideAreaOwnerCheck = not overrideAreaOwnerCheck
print('overrideAreaOwnerCheck = ' .. tostring(overrideAreaOwnerCheck))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment