How to make pit puzzle, such as the chamber of pits?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
antti
Posts: 688
Joined: Thu Feb 23, 2012 1:43 pm
Location: Espoo, Finland
Contact:

Re: How to make pit puzzle, such as the chamber of pits?

Post by antti »

Komag wrote:the dungeon crashed when trying to load into the real game as a custom dungeon
"global" variables will be stored in save games and the datatypes that are supported in save games is limited. You cannot save tables or variables that contain game objects; they should only be used locally.

Unfortunately the save games and variables -article we have on the modding page is a little behind the times and in need of an update...
Steven Seagal of gaming industry
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: How to make pit puzzle, such as the chamber of pits?

Post by Komag »

Alright, then I've had to revert some aspects (including "steps") and rearrange a bit so it will work in game:

Code: Select all

steps = 9 -- CUSTOMIZE: HOW MANY STEPS YOU HAVE
namepart = "pitpuz" -- CUSTOMIZE: PARTIAL ID OF PITS (WITHOUT THE NUMBER)

time = 1
function pitSequence()
  local thetimer = pitpuztimer -- CUSTOMIZE: ID OF THE TIMER
  local sequence = { pitpuz7, pitpuz4, pitpuz1, pitpuz2, pitpuz3, pitpuz6, pitpuz5, pitpuz8, pitpuz9 } -- CUSTOMIZE: IDS OF THE PITS YOU WANT TO CLOSE, IN ORDER
  if levercount == 2 then
    if time < steps + 1 then
      sequence[time]:deactivate() --close a pit in the sequence
    end
    if time > 2 then
      sequence[time-2]:activate() --and then open a pit again two steps behind
    end
    time = time + 1
    if time == steps + 3 then
      time = 1
      thetimer:deactivate()
    end
  elseif levercount == 1 then
    if time > 2 then
      sequence[time-2]:deactivate() --close a pit in the sequence
    end
    if time < steps + 1 then
      sequence[time]:activate() --and then open a pit again two steps behind
    end
    time = time - 1
    if time == 0 then
      time = steps + 2
      thetimer:deactivate()
    end
  end
end

levercount = 2
function leverPull()
  local thetimer = pitpuztimer -- CUSTOMIZE: ID OF THE TIMER
  local thelever1 = pitpuzlever1 -- CUSTOMIZE: ID OF THE FIRST LEVER
  local thelever2 = pitpuzlever2 -- CUSTOMIZE: ID OF THE SECOND LEVER
  if thelever1:getLeverState() == "activated" and
    thelever2:getLeverState() == "activated" then
      levercount = 2
      time = 1
  elseif thelever1:getLeverState() == "deactivated" and
    thelever2:getLeverState() == "deactivated" then
      levercount = 2
      time = 1
  else
    levercount = 1
    time = steps + 2
  end
  for i=1,steps do
    local pit = findEntity(namepart..i)
    if pit then
      pit:activate()
    end
  end
  thetimer:deactivate()
end
The customizing still happens near the top of each function this way, and now it works both in the editor and in the regular game!
Finished Dungeons - complete mods to play
Obyvvatel
Posts: 30
Joined: Mon Sep 17, 2012 11:21 pm
Location: Poznań, Poland

Re: How to make pit puzzle, such as the chamber of pits?

Post by Obyvvatel »

I made it without scripting, and now i'm just like how the heck that happend? :D
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: How to make pit puzzle, such as the chamber of pits?

Post by Komag »

impressive! Do you have the levers to reverse the order yet?
Finished Dungeons - complete mods to play
Obyvvatel
Posts: 30
Joined: Mon Sep 17, 2012 11:21 pm
Location: Poznań, Poland

Re: How to make pit puzzle, such as the chamber of pits?

Post by Obyvvatel »

No, I can put second button that makes the same sequence of events, but in reverse order (if I only used my crappy English correctly you will understand me) :)
Post Reply