-
Notifications
You must be signed in to change notification settings - Fork 0
/
ncp.mare
181 lines (156 loc) · 5.67 KB
/
ncp.mare
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
@@ Navigation Console Parent v1.0
@addparent NCParent=System Function Parent
@set NCParent=Color:12
#mupdate on
@@set NCParent=Desc:
@@ Current sector [get_sector()]%r
@@
@@--------------[setq(1,foreach(lexits(loc(ship())),[last(first(name(v(0)),>),<)]))]%r
@@| [ifelse(wmatch(v(1),N),N,{ })] [ifelse(wmatch(v(1),U),U,{ })] |%r
@@| [ifelse(wmatch(v(1),N),|,{ })] [ifelse(wmatch(v(1),U),/,{ })] |%r
@@| [ifelse(wmatch(v(1),W),W --,{ })] * [ifelse(wmatch(v(1),E),-- E,{ })] |%r
@@| [ifelse(wmatch(v(1),D),/,{ })] [ifelse(wmatch(v(1),S),|,{ })] |%r
@@| [ifelse(wmatch(v(1),D),D,{ })] [ifelse(wmatch(v(1),S),S,{ })] |%r
@@--------------
.
@set NCParent=Desc:
Current Sector: [ansi(y+,get_sector())]%r
Current Course: [ansi(b+,get_course())]%r
Course distance: [ansi(w+,courselen())] sectors%r
Speed: [ansi(w,v(speed))]%r
Helm: [switch(truth(wmatch(lsema(me),tr_step)),1,ansi(g+,engaged),ansi(x+,idle))]
.
#mupdate off
@defattr NCParent/cmd_do=inherit
@defattr NCParent/presentcourse=function
@defattr NCParent/coursex=function inherit
@defattr NCParent/coursey=function inherit
@defattr NCParent/coursez=function inherit
@defattr NCParent/get_course=function inherit
@defattr NCParent/clenx=function inherit
@defattr NCParent/cleny=function inherit
@defattr NCParent/clenz=function inherit
@defattr NCParent/courselen=function inherit
@set NCParent=coursex:[first(presentcourse())]
@set NCParent=coursey:[extract(presentcourse(),2,1)]
@set NCParent=coursez:[last(presentcourse())]
@set NCParent=get_course:[coursex()].[coursey()].[coursez()]
@set NCParent=clenx:[abs(sub(coursex(),getx()))]
@set NCParent=cleny:[abs(sub(coursey(),gety()))]
@set NCParent=clenz:[abs(sub(coursez(),getz()))]
@set NCParent=courselen:[add(add(clenx(),cleny()),clenz())]
@defattr NCParent/speed=function inherit
@set NCParent=speed:0
@defattr NCParent/cmd_laycourse=inherit
@defattr NCParent/cmd_engage=inherit
@defattr NCParent/cmd_allstop=inherit
@defattr NCParent/cmd_speed=inherit
@defattr NCParent/cmd_speedset=inherit
@defattr NCParent/cmd_onscreen=inherit
@defattr NCParent/cmd_offscreen=inherit
@defattr NCParent/cmd_navon=inherit
@defattr NCParent/cmd_navoff=inherit
@defattr NCParent/cmd_shownavs=inherit
@defattr NCParent/tr_step=inherit
@defattr NCParent/tr_notify=inherit
@defattr NCParent/tr_shipmove=inherit
#mupdate on
@set NCParent=cmd_do:$>*:/[not(lor(wmatch(course engage speed view viewscreen,first(v(0))),match(v(0),all stop)))]/
@fo [ship()]={[v(0)]};
.
@set NCParent=cmd_laycourse:$course *.*.*:
@switch [land(land(isnum(v(0)),isnum(v(1))),isnum(v(2)))]=1,{
@switch [land(land(between(v(0),-499,499),between(v(1),-499,499)),between(v(2),-499,499))]=1,{
@set me=presentcourse:[v(0)] [v(1)] [v(2)];
@tr me/tr_notify={New course to \\\[get_course()] laid in},%#;
@tr me/tr_notify={Total distance is \\\[courselen()] sectors},%#;
},{
@tr me/tr_notify={That is not a valid course.},%#;
};
},{
@tr me/tr_notify={That is not a valid course.},%#;
};
.
@set NCParent=cmd_engage:$engage:
@switch [land(land(eq(getx(),coursex()),eq(gety(),coursey())),eq(getz(),coursez()))]=1,{
@tr me/tr_notify={You are already at [get_sector()]},%#;
},{
@tr me/tr_notify={Course to [coursex()].[coursey()].[coursez()] engaged},%#;
@wait 1/tr_step=@tr me/tr_step;
};
.
@set NCParent=cmd_allstop:$all stop:
@cancel [num(me)]=tr_step;
@tr me/tr_notify={The ship has stopped},%#;
.
@set NCParent=cmd_speed:$speed:
@tr me/tr_notify={The current speed is [v(speed)]},%#;
.
@set NCParent=cmd_speedset:$speed *:
@switch land(isnum(v(0)),between(v(0),0,10))=1,{
@set me=speed:[v(0)];
@tr me/tr_notify={Speed adjusted to [v(0)]},%#
},{
@tr me/tr_notify={Valid speeds are 0-10},%#;
};
.
@set NCParent=cmd_onscreen:$onscreen:
@tr [ship()]/tr_addrelay=[num(here)]:0;
@tr me/tr_notify={Ship exterior activity will now be shown to the entire bridge}
.
@set NCParent=cmd_offscreen:$offscreen:
@tr [ship()]/tr_delrelay=[num(here)]:0;
@tr me/tr_notify={Ship exterior activity will no longer shown on the bridge}
.
@set NCParent=cmd_navon:$navon:
@tr [ship()]/tr_addrelay=[num(v(#))]:0;
@tr me/tr_notify={You will now see all ship exterior activity},%#
.
@set NCParent=cmd_navoff:$navoff:
@tr [ship()]/tr_delrelay=[num(v(#))]:0;
@tr me/tr_notify={You will no longer see ship exterior activity},%#
.
@emit [ansi(y+,WARNING: Change this unparse() to a cname()!)];
.
@set NCParent=cmd_shownavs:$navlist:
@tr me/tr_notify={Ship exterior activity is currently being viewed by:},%#;
@tr me/tr_notify=[foreach(get(ship(),relay),[unparse(first(v(0),:))])],%#;
.
@set NCParent=tr_step:
@@tr me/tr_notify={Sector [[get_sector()]]};
@switch [land(land(eq(getx(),coursex()),eq(gety(),coursey())),eq(getz(),coursez()))]=1,{
@tr me/tr_notify={You have arrived at your destination};
},{
@switch [last(last(sort(s([setunion(clenx(),x,~)] [setunion(cleny(),y,~)] [setunion(clenz(),z,~)]))),~)]=x,{
@fo [ship()]=[ifelse(gt(coursex(),getx()),E,W)];
},y,{
@fo [ship()]=[ifelse(gt(coursey(),gety()),N,S)];
},z,{
@fo [ship()]=[ifelse(gt(coursez(),getz()),U,D)];
};
@@wait 2/tr_step=@tr me/tr_step;
@switch v(speed)=0,{
@cancel [num(me)]=tr_step;
@tr me/tr_notify={The ship has stopped};
},{
@wait [sub(10,v(speed))]/tr_step=@tr me/tr_step;
};
};
.
@set NCParent=tr_notify:
@switch [truth(wcount(v(0)))]=1,{
@switch [truth(wcount(v(1)))]=0,{
@emit [ansi(s(v(color)),>)] [v(0)];
},{
@foreach [v(1)]={
@pemit v(0)=[ansi(s(v(color)),>)] [v(0)];
};
};
};
.
@set NCParent=tr_shipmove:
@switch [is_a(loc(ship()),cross_mare_id(sectorparent))]=1,{
@tr me/tr_notify=[[ansi(c+,get_sector())]];
};
.
#mupdate off