@name Metal Detector
@inputs Scr:wirelink Player:entity
@persist Status Keyword:array
@trigger all
if (first()) {
    Scr:egpClear()
    Keyword=array("mad","cracker","pick") #foreign object words
}
if (Player & changed(Player)) {
    Weps=Player:getWeapons()
    String=""
    for (I=1, Weps:count()) {
        String=String+", "+(Weps[I,entity]:type())
    }
    Bad=0
    for (I=1, Keyword:count()) {
        if (String:matchFirst(Keyword[I,string])) {
            Bad=1
        }
    }
    if (Bad) {
        soundPurge()
        soundPlay(0,0,"ambient/alarms/klaxon1.wav")
        Scr:egpClear()
        Scr:egpText(1,"X",vec2(256,256))
        Scr:egpAlign(1,1,1)
        Scr:egpSize(1,250)
        Scr:egpText(2,"Foreign Material Detected",vec2(256,500))
        Scr:egpSize(2,30)
        Scr:egpAlign(2,1,2)
        Scr:egpColor(1,vec(255,0,0))
        Scr:egpColor(2,vec(255,0,0))
        timer("clear",5000)
    }
    
}
if (clk("clear")) {
    Scr:egpClear()
}

