Jump to content

Trying to find an object one floor down


JuryOfYourFears

Recommended Posts

function ISPlumbHelperCursor2:isValid(square)
local objects = square:getObjects()
	for index=0, objects:size()-1 do
		local object = objects:get(index)
		if object:hasModData() and object:getModData().canBeWaterPiped then
			return true
		end
	end
return false
end


This is finding the objects (things that can be plumbed) but I need to check one floor down and I'm still learning, so I've kind of hit a wall here. Any advice is appreciated!

Link to comment
Share on other sites

  • 2 weeks later...

For posterity, this is what I ended up with:
 

function ISPlumbHelperCursor2:isValid(square)
	local x,y,z = square:getX(),square:getY(),square:getZ()-1
	local squareA = getCell():getGridSquare(x, y, z)
	if not squareA then return false end
	local objects = squareA:getObjects()
	for index=0, objects:size()-1 do
		local object = objects:get(index)
		if (object:hasModData() and object:getModData().canBeWaterPiped) or (instanceof(object, "IsoObject") and object:getSprite() and 
			object:getSprite():getProperties() and object:getSprite():getProperties():Is(IsoFlagType.waterPiped)) then
			return true
		end
	end
	return false
end

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...