Page 1 of 2
Connector between levels
Posted: Fri Sep 14, 2012 8:35 pm
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.
Re: Connector between levels
Posted: Fri Sep 14, 2012 8:42 pm
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.
Re: Connector between levels
Posted: Fri Sep 14, 2012 9:12 pm
by Komag
nice!
I have added this to the "Use Scripts Repository":
viewtopic.php?f=14&t=3099
Re: Connector between levels
Posted: Sat Sep 15, 2012 12:41 am
by Emciel
thanks alot Magus.
would it also be possible to call a lua function on another level this way?
Re: Connector between levels
Posted: Sat Sep 15, 2012 1:11 am
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
Re: Connector between levels
Posted: Sat Sep 15, 2012 1:36 am
by Emciel
i mean use a lua script on one level to make a lua script on another level do something?
Re: Connector between levels
Posted: Sat Sep 15, 2012 7:43 am
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.
Re: Connector between levels
Posted: Sat Sep 15, 2012 10:15 am
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
Re: Connector between levels
Posted: Sat Sep 15, 2012 11:48 am
by Komag
timers are your friends - very powerful friends
Re: Connector between levels
Posted: Sat Sep 15, 2012 12:30 pm
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.