Item On Pressure Plate(s)

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Item On Pressure Plate(s)

Post by Mysterious »

Hello everyone.

I found the code below and it works very good. What I need is simular but I don't need the door. What I mean is I need the pressure plate just to accept a item of my choosing and then a counter decrement or any thing I need to do after the (then) command and the option to destroy the item as well.

I have tried and failed badly again and again so plese some help.

Code: Select all

function opendoor()
  --timer_1.timer:start()
  local matches = {
    ["blue_gem"] = "dungeon_door_portcullis_1", } -- The item and the door you want to open
  
for e in dungeon_pressure_plate_1.map:entitiesAt(dungeon_pressure_plate_1.x,dungeon_pressure_plate_1.y) do
    for gem,door in pairs(matches) do
      if e.name == gem then
        findEntity(door).door:open()
        --e:destroyDelayed()    -- enable this if you want the correct item to get destroyed
        break
      end
    end
  end
end
EDIT: I have after much hair pulling worked it out. I hope this right as it works in the Editor.

Code: Select all

function Sky1()
  local matches = {
    ["blue_gem"] = "maze_counter_1", } -- The counter
  
for e in forest_pressure_plate_6.map:entitiesAt(forest_pressure_plate_6.x,forest_pressure_plate_6.y) do
    for gem,counter in pairs(matches) do
      if e.name == gem then
        findEntity(counter).counter:decrement()
        e:destroyDelayed()    -- enable this if you want the correct item to get destroyed
		delayedCall(self.go.id,0.1,"SkySolved1")
        break
      end
    end
  end
end
Post Reply