[Questions] Developing dungeon, need help.

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
MusicManiac
Posts: 2
Joined: Sun Oct 15, 2017 11:31 pm

[Questions] Developing dungeon, need help.

Post by MusicManiac »

Hi all.

Intro (skip if not intrested)
I've started to develop my own dungeon, got decent starting area with 1 simple puzzle and secret. So I've started to develop second area, and creating more complicated puzzle, and I've come to the point where I need to make a script, and I have no clue how to make scripts. I've watched that series of vids on youtube about creating dungeons in LoG2 (the one with 13 series), and have read scripting guides here, but still haven't got far into it. So yea, I need help with following:

Question itself
I need to make a script that will reset a row of portals to their default state (turned on), if they are not in their default state.
So i have invisible_teleporter_1, invisible_teleporter_2, ..., invisible_teleporter_5, invisible_teleporter_6, and I need a script that will reset them all to default state if/when any of them is triggered.
Thx for help.
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: [Questions] Developing dungeon, need help.

Post by Isaac »

Two ways:

Use this one if all of your teleporters are consecutively named (as you mentioned they were).

Code: Select all

function reset()
	local max = 6 	-- number of consecutively named teleporters
	
	for x = 1, max do
		local test = findEntity("teleporter_"..x)
		if test and test.teleporter then 
			test.controller:activate()
		end
	end
end
Use this one if you have teleporters with un-ordered names like 'teleporter 12' and then _21, _17, _26... etc

Code: Select all

function altReset()  
	local set = {
					'teleporter_3',
					'teleporter_5',
					'teleporter_2',
					'teleporter_4',
					'teleporter_6',
					'teleporter_1',
				}
	for _,each in pairs(set) do
		local test = findEntity(each)
		if test and test.teleporter then 
			test.controller:activate()
		end
	end
end
User avatar
MusicManiac
Posts: 2
Joined: Sun Oct 15, 2017 11:31 pm

Re: [Questions] Developing dungeon, need help.

Post by MusicManiac »

Thanks, that worked, will come back here for more help when will get to it :)
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: [Questions] Developing dungeon, need help.

Post by akroma222 »

MusicManiac wrote: I've started to develop my own dungeon, got decent starting area with 1 simple puzzle and secret. So I've started to develop second area, and creating more complicated puzzle, and I've come to the point where I need to make a script, and I have no clue how to make scripts.
When the LoG1 editor was released I built a level without script entities or any coding on my part...
then needed to open secret doors when gems were placed into demon head statues
Luckily AH responded to my email and helped me with the scripting required.
From there I trawled through these forums, asking questions and adapting other peoples code to suit my purposes
Years later Im still learning from the more experienced (and very helpful) modders here - everyone here is helping each other :)
If you get stuck, do what you can to find out with the resources available & dont be afraid to ask questions
Best of luck MusicManiac, and welcome! ;)
Post Reply