-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnh-chooser
executable file
·74 lines (70 loc) · 1.32 KB
/
nh-chooser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/expect -f
# exp_internal 1
set timeout -1
set force_conservative 0
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
proc quit_nethack {} {
send -- "#"
expect {
"Extended Command:" { send -- "q" }
"#" { send -- "q\r" }
}
expect "Really quit? \\\[yn\\\] (n) "
send -- "y"
expect {
"(end) " { send -- " " }
"Do you want your possessions identified? \\\[ynq\\\] (n) " {}
}
send -- "q"
expect eof
wait
}
proc nh_expect {prompt} {
expect "$prompt"
expect "(end) "
}
set retry "n"
while {$retry == "n"} {
spawn -noecho nethack
expect {
"*Restoring save file...*" {
interact
wait
exit
}
"*Is this ok?*"
}
send -- "y"
expect {
-gl "--More--" { send -- " " }
"Hello *, welcome to NetHack!" {}
}
send -- "i"
expect "(end) "
send_user -- "\nDo you want this character? \[ynq\] "
stty -echo
stty -cooked
expect_user -timeout -1 -re "(\[ynq\])"
stty cooked
stty echo
send_user -- "\n"
set retry $expect_out(1,string)
send -- " "
if {$retry == "q"} {
quit_nethack
exit
} elseif {$retry == "n"} {
quit_nethack
}
}
send -- "S"
expect "Really save? \\\[yn\\\] (n) "
send -- "y"
expect eof
send_user "Your game is saved. Load nethack to continue it.\n"