Page 1 of 1

Temple_pit coding issue

Posted: Tue Mar 05, 2013 3:00 am
by Zerosangheili
I'm attempting to make a full set of pits open/close, but can't seem to get it to work correctly. I'm extremely new to any type of coding, so bear with me here.

I have 4 levers in total, but when two are activated I want to block the player in by opening a wall of pits. Opening this wall of pits also releases a strong monster for them to slay. Once slain, the monster will drop the appropriate key to close the pits for the player to continue through the dungeon.

Here is the basic floor plan. The monsters in the center of the room will be released. The others are fillers for now.
Image

This is what I've come up with so far, but I know it's not right. It tells me there's an unexpected symbol near and. Referring to the "trapPit1:open() and"

Code: Select all

Pit Trap
function pullLever()
	if accessLever3:getLeverState() == "activated" and
	accessLever4:getLeverState() == "activated" then
		trapPit1:open() and
		trapPit2:open() and
		trapPit3:open() and
		trapPit4:open() and
		trapPit5:open() and
		trapPit6:open() and
		trapPit7:open() and
		trapPit8:open() and
		trapPit9:open() and
		trapPit10:open() and
		trapPit11:open() and
		trapPit12:open() and
		trapPit13:open() 
	else
		trapPit1:close() and
		trapPit2:close() and
		trapPit3:close() and
		trapPit4:close() and
		trapPit5:close() and
		trapPit6:close() and
		trapPit7:close() and
		trapPit8:close() and
		trapPit9:close() and
		trapPit10:close() and
		trapPit11:close() and
		trapPit12:close() and
		trapPit13:close() 
	end
end
Any help at all would be greatly appreciated. Thank you.

Re: Temple_pit coding issue

Posted: Tue Mar 05, 2013 3:09 am
by msyblade
remove ALL of the "ands :), let me know if you still have an error

Re: Temple_pit coding issue

Posted: Tue Mar 05, 2013 3:15 am
by Zerosangheili
So simple. I can't believe I didn't try that. Thank you very much.

Re: Temple_pit coding issue

Posted: Tue Mar 05, 2013 3:51 am
by Komag

Code: Select all

Pit Trap
function pullLever()
  local lv = false
  if accessLever3:getLeverState() == "activated" and
     accessLever4:getLeverState() == "activated" then
     lv = true
  end
  for i=1,13 do
    local p = findEntity("trapPit"..i)
    if p then if lv then p:open() else p:close() end end
  end
end

Re: Temple_pit coding issue

Posted: Tue Mar 05, 2013 4:33 am
by msyblade
Damn, I wish i could do that, lol.