Page 1 of 1

[Questions] Developing dungeon, need help.

Posted: Sun Oct 15, 2017 11:50 pm
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.

Re: [Questions] Developing dungeon, need help.

Posted: Mon Oct 16, 2017 2:08 am
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

Re: [Questions] Developing dungeon, need help.

Posted: Tue Oct 17, 2017 11:33 am
by MusicManiac
Thanks, that worked, will come back here for more help when will get to it :)

Re: [Questions] Developing dungeon, need help.

Posted: Wed Oct 18, 2017 3:20 pm
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! ;)