Connector between levels

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Emciel
Posts: 34
Joined: Fri Sep 14, 2012 2:19 am

Connector between levels

Post by Emciel »

Is it possible to use a button on one level to trigger something on another?
At the moment it lets me connect them but not specify the action.
Magus
Posts: 56
Joined: Wed Sep 12, 2012 6:05 pm

Re: Connector between levels

Post by Magus »

Yes just use simple lua scripts.
Example:

Code: Select all

function sdoor01()
	if lever01:getLeverState() == "activated" then
		door01:setDoorState("open")
	else
		door01:setDoorState("closed")
	end
end
The lever/button and the script must be in the same level. The door can be in a lower level.
You need to rename door01 and lever01 if you want to use this.
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Connector between levels

Post by Komag »

nice!

I have added this to the "Use Scripts Repository":
viewtopic.php?f=14&t=3099
Finished Dungeons - complete mods to play
User avatar
Emciel
Posts: 34
Joined: Fri Sep 14, 2012 2:19 am

Re: Connector between levels

Post by Emciel »

thanks alot Magus.

would it also be possible to call a lua function on another level this way?
User avatar
Shroom
Posts: 98
Joined: Tue Mar 27, 2012 6:37 pm
Location: UK

Re: Connector between levels

Post by Shroom »

As far as I can see, you are referencing the object, so it doesn't seem to care where it is on the map. This is the advantage of script calls :)
User avatar
Emciel
Posts: 34
Joined: Fri Sep 14, 2012 2:19 am

Re: Connector between levels

Post by Emciel »

i mean use a lua script on one level to make a lua script on another level do something?
Magus
Posts: 56
Joined: Wed Sep 12, 2012 6:05 pm

Re: Connector between levels

Post by Magus »

don't think this works. Right now we can't call functions outside of the lua scripts.

EDIT: Found a way. You can use a timer for the second script, this way you can activate the timer from all other floors and the timer will run the lua script.
User avatar
Shroom
Posts: 98
Joined: Tue Mar 27, 2012 6:37 pm
Location: UK

Re: Connector between levels

Post by Shroom »

Shroom wrote:As far as I can see, you are referencing the object, so it doesn't seem to care where it is on the map. This is the advantage of script calls :)
Magus wrote:don't think this works. Right now we can't call functions outside of the lua scripts.

EDIT: Found a way. You can use a timer for the second script, this way you can activate the timer from all other floors and the timer will run the lua script.
Use the level objects - you can use timers, or activate plates or whatever else you want to do to run localised scripts - these objects can sit in unconnected rooms, or just not be triggered by the party, items or monsters etc
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Connector between levels

Post by Komag »

timers are your friends - very powerful friends
Finished Dungeons - complete mods to play
Magus
Posts: 56
Joined: Wed Sep 12, 2012 6:05 pm

Re: Connector between levels

Post by Magus »

A much better way is using counters. Set the counter to 1 and decrease it with a script, the counter runs a new script that resets the counter to 1.

This way you don't need to wait 1 second for the script to run.
Post Reply