How to check for a specific item on a pressure plate

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
Broken|Glass
Posts: 2
Joined: Tue Oct 09, 2012 11:32 pm

How to check for a specific item on a pressure plate

Post 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!
Last edited by Broken|Glass on Wed Oct 10, 2012 12:53 am, edited 1 time in total.
Lyverbe
Posts: 57
Joined: Thu May 17, 2012 1:31 pm

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

Post 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
Batty
Posts: 509
Joined: Sun Apr 15, 2012 7:04 pm

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

Post 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
Post Reply