Page 1 of 2
Scripting Pressureplates
Posted: Tue Oct 21, 2014 3:03 pm
by Hianloun
Hello.
I wanted to start my own Map in LoG2. I´am pretty new at Scripting and the first problems start

.
I want to make a little Pressureplate puzzle.
For example. Lets say i Have three Plates. Two of them have to be activated and one of them have to be deactivated to open the Door
So in the Editor i place :
3x PressurePlates
1x Door
1x scripting_entity
I connectect the 3x Pressure Plates to scripting_entity and also choose the DoorOpen() function
I renamed the Pressureplates and the Door to make it easyier for me (Plate1,Plate2,Plate3 / Door1)
The scripting_entity looks like:
function DoorOpen()
if Plate1.floortrigger: <<<<<<<<<<< (And here the problem starts) What is the command to let the script check that this plate is active and
Plate2.floortrigger: <<<<<<<<<< same and
Plate3.floortrigger: <<<<<<<<<< same then
Door1.door (dont know if door is right): <<<<<< same
end
end
Hope anyone can help me

. Thanks
Re: Scripting Pressureplates
Posted: Tue Oct 21, 2014 3:21 pm
by Drakkan
just my idea as I am scripting noob as well - you dont need scripting for this. Just use object counter, set it to 2 and link it to door. Then link all plates to it (two "correct" plates will give -1 counter on activation and +1 on deactivation, and last plate will give +1 on activation and -1 on deactivation). So door will only open when counter = 0 (means both correct plates are activated). Of course scripting will be much more precise for this

Re: Scripting Pressureplates
Posted: Tue Oct 21, 2014 3:24 pm
by NutJob
Drakkan wrote:just my idea as I am scripting noob as well - you dont need scripting for this. Just use object counter, set it to 2 and link it to door. Then link all plates to it (two "correct" plates will give -1 counter on activation and +1 on deactivation, and last plate will give +1 on activation and -1 on deactivation). So door will only open when counter = 0 (means both correct plates are activated). Of course scripting will be much more precise for this

To add; this is a helpful guide to doing it in LoG1 (will still work in Log2).
https://www.youtube.com/watch?v=6G5K0sjKadI
Re: Scripting Pressureplates
Posted: Tue Oct 21, 2014 3:29 pm
by Hianloun
Thanks to both of you.
I had the same idea but i think there is a problem.
Lets say the counter have a value of 2. And at 0 it triggers the Door.
I have three plates and Want 1 and 3 activated and 2 deactivated.
If a player goes on Plate1 or Plate3 the counter value goes -1. If he goes on Plate2 nothing happen.
Ok now the player can easy move over Plate1 and again Plate1 ( Counter -1 -1 )
Another Problem is when i give Plate2 a value of +1 to the counter and the player moves 10 times over it. That means the Counter is at 10+.
Or do i think the wrong way?
Re: Scripting Pressureplates
Posted: Tue Oct 21, 2014 3:32 pm
by NutJob
That video actually explains how to remedy that problem.
Re: Scripting Pressureplates
Posted: Tue Oct 21, 2014 3:39 pm
by Hianloun
Jea thats true. But this is for Torchholder.
if Plate1.floortrigger: <<<<<<<<<<< (And here the problem starts) What is the command to let the script check that this plate is active
That is my Problem at the moment. I dont know the commmand to let the script check if the plate is active

.
Also the scripting changes from LoG1 and LoG2.
Re: Scripting Pressureplates
Posted: Tue Oct 21, 2014 4:58 pm
by SnowyOwl47
Want I'm getting here is you want to do,
Create a script_entity and name it game and copy paste this in it:
Code: Select all
function getEnabled(entity)
if entity .door:open() == open then
return true
elseif entity .door:close() == close then
return false
end
end
So then you can use that like:
if game.script:getEnabled(entity) == true or false whichever one then
door_name.door:close()
end
Example that I use:
if game.script:getEnabled(door) == false then
door.door:open()
end
So true = open,
and false = closed
Or you can also use the method that you don't have to do much with which is:
if entity .door:open() == open then
elseif entity .door:close() == close then
end
thats the way you do that which is less work but the reason why I showed you the other method is because thats apart of a easy script thing you copy paste into an script_entity and name the script_entity game and it makes most commands easier but in my easy commands the getEnabled method doesn't just get if a door is opened or closed.
Re: Scripting Pressureplates
Posted: Tue Oct 21, 2014 5:11 pm
by SnowyOwl47
Hianloun wrote:Jea thats true. But this is for Torchholder.
if Plate1.floortrigger: <<<<<<<<<<< (And here the problem starts) What is the command to let the script check that this plate is active
That is my Problem at the moment. I dont know the commmand to let the script check if the plate is active

.
Also the scripting changes from LoG1 and LoG2.
Sorry buddy but I can't help you with this please explain what your asking more on this on

then I can help you!

Re: Scripting Pressureplates
Posted: Tue Oct 21, 2014 7:45 pm
by Hianloun
Hey,
i just want three pressureplates.
If two of them are activated the door opens. Else not.
Re: Scripting Pressureplates
Posted: Tue Oct 21, 2014 7:49 pm
by SnowyOwl47
Hianloun wrote:Hey,
i just want three pressureplates.
If two of them are activated the door opens. Else not.
No script needed just use a counter and make it have 2 value and then make your to pressure plates that open the door decrement the counter and the their pressure plate reset the counter or increase the counter and then connect the counter to the door easy as pie
