Scripting Pressureplates

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!
Hianloun
Posts: 6
Joined: Tue Oct 21, 2014 2:46 pm

Scripting Pressureplates

Post 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
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: Scripting Pressureplates

Post 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 :)
Breath from the unpromising waters.
Eye of the Atlantis
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Scripting Pressureplates

Post 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
Hianloun
Posts: 6
Joined: Tue Oct 21, 2014 2:46 pm

Re: Scripting Pressureplates

Post 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?
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Scripting Pressureplates

Post by NutJob »

That video actually explains how to remedy that problem.
Hianloun
Posts: 6
Joined: Tue Oct 21, 2014 2:46 pm

Re: Scripting Pressureplates

Post 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.
User avatar
SnowyOwl47
Posts: 148
Joined: Fri Sep 12, 2014 10:41 pm

Re: Scripting Pressureplates

Post 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.
User avatar
SnowyOwl47
Posts: 148
Joined: Fri Sep 12, 2014 10:41 pm

Re: Scripting Pressureplates

Post 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 :D then I can help you! :geek:
Hianloun
Posts: 6
Joined: Tue Oct 21, 2014 2:46 pm

Re: Scripting Pressureplates

Post by Hianloun »

Hey,

i just want three pressureplates.

If two of them are activated the door opens. Else not.
User avatar
SnowyOwl47
Posts: 148
Joined: Fri Sep 12, 2014 10:41 pm

Re: Scripting Pressureplates

Post 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 :D
Post Reply