Handling crazy amounts of secret doors (new problem)

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
HaunterV
Posts: 676
Joined: Mon Apr 16, 2012 9:54 pm
Location: Barrie, Ontario, Canada

Re: Handling crazy amounts of secret doors(thoughts on the w

Post by HaunterV »

ok so i got it to fire the rm change but it always picks the one configuration also integrating a timer is a little confusing. i put;

Code: Select all

	old_config = 1

function changeConfig()
	sd_rm_cfg_change_timer:setTimerInterval(math.random(5,10))
  local configurations = {"sd_rm_cfg_1_", "sd_rm_cfg_2_", "sd_rm_cfg_3_", "sd_rm_cfg_4_", "sd_rm_cfg_5_"}
  repeat new_config = math.random(1,5) until new_config ~= old_config
  for ent in allEntities(party.level) do
    if ent.id:sub(1,12) == configurations[new_config] then
      ent:open()
    elseif ent.id:sub(1,12) == configurations[old_config] then
      ent:close()
    end
  end
  old_config = new_config
end
then named the timer sd_rm_cfg_change_timer and connected it to the SE firing this script
Grimrock Community 'FrankenDungeon 2012. Submit your entry now!: http://tinyurl.com/cnupr7h
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc
User avatar
HaunterV
Posts: 676
Joined: Mon Apr 16, 2012 9:54 pm
Location: Barrie, Ontario, Canada

Re: Handling crazy amounts of secret doors(thoughts on the w

Post by HaunterV »

ok i got allmost everything inplace. the cfg change in this:

Code: Select all

	old_config = 1

function changeConfig()
	  local configurations = {"sd_rm_cfg_1_", "sd_rm_cfg_2_", "sd_rm_cfg_3_", "sd_rm_cfg_4_", "sd_rm_cfg_5_"}
  repeat new_config = math.random(1,5) until new_config ~= old_config
  for ent in allEntities(party.level) do
    if ent.id:sub(1,12) == configurations[new_config] then
      ent:open()
    elseif ent.id:sub(1,12) == configurations[old_config] then
      ent:close()
    end
  end
  old_config = new_config
end

isn't waiting for the con figurations to change it seems to keep firing constantly.
Grimrock Community 'FrankenDungeon 2012. Submit your entry now!: http://tinyurl.com/cnupr7h
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: Handling crazy amounts of secret doors(thoughts on the w

Post by Grimwold »

Strange.. (without testing them) your scripts look fine..

You have a timer with an interval ~ 10 seconds that fires this function? and there's nothing else that connects here that might also be triggering it?

Have you tried adjusting the interval on your timer to see if that makes a difference? try 20 or 30 seconds.

I do have a basic setup that works with the script I posted, but it's on my office PC so it's not easy for me to get at over the weekend.
User avatar
HaunterV
Posts: 676
Joined: Mon Apr 16, 2012 9:54 pm
Location: Barrie, Ontario, Canada

Re: Handling crazy amounts of secret doors(thoughts on the w

Post by HaunterV »

Grimwold wrote:Strange.. (without testing them) your scripts look fine..

You have a timer with an interval ~ 10 seconds that fires this function? and there's nothing else that connects here that might also be triggering it?

Have you tried adjusting the interval on your timer to see if that makes a difference? try 20 or 30 seconds.

I do have a basic setup that works with the script I posted, but it's on my office PC so it's not easy for me to get at over the weekend.
facepalm
Grimrock Community 'FrankenDungeon 2012. Submit your entry now!: http://tinyurl.com/cnupr7h
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc
User avatar
HaunterV
Posts: 676
Joined: Mon Apr 16, 2012 9:54 pm
Location: Barrie, Ontario, Canada

Re: Handling crazy amounts of secret doors(thoughts on the w

Post by HaunterV »

Code: Select all

	old_config = 1

function changeConfig()
	  	  local configurations = {"sd_rm_cfg_1_", "sd_rm_cfg_2_", "sd_rm_cfg_3_", "sd_rm_cfg_4_", "sd_rm_cfg_5_"}
  repeat new_config = math.random(1,5) until new_config ~= old_config
  for ent in allEntities(party.level) do
    if ent.id:sub(1,12) == configurations[new_config] then
      ent:close()
    elseif ent.id:sub(1,12) == configurations[old_config] then
      ent:open()
    end
  end
  old_config = new_config
end
this is working how i wanted it to. now with timer interval working as intended.

Now, is there an if "check sd_rm_cfg_1_" is closed then activate spawner such n such script?
Grimrock Community 'FrankenDungeon 2012. Submit your entry now!: http://tinyurl.com/cnupr7h
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc
User avatar
HaunterV
Posts: 676
Joined: Mon Apr 16, 2012 9:54 pm
Location: Barrie, Ontario, Canada

Re: Handling crazy amounts of secret doors(thoughts on the w

Post by HaunterV »

oh god!@ wTF soem of my doors are friggn illusionary walls now for some reason.
Grimrock Community 'FrankenDungeon 2012. Submit your entry now!: http://tinyurl.com/cnupr7h
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc
User avatar
HaunterV
Posts: 676
Joined: Mon Apr 16, 2012 9:54 pm
Location: Barrie, Ontario, Canada

Re: Handling crazy amounts of secret doors (solved)

Post by HaunterV »

I have since solved the issue. All is well in the world.
Grimrock Community 'FrankenDungeon 2012. Submit your entry now!: http://tinyurl.com/cnupr7h
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: Handling crazy amounts of secret doors (solved)

Post by Grimwold »

Really glad you were able to get things sorted. Sorry I was not around much at the weekend to reply.. we are currently awaiting the arrival of a new entity.
User avatar
SpiderFighter
Posts: 789
Joined: Thu Apr 12, 2012 4:15 pm

Re: Handling crazy amounts of secret doors (solved)

Post by SpiderFighter »

Grimwold wrote:Really glad you were able to get things sorted. Sorry I was not around much at the weekend to reply.. we are currently awaiting the arrival of a new entity.
Congratulations, my friend!!

Haunter, glad everything got sorted out. You certainly dove head first into that concept, and I can't wait to see the end result!
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: Handling crazy amounts of secret doors (solved)

Post by Xanathar »

This was posted on the OneRoom challenge thread. Copying here as it's relevant to this discussion.

I don't know if I have understood the problem properly, so I resume what I understand of it first:
  • You want to do a maze-kind-of-thing where you have secret doors all around
  • Some kind of activator (plates, levers, etc) do change the secret doors to a number of configurations
If this is the case you probably can do as following.

1) Define a table of tables for configurations:

Code: Select all

DOORSPATTERNS =
{
	["config1"] = { "secret_door_1", "secret_door_5", "secret_door_7" },
	["config2"] = { "secret_door_11", "secret_door_25", "secret_door_37" },
	["config4"] = { "secret_door_2", "secret_door_5", "secret_door_7" },
}

ALLDOORS = { "secret_door_1", "secret_door_5", "secret_door_7", ....... etc etc etc }

2) Have an activate configuration method:

Code: Select all

function activatePattern(patternName)
	for _, doorName in ipairs(ALLDOORS) do
		local door = findEntity(doorName)
		door:close()
	end

	for _, doorName in ipairs(DOORSPATTERNS[patternName]) do
		local door = findEntity(doorName)
		door:open()
	end
end
3) find some way (whatever you want) to call activatePattern("config1") etc. etc.

Notes:
  • There is no need to stay all-lower-case inside a scripting entity. Use whatever makes the code clearer (I usually stay with the convention that read-only values are all-upper-case).
  • The code above is NOT TESTED.
  • Never put objects inside table, always put the id of the objects - otherwise GrimRock crashes when saving.
  • Always test the code in the game at regular intervals in time (say, once a day), including saving and reloading.

--

Edited for various fixes.
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com

The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563

My preciousss: http://www.moonsharp.org
Post Reply