Jump to content

Open door using multiple switches


ZIoKo

Recommended Posts

Hey there,

 

Im in need for a bit of advice.

I want the player to get access to a certain -yet locked- door.

To get it unlocked, he/she will have to activate 3 or more switches.

Only if all 3 (or more) switches are activated, the door will unlock,

possibly with an on-screen message and sound, since the locked door

is not in the players sight.

(The switches should also stay activated,

so the player cant deactivate them again - to avoid confusion)

 

If anyone knows how to do that, i'd be very happy!

 

Thanks in advance.

Link to comment
Share on other sites

This is a tricky one but I know the trick ;)

 

What you do is make a script for each switch. Since a script can't change a variable in another script unless it is part of a quest, you either need to use a global variable or you can use this helpful trick: Make an X marker and position it at 0,0,0 and name it something like DoorSwitchSetting. Then you make the scripts for the switches like this:

 

scn SwitchOne

 

begin onactivate

 

if DoorSwitchSetting.getpos z == 0

DoorSwitchSetting.setpos z, 10

Endif

 

end

 

scn SwitchTwo

 

begin onactivate

 

if DoorSwitchSetting.getpos z == 10

DoorSwitchSetting.setpos z, 20

Endif

 

end

 

scn SwitchThree

 

begin onactivate

 

if DoorSwitchSetting.getpos z == 20

DoorSwitchSetting.setpos z, 30

DoorRef.Unlock ;(you could put DoorRef.setopenstate 1 here if you want it to open)

Endif

 

end

 

if the switch is animated add this line after each getpos line : SwitchRef.playgroup forward 1

 

I used this trick for a code locked blast door (more complex but the same idea)

 

So put these scripts on the switches

And make sure to make DoorRef the reference name of the door and SwitchRef the reference name of the switch that you want to animate.

 

Hope this helps :thumbsup:

Link to comment
Share on other sites

Thanks!

 

Some sort of counters, of course. :wallbash:

 

I'll try to implent that, thank you!

 

Just one more thing:

Do i have to duplicate and rename the existing switches in GECK (new EditorID),

or can i just use the normal ones and just give them a different RefID in my map?

 

[E]

 

When saving my script, i get a syntax error: Invalid reference "insert my button name here"... etc...

Is this normal?

I've set up everything correctly, the names (RefIDs) match... any ideas?

Link to comment
Share on other sites

  • 1 year later...
Since a script can't change a variable in another script unless it is part of a quest...

Actually, you can change a varibale in a script from another. As long as the object the script is running on is persistent and has a reference editor ID and both scripts are running on objects in the same cell, you can do it.

 

Say I have a persistent switch with a reference editor ID of "MySwitch". In that script I define a variable like this:

 

Short Task

 

Then I can reference "Task" explicitly from another script running in the same cell like this:

 

Set MySwitch.Task to (whatever)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...