Update! The script had an error, I corrected the code here in the thread and also rebuilt the game with the correct version (new download link). I am afraid you have to re-download
I know its ANOTHER thread by me but this is no conversation and way too long for the Short Script thread - but you are going to like this one, I'm sure.
It's an old-fashioned script for entering a 4-digit code, using no variables or huds, just simple & colourful RAWTEXT:
This is not all of course. If you want to enjoy the audio and know what happens when you enter the wrong code, you'll have to download & play the demo (or read the script thourougly...)
Here is the full script:
;Artificial Intelligence Script:CodeInput
by TheStoryteller01 2012
;Header
desc=
This script only works with FPSC 1.18. or later.
Made for control pads, monitors or smiliar where the player has to enter a 4-digit code to open a remote door.
Best ist to set the item properties "Isimmobile" to "Yes" and "Strength" to "0" (=indestructible).
The name of the remote door has to be entered in the "Ifused" field of this entity.
The script starts when the player moves the cursor over the item while not more than 60 units away.
If the player enters the wrong code an alarm sound is started but he can still try to enter the correct code.
Once the door is opened, it cannot be closed again.
The correct code for this script is 6184. To change it, refer to the keypboard's numpad numbers below:
1=79
2=80
3=81
4=75
5=76
6=77
7=71
8=72
9=73
;Triggers
:state=0:state=1
:state=1,pickobject=1,plrdistwithin=60:state=3
:state=3:fpgcrawtextsize=48,fpgcrawtextfont=verdana,fpgcrawtextr=190,fpgcrawtextg=190,fpgcrawtextb=190,fpgcrawtextx=50,fpgcrawtexty=46
:state=3:fpgcrawtext=?
:state=3,plrusingaction=1,etimergreater=500:state=4
:state=3,pickobject=0:state=1
:state=4,pickobject=1,plrdistwithin=60:etimerstart,state=5
:state=5:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=190,fpgcrawtextg=190,fpgcrawtextb=190,fpgcrawtextx=50,fpgcrawtexty=56
:state=5:fpgcrawtext=Entering the right access code should open this door.
:state=5,plrusingaction=1,etimergreater=500:state=6
:state=5,pickobject=0:state=4
:state=6,pickobject=1,plrdistwithin=60:etimerstart,state=7
:state=7:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=051,fpgcrawtextx=50,fpgcrawtexty=56
:state=7:fpgcrawtext=Enter the 4-digit code <use the keyboard's numpad>
:state=7,etimergreater=3000:state=40
:state=7,plrusingaction=1,etimergreater=500:state=40
:state=7,pickobject=0:state=6
:state=40,pickobject=1,plrdistwithin=100:state=50
:state=50:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=051,fpgcrawtextx=50,fpgcrawtexty=56
:state=50:fpgcrawtext=_ _ _ _
:state=50,keypressed=77 1:plrsound=audiobank\switches\press.wav,state=52
:state=50,keypressed=80 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,keypressed=81 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,keypressed=75 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,keypressed=76 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,keypressed=79 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,keypressed=71 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,keypressed=72 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,keypressed=73 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,pickobject=0:state=6
:state=52:etimerstart,state=53
:state=53:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=051,fpgcrawtextx=50,fpgcrawtexty=56
:state=53:fpgcrawtext=* _ _ _
:state=53,pickobject=1,plrdistwithin=100,etimergreater=500:state=55
:state=53,pickobject=0:state=6
:state=55:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=051,fpgcrawtextx=50,fpgcrawtexty=56
:state=55:fpgcrawtext=* _ _ _
:state=55,keypressed=79 1:plrsound=audiobank\switches\press.wav,state=56
:state=55,keypressed=80 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,keypressed=81 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,keypressed=75 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,keypressed=76 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,keypressed=77 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,keypressed=71 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,keypressed=72 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,keypressed=73 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,pickobject=0:state=6
:state=56:etimerstart,state=57
:state=57:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=51,fpgcrawtextx=50,fpgcrawtexty=56
:state=57:fpgcrawtext=* * _ _
:state=57,pickobject=1,plrdistwithin=100,etimergreater=500:state=59
:state=57,pickobject=0:state=6
:state=59:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=051,fpgcrawtextx=50,fpgcrawtexty=56
:state=59:fpgcrawtext=* * _ _
:state=59,keypressed=72 1:plrsound=audiobank\switches\press.wav,state=60
:state=59,keypressed=80 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,keypressed=81 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,keypressed=75 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,keypressed=76 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,keypressed=77 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,keypressed=71 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,keypressed=79 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,keypressed=73 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,pickobject=0:state=6
:state=60:etimerstart,state=61
:state=61:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=51,fpgcrawtextx=50,fpgcrawtexty=56
:state=61:fpgcrawtext=* * * _
:state=61,pickobject=1,plrdistwithin=100,etimergreater=500:state=63
:state=61,pickobject=0:state=6
:state=63:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=051,fpgcrawtextx=50,fpgcrawtexty=56
:state=63:fpgcrawtext=* * * _
:state=63,keypressed=75 1:plrsound=audiobank\switches\press.wav,state=64
:state=63,keypressed=80 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,keypressed=81 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,keypressed=79 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,keypressed=76 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,keypressed=77 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,keypressed=71 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,keypressed=72 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,keypressed=73 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,pickobject=0:state=6
:state=64,etimerstart:state=65
:state=65:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=51,fpgcrawtextx=50,fpgcrawtexty=56
:state=65:fpgcrawtext=* * * *
:state=65,pickobject=1,plrdistwithin=100,etimergreater=2000:state=90
:state=90:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=51,fpgcrawtextx=50,fpgcrawtexty=56
:state=90:fpgcrawtext=CODE VALID
:state=90:plrsound=audiobank\misc\checkpoint.wav,state=91
:state=91:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=51,fpgcrawtextx=50,fpgcrawtexty=56
:state=91:fpgcrawtext=CODE VALID
:state=91,etimergreater=3000:state=92
:state=91,pickobject=0:state=92
:state=92:fpgcrawtextoff,activateifused=1
:state=99:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=204,fpgcrawtextg=000,fpgcrawtextb=000,fpgcrawtextx=50,fpgcrawtexty=56
:state=99:fpgcrawtext=CODE INVALID
;//THE FOLLOWING LINE PLAYS A LOOPING ALARMSOUND THAT WONT STOP. IF YOU DONT LIKE IT, JUST DELETE THE FOLLOWING LINE.
:state=99:loopsound=audiobank\atmos\alarmhum.wav
:state=99,plrusingaction=1,etimergreater=500:state=50
:state=99,pickobject=0:state=6
;end of script
How it works:
When the player puts the crosshair over the item, a “?” will be displayed. Pressing enter displayes the text line seen in the first pic. Pressing enter again (or waiting a few seconds) displays the green text line (second pic). The player then has to enter a 4-digit code using his keyboard's numpad. If the player removes the cursor from the object at any time, the text simply stops to display but the script remembers the state it's in, so when later the cursor is moved over the object again, only the last displayed line will be displayed instead of the script starting all over. Of course, if the player removes the cursor during entering the numbers he will get the chance to start with the first digit again next time.
Examples where to use:
Remote doors, lifts, android/robot allies (The name of the entity to be activated must be entered in the "Ifused" field of the scripted entity)
Issues:
It includes a line calling a LOOPSOUND, that cannot be stopped. There is a workaround but then the script wouldn't be standalone anymore. If you dislike the sound, simply remove the line (it's conveniently at the script's end and marked)
This is the new variant:
;Artificial Intelligence Script:CodeInput02
by TheStoryteller01 2012
;Header
desc=
This script only works with FPSC 1.18. or later.
Made for control pads, monitors or smiliar where the player has to enter a 4-digit code to open a remote door.
Best ist to set the item properties "Isimmobile" to "Yes" and "Strength" to "0" (=indestructible).
The name of the remote door has to be entered in the "Ifused" field of this entity.
The script starts when the player moves the cursor over the item while not more than 60 units away.
If the player enters the wrong code an alarm sound is started but he can still try to enter the correct code and
entering the correct code turns off the alarm. Once the door is opened, it cannot be closed again.
The correct code for this script is 6184. To change it, refer to the keypboard's numpad numbers below:
1=79
2=80
3=81
4=75
5=76
6=77
7=71
8=72
9=73
;Triggers
:state=0:state=1
:state=1,pickobject=1,plrdistwithin=60:state=3
:state=3:fpgcrawtextsize=48,fpgcrawtextfont=verdana,fpgcrawtextr=190,fpgcrawtextg=190,fpgcrawtextb=190,fpgcrawtextx=50,fpgcrawtexty=46
:state=3:fpgcrawtext=?
:state=3,plrusingaction=1,etimergreater=500:state=4
:state=3,pickobject=0:state=1
:state=4,pickobject=1,plrdistwithin=60:etimerstart,state=5
:state=5:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=190,fpgcrawtextg=190,fpgcrawtextb=190,fpgcrawtextx=50,fpgcrawtexty=56
:state=5:fpgcrawtext=Entering the right access code should open this door.
:state=5,plrusingaction=1,etimergreater=500:state=6
:state=5,pickobject=0:state=4
:state=6,pickobject=1,plrdistwithin=60:etimerstart,state=7
:state=7:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=051,fpgcrawtextx=50,fpgcrawtexty=56
:state=7:fpgcrawtext=Enter the 4-digit code <use the keyboard's numpad>
:state=7,etimergreater=3000:state=40
:state=7,plrusingaction=1,etimergreater=500:state=40
:state=7,pickobject=0:state=6
:state=40,pickobject=1,plrdistwithin=100:state=50
:state=50:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=051,fpgcrawtextx=50,fpgcrawtexty=56
:state=50:fpgcrawtext=_ _ _ _
:state=50,keypressed=77 1:plrsound=audiobank\switches\press.wav,state=52
:state=50,keypressed=80 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,keypressed=81 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,keypressed=75 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,keypressed=76 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,keypressed=79 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,keypressed=71 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,keypressed=72 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,keypressed=73 1:plrsound=audiobank\switches\press.wav,state=99
:state=50,pickobject=0:state=6
:state=52:etimerstart,state=53
:state=53:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=051,fpgcrawtextx=50,fpgcrawtexty=56
:state=53:fpgcrawtext=* _ _ _
:state=53,pickobject=1,plrdistwithin=100,etimergreater=500:state=55
:state=53,pickobject=0:state=6
:state=55:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=051,fpgcrawtextx=50,fpgcrawtexty=56
:state=55:fpgcrawtext=* _ _ _
:state=55,keypressed=79 1:plrsound=audiobank\switches\press.wav,state=56
:state=55,keypressed=80 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,keypressed=81 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,keypressed=75 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,keypressed=76 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,keypressed=77 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,keypressed=71 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,keypressed=72 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,keypressed=73 1:plrsound=audiobank\switches\press.wav,state=99
:state=55,pickobject=0:state=6
:state=56:etimerstart,state=57
:state=57:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=51,fpgcrawtextx=50,fpgcrawtexty=56
:state=57:fpgcrawtext=* * _ _
:state=57,pickobject=1,plrdistwithin=100,etimergreater=500:state=59
:state=57,pickobject=0:state=6
:state=59:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=051,fpgcrawtextx=50,fpgcrawtexty=56
:state=59:fpgcrawtext=* * _ _
:state=59,keypressed=72 1:plrsound=audiobank\switches\press.wav,state=60
:state=59,keypressed=80 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,keypressed=81 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,keypressed=75 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,keypressed=76 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,keypressed=77 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,keypressed=71 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,keypressed=79 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,keypressed=73 1:plrsound=audiobank\switches\press.wav,state=99
:state=59,pickobject=0:state=6
:state=60:etimerstart,state=61
:state=61:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=51,fpgcrawtextx=50,fpgcrawtexty=56
:state=61:fpgcrawtext=* * * _
:state=61,pickobject=1,plrdistwithin=100,etimergreater=500:state=63
:state=61,pickobject=0:state=6
:state=63:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=051,fpgcrawtextx=50,fpgcrawtexty=56
:state=63:fpgcrawtext=* * * _
:state=63,keypressed=75 1:plrsound=audiobank\switches\press.wav,state=64
:state=63,keypressed=80 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,keypressed=81 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,keypressed=79 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,keypressed=76 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,keypressed=77 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,keypressed=71 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,keypressed=72 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,keypressed=73 1:plrsound=audiobank\switches\press.wav,state=99
:state=63,pickobject=0:state=6
:state=64,etimerstart:state=65
:state=65:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=51,fpgcrawtextx=50,fpgcrawtexty=56
:state=65:fpgcrawtext=* * * *
:state=65,pickobject=1,plrdistwithin=100,etimergreater=2000:state=90
:state=90:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=51,fpgcrawtextx=50,fpgcrawtexty=56
:state=90:fpgcrawtext=CODE VALID
:state=90:plrsound=audiobank\misc\checkpoint.wav,state=91
:state=91:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=051,fpgcrawtextg=255,fpgcrawtextb=51,fpgcrawtextx=50,fpgcrawtexty=56
:state=91:fpgcrawtext=CODE VALID
:state=91:music=OFF
:state=91:etimergreater=3000:state=92
:state=91,pickobject=0:state=92
:state=92:fpgcrawtextoff,activateifused=1
:state=99:fpgcrawtextsize=24,fpgcrawtextfont=verdana,fpgcrawtextr=204,fpgcrawtextg=000,fpgcrawtextb=000,fpgcrawtextx=50,fpgcrawtexty=56
:state=99:fpgcrawtext=CODE INVALID
:state=99:etimerstart,music=audiobank\atmos\alarmhum.wav,state=100
:state=100,plrusingaction=1,etimergreater=500:state=50
:state=100,pickobject=0:state=6
;end of script
Difference to the original script
Instead of LOOPSOUND= this script uses MUSIC= to play the exact same alarm sound which made it scriptable, that entering the correct code turns the alarm sound off. That comes with a price however - the engine allows multiple sounds to be played but there is only one MUSIC because it provides the "background" for the whole level (like that nervwrecking humming noise that is included in the default
Level Settings). Therefore the alarm sound from this script will replace any music or ambience currently running as "background" and even turning the alarm off will not restore it but leave the level in silence instead (which I personally don't mind but thats just me).
Updated link! The archive containis the demobuild, the seperate original script and the above pic for reference:
http://www.mediafire.com/?r39oea18xvobl9e
In case you find my grammar and spelling weird ---> native German speaker ^^