Page 1 of 1

How to check for a specific item on a pressure plate

Posted: Tue Oct 09, 2012 11:41 pm
by Broken|Glass
It took me about an hour to figure this out, so I wanted to share it with everyone.

The goal was to get a specific item to trigger a pressure plate (only when the item is placed on the plate) and open a door.
SpoilerShow
function checkWhatActivated()

Code: Select all

if findEntity("a1") ~= nil then
	if a1.x == p1.x and a1.y == p1.y and p1:isDown() then
	    d1:open()
	end
  end
end
Replace a1 with the specific ITEM ID, replace p1 with the specific PRESSURE PLATE ID, and replace d1 with the specific DOOR ID. It will open the door if and only if the item is placed on the plate. This LUA needs to be connected to the pressure plate that is used.

Enjoy!
P.S. I noticed that the post took away my perfect spacing(formatting) and I was wondering if anyone knows how to make it NOT do that? **EDIT** Thanks for the fix!

Re: How to check for a specific item on a pressure plate

Posted: Tue Oct 09, 2012 11:51 pm
by Lyverbe
I use the iterator

Code: Select all

	for i in entitiesAt(5, 21, 17) do
		if i.name == "<insert entity name to seek>" then
			<do whatever necessary>
		end
	end
Ps. For formatting, put code between [ code] tags

Re: How to check for a specific item on a pressure plate

Posted: Tue Oct 09, 2012 11:51 pm
by Batty
Broken|Glass wrote: P.S. I noticed that the post took away my perfect spacing(formatting) and I was wondering if anyone knows how to make it NOT do that?

Code: Select all

put it in code tags