ZIoKo Posted February 2, 2009 Share Posted February 2, 2009 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 dooris 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 More sharing options...
SpeedyB64 Posted February 2, 2009 Share Posted February 2, 2009 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, 10Endif end scn SwitchTwo begin onactivate if DoorSwitchSetting.getpos z == 10 DoorSwitchSetting.setpos z, 20Endif 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 switchesAnd 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 More sharing options...
ZIoKo Posted February 3, 2009 Author Share Posted February 3, 2009 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 More sharing options...
SpeedyB64 Posted February 3, 2009 Share Posted February 3, 2009 Are the switches set to persistent reference? (double click on the switch and check the box) Link to comment Share on other sites More sharing options...
ZIoKo Posted February 3, 2009 Author Share Posted February 3, 2009 Are the switches set to persistent reference? (double click on the switch and check the box) Ah, that was the missing piece!Its working like a charm, thanks! :thumbsup: Link to comment Share on other sites More sharing options...
SpeedyB64 Posted February 3, 2009 Share Posted February 3, 2009 You are most welcome :thumbsup: Link to comment Share on other sites More sharing options...
3vilg3nius Posted February 25, 2010 Share Posted February 25, 2010 THanks speedy, nifty script...w00t...modified it a bit for a keypad I made; but never the less...works like a charm. :bunny: :banana: Link to comment Share on other sites More sharing options...
pkleiss Posted February 25, 2010 Share Posted February 25, 2010 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 More sharing options...
Recommended Posts