-
Notifications
You must be signed in to change notification settings - Fork 8
/
Supernatural Agreement Support System.txt
2390 lines (1717 loc) · 64.1 KB
/
Supernatural Agreement Support System.txt
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
################################################################################
## SUPERNATURAL AGREEMENT SUPPORT SYSTEM #######################################
With careful application, a lot of this code can go on a parent object, with
each specific system ( pledges, pacts, baths ) can be presented on its own.
For now, the Blood-Bather Ritual system ( +baths ) is the master prototype.
================================================================================
== SETUP =======================================================================
*/
@create Supernatural Agreement Support System <SASS>=10
@fo me=&d.sass me=search( name=Supernatural Agreement Support System <SASS> )
@set Supernatural Agreement Support System <SASS>=inherit safe
@Desc [v( d.sass )]=
localize( strcat(
ansi( h, SASS Systems ), :, %b,
setq( q, iter( children( %! ), name( %i0 ), , lit( %,%b ))),
if( t( %qq ), %qq, None Yet )
))
/*
--------------------------------------------------------------------------------
-- Optional: Code Object Data Parent -------------------------------------------
*/
@fo me=@parent [v( d.sass )]=search( name=Code Object Data Parent <codp> )
&prefix.elements [v( d.sass )]=element.
&prefix.displays [v( d.sass )]=display. format.
/*
================================================================================
== DATA ========================================================================
--------------------------------------------------------------------------------
-- Data: Basic -----------------------------------------------------------------
<to be determined>
================================================================================
== CROSS-PLATFORM FUNCTIONS ====================================================
*/
&.header [v( d.sass )]=header( %0 )
&.divider [v( d.sass )]=divider( %0 )
&.footer [v( d.sass )]=footer( %0 )
&.isapproved [v( d.sass )]=isapproved( %0, %1 )
&.isstaff [v( d.sass )]=isstaff( %0 )
&.msg [v( d.sass )]=ansi( h, <%0>, n, %b%1 )
&.titlestr [v( d.sass )]=titlestr( %0, %1 )
&.crumple [v( d.sass )]=crumple( %0, %1 )
// lmax() used to not exist for TinyMUX
&.lmax [v( d.sass )]=lmax( %0, %1 )
// The following are functions known to cause cross-platform issues
// (originally written for TinyMUX 2.10)
&.itemize [v( d.sass )]=if( strlen( %1 ), itemize( %0, %1 ), itemize( %0 ))
&.wrap [v( d.sass )]=wrap( %0, %1, %2, %3, %4, %5, %6, %7 )
&.columns [v( d.sass )]=columns( %0, %1, %2, %3 )
/*
================================================================================
== ELEMENTS ====================================================================
Position is: <element name> <attribute prefix> <list position>
Validation takes: %0 - entire item to validate
Convert takes: 0: single element to convert, if list ( e.g., players )
1: should I also display the error text?
Set-Check takes: 0: < fill in later >
Display takes: %0 - list of elements to display
Filter is: How do I filter() for this? - 0: value, 2: comparison type (optional)
--------------------------------------------------------------------------------
-- Element: Name ---------------------------------------------------------------
The name of the storage group. Must exist, always.
*/
&element.name.position [v( d.sass )]=name entry. 1
&element.name.validate [v( d.sass )]=
case( 0,
t( %0 ), #-1 'Name' cannot be empty,
lte( strlen( %0 ), 30 ), #-1 'Name' must be 30 characters or less,
1
)
&element.name.display [v( d.sass )]=
localize( strcat(
setq( t, name ),
setq( v, u( .titlestr, %0 )),
setq( e, u( f.element.validate, %qt, %0 )),
if( t( %qe ),
%qv,
strcat(
ansi( r, %qv ),
if( t( %1 ), ansi( xh, %b%([rest( %qe )]%)))
)
)
))
&element.name.filter [v( d.sass )]=
localize( strcat(
setq( t, name ),
setq( e, get( %!/element.%qt.position )),
filter( fil.matches,
lattr( v( d.database )/[elements( %qe, 2 )]* ),
,
,
elements( %qe, 3 ),
%0
)
))
/*
--------------------------------------------------------------------------------
-- Element: Expires ------------------------------------------------------------
When does this element expire?
This is in most versions, so it's kept on the parent.
*/
&element.expires.position [v( d.sass )]=expires entry. 2
&element.expires.validate [v( d.sass )]=
case( 0,
comp( %0, ), #-1 'Expires' cannot be empty,
isint( %0 ), #-1 'Expires' not in the expected format,
gt( %0, secs()), #-1 'Expires' has passed,
1
)
&element.expires.convert [v( d.sass )]=
switch( %0,
@@( null ), @@( is null ),
now, secs(),
da*, add( secs(), 86400 ),
wee*, add( secs(), 604800 ),
mon*, add( secs(), 2419200 ),
qua*, add( secs(), 7689600 ),
sem*, add( secs(), 15811200 ),
yea*, add( secs(), 31622400 ),
fiv*, add( secs(), 158112000 ),
convtime(
[mid( %0, 0, 4 )]-
[mid( %0, 4, 2 )]-
[mid( %0, 6, 2 )]
[extract( time(), 4, 1 )]
)
)
&element.expires.display [v( d.sass )]=
localize( strcat(
setq( t, expires ),
setq( v, if( isint( %0 ), timefmt( $Y-$m-$d, %0 ), %0 )),
setq( e, u( f.element.validate, %qt, %0 )),
if( t( %qe ),
%qv,
[ansi( r, %qv )]
[if( t( %1 ), ansi( xh, %b%([rest( %qe )]%)))]
)
))
// --
&element.filter.expires [v( d.sass )]=
localize( strcat(
setq( t, expires )
setq( e, get( %!/element.%qt.position ))
setq( k,
case( %2,
>, is_more,
<, is_less,
=, is,
switch( %2, gr*, is_more, mo*, is_more, le*, is_less, is )
)
),
filter( fil.%qk,
lattr( v( d.database )/[elements( %qe, 2 )]* ),
, , elements( %qe, 3 ), %0
)
)
/*
--------------------------------------------------------------------------------
-- Element: Players ------------------------------------------------------------
A list of players associated with the element. Common, so left on parent.
*/
&element.players.position [v( d.sass )]=players entry. 3
&element.players.validate [v( d.sass )]=
localize(
case( 0,
t( %0 ),
#-1 'Players' list cannot be empty,
iter( %0,
case( 0,
t( pmatch( %i0 )), #-1 Player not found,
u( .isapproved, %i0, approved ), #-1 Player not approved,
not( u( .isapproved, %i0, frozen )), #-1 Player is frozen,
1
),
, |
)
)
)
&element.players.convert [v( d.sass )]=iter( %0, pmatch( %i0 ))
// Each system attached to this should check this as their needs.
&element.players.set-check [v( d.sass )]=1
&element.players.display [v( d.sass )]=
localize( strcat(
setq( t, players ),
iter( %0,
strcat(
setq( e, u( f.element.validate, %qt, %i0 )),
setq( v, name( %i0 )),
if( strmatch( %qe, #-* ),
strcat(
ansi( r, %qv ),
if( t( %1 ), ansi( xh, %b%([rest( %qe )]%) ))
),
%qv
)
),
, %,%b
)
))
&element.players.filter [v( d.sass )]=
localize( strcat(
setq( t, players ),
setq( e, get( %!/element.%qt.position )),
filter( fil.is,
lattr( v( d.database )/[elements( %qe, 2 )]* ),
, , elements( %qe, 3 ), %0
)
)
/*
--------------------------------------------------------------------------------
-- Element: Text ---------------------------------------------------------------
The filler note-text. Always available.
*/
&element.text.position [v( d.sass )]=text text. 1
// text is always valid
&element.text.validate [v( d.sass )]=1
&element.text.filter [v( d.sass )]=
localize( strcat(
setq( t, text ),
setq( e, get( %!/element.%qt.position )),
filter( fil.matches,
lattr( v( d.database )/[elements( %qe, 2 )]* ),
, , elements( %qe, 3 ), %0
)
)
/*
--------------------------------------------------------------------------------
-- Element: Others -------------------------------------------------------------
Other elements will be generated on each sub-system.
================================================================================
== FUNCTIONS ===================================================================
--------------------------------------------------------------------------------
-- Function: Elements' Position List -------------------------------------------
0: list|of|elements
returns: The entire data segments from that list, |-delimited, partial-matches
*/
&f.list.elements.position [v( d.sass )]=
iter(
%0,
iter(
lattrp( %!/element.[edit( %i0, %b, _ )]*.position ),
v( %i0 ),
, |
),
, |
)
/* -- test --
think u( v( d.sass )/f.list.elements.position, * )
think u( v( d.sass )/f.list.elements.position, b )
think u( v( d.sass )/f.list.elements.position, b t )
think u( v( d.sass )/f.list.elements.position, p b )
--------------------------------------------------------------------------------
-- Function: Validate Element --------------------------------------------------
0: Element to validate (name completed already?)
1: Item(s) to validate
m: message returned from validation
returns: list|of|validations, where appropriate
*/
&f.element.validate [v( d.sass )]=
localize(
case( 1,
strmatch( %1, *|* ),
#-1 [capstr( lcstr( %0 ))] may not contain pipe character,
strmatch( setr( m, udefault( element.%0.validate, 1, %1 )), *#-* ),
%qm,
1
)
)
/* -- test --
think u( v( d.sass )/f.element.validate, name, this|isatest )
think u( v( d.sass )/f.element.validate, name, )
think u( v( d.sass )/f.element.validate, expires, 123 )
think u( v( d.sass )/f.element.validate, expires, abc )
think u( v( d.sass )/f.element.validate, players, #1 #999 )
think u( v( d.sass )/f.element.validate, text, )
--------------------------------------------------------------------------------
-- Function: Convert Element ---------------------------------------------------
0: element name ( validated )
1: data to convert
returns: conversion process, or %1 if not found
Simple.
*/
&f.element.convert [v( d.sass )]=udefault( element.%0.convert, %1, %1 )
/* -- test --
think u( v( d.sass )/f.element.convert, name, This is a name )
think u( v( d.sass )/f.element.convert, expires, quarter )
think u( v( d.sass )/f.element.convert, players, thenomain troy )
--------------------------------------------------------------------------------
-- Function: Display Element ---------------------------------------------------
0: element name ( validated )
1: data to display
2: 'true' if details about the error are desired
returns: Processed & errored data, else
*/
&f.element.display [v( d.sass )]=udefault( element.%0.display, %1, %1, %2 )
/* -- test --
think u( v( d.sass )/f.element.display, name, this|isatest )
think u( v( d.sass )/f.element.display, name, this|isatest, 1 )
think u( v( d.sass )/f.element.display, name, , 1 )
think u( v( d.sass )/f.element.display, expires, 1234567 )
think u( v( d.sass )/f.element.display, expires, abc, 1 )
think u( v( d.sass )/f.element.display, players, #1 #999 #188 )
think u( v( d.sass )/f.element.display, players, #1 #999 #188, 1 )
think u( v( d.sass )/f.element.display, text, @@( it's null ), 1 )
--------------------------------------------------------------------------------
-- Function: Get Elements ------------------------------------------------------
0: entry #
1: element(s)
e: element positions list
*/
&f.get.entry.elements [v( d.sass )]=
localize( strcat(
setq( e, u( f.list.elements.position, %1 )),
case( 0,
comp( %qe, ),
#-1 Element(s) requested unknown,
t( get( u( d.database )/entry.%0 )),
#-1 Entry #%0 Not Found,
iter( %qe,
extract(
u( u( d.database )/[elements( %i0, 2 )]%0 ),
last( %i0 ),
1,
|
),
|, |
)
)
))
/*
--------------------------------------------------------------------------------
-- Function: Set Elements ------------------------------------------------------
0: entry #
1: element
2: value
p: element position
n: new element to set
a: attribute for element+entry
w: can't remember
e: possible error
*/
&f.set.entry.element [v( d.sass )]=
localize( strcat(
setq( p, u( f.list.elements.position, %1 )),
setq( a, [extract( %qp, 2, 1 )]%0 ),
setq( w, elements( %qp, 3 )),
case( 0,
comp( %qp, ),
#-1 Element requested unknown,
eq( words( %qp, | ), 1 ),
#-1 Multiple elements found,
hasattr( u( d.database ), entry.%0 ),
#-1 Entry #%0 Not Found,
// if there are special conditions on setting the entry's element
t(
setr( e,
udefault( element.[first( %qp )].set-check, 1, %0, %2 )
)
),
%qe,
// default:
// if an element hasn't been set on an attribute, assume it's the only one
// (note: this is done during the setup +command, but we're correcting for
// the behavior of 'replace()' with null lists)
strcat(
setq( n, ulocal( u( d.database )/%qa )),
setq( n,
if( strlen( %qn ),
replace( %qn, %qw, %2, | ),
%2
)
),
setq( e, set( u( d.database ), %qa:%qn )),
if( comp( %qe, ),
#-1 Error setting the attribute%; aborted,
Set entry #%0's [first( %qp )] to '%2'
)
)
)
))
/*
--------------------------------------------------------------------------------
-- Function: Counter - Entries -------------------------------------------------
List the numbers for all entries, sorted.
*/
&f.counter.entries [v( d.sass )]=
sort( edit( lattr( u( d.database )/entry.* ), ENTRY., ))
/*
--------------------------------------------------------------------------------
-- Function: Counter - Free ----------------------------------------------------
Return the numerically lowest free entry.
*/
&f.counter.free [v( d.sass )]=
localize(
first(
setdiff(
lnum( 1, inc( lmax( setr( n, u( f.counter.entries ))))),
%qn,
, , n
)
)
)
/* -- test --
think u( v( d.sass )/f.counter.free )
================================================================================
== MISTRESS COMMANDS ===========================================================
The "Mistress" Command structure (from Seth, AetherMux) allows a generic sorting
system for easy refactoring.
It is entirely function-based. Use trigger( ) when necessary.
--------------------------------------------------------------------------------
-- Mistress: Primary Command ---------------------------------------------------
1: /switches
2: text
*/
&c.sass [v( d.sass )]=$+sass*:@pemit %#=
u( .msg, S.A.S.S.,
The following Supernatural Agreement systems are known:
[setq( q, iter( children( %! ), name( %i0 ), , | ))]
[if( t( %qq ), u( .itemize, %qq, | ), None Yet )]
)
// --
@set v( d.sass )/c.sass=no_inherit
/*
--------------------------------------------------------------------------------
-- Mistress: Switches ----------------------------------------------------------
0: <command name>, passed up from Sub-Mistress systems ( e.g., 'baths' )
1: /switch/es
2: text ( if passed )
n: command name ( 'baths' )
s: switches found ( c.baths/* )
p: pseudo-switches ( others )
a: attributes to check ( c.switch/<switch> )
*/
&c.mistress.switch [v( d.sass )]=
strcat(
setq( n, %0 ),
setq( s, ),
setq( p, ),
setq( a, lattrp( %!/c.switch/* )),
// filter real (%qs) and psudo-switches (%qp)
iter( rest( %1, / ),
if( t( grab( %qa, c.switch/%i0* )),
setq( s, %qs/[rest( grab( %qa, c.switch/%i0* ), / )] ),
setq( p, %qp/%i0 )
),
/,
@@
),
// process:
if( t( %qs ),
// .. pass to first real-switch passed
ulocal( c.switch/[extract( %qs, 2, 1, / )], %0, %2, %qp ),
// .. else pass to '.specific' or '.default' with pseudo-switches
if( t( %2 ),
ulocal( c.mistress.specific, %0, %2, %qp ),
ulocal( c.mistress.default, %0, %qp )
)
)
)
/*
--------------------------------------------------------------------------------
-- Mistress: Default -----------------------------------------------------------
0: <command name>
1: psudo-switches, if passed (error'd, for now)
*/
&c.mistress.default [v( d.sass )]=
if( strlen( %1 ),
// error on psudo-switches
u( .msg, lcstr( %0 ), I don't recognize that switch ),
// else: ok
u( c.switch/view, %0 )
)
/*
--------------------------------------------------------------------------------
-- Mistress: Specific ----------------------------------------------------------
0: <command name>
1: text
2: psudo-switches, if passed ( errored, for now )
*/
&c.mistress.specific [v( d.sass )]=
if( strlen( %2 ),
// error on psudo-switches
u( .msg, lcstr( %0 ), I don't recognize that switch ),
// else: ok
u( c.switch/view, %0, %1 )
)
/*
================================================================================
== SWITCHED COMMANDS ===========================================================
For all these commands:
attribute name: &c.switch/<switch name>
0: <cmd>
1: <text>
2: psudo-switches, if any
--------------------------------------------------------------------------------
-- /view -----------------------------------------------------------------------
+<cmd>/view [<entry num>]
Display one or all possible items.
0: <cmd>
1: entry num, if any
2: pseudo-switches, ignored
l: list of pledges visible to the player; sorted by num desc
*/
&c.switch/view [v( d.sass )]=
if( strlen( %1 ),
// >> display one entry
case( 0,
and( isint( %1 ), gt( %1, 0 )),
u( .msg, %0, Lookup must be a positive number ),
cor(
isstaff( %# ),
t( match( u( f.get.entry.elements, %1, players ), %# ))
),
u( .msg, %0, You may not view someone else's entry ),
t( get( u( d.database )/entry.%1 )),
u( .msg, %0, Entry not found ),
u( display.entry.full, %0, %1, +%0/view %1 )
),
// >> display all entries
u( display.entry.all, %0 )
)
/*
--------------------------------------------------------------------------------
-- /new ------------------------------------------------------------------------
+<cmd>/new <name>
Create a new element.
e: Possible error
n: name for entry ( %0 )
c: next available counter
a: the 'name' position list: name <prefix.> <position #>
p: <prefix.>
r: item to set on the attribute '<prefix.>%qc'
*/
&c.switch/new [v( d.sass )]=
strcat(
setq( n, u( .titlestr, %1 )),
setq( c, u( f.counter.free )),
setq( a, v( element.name.position )),
setq( p, elements( %qa, 2 )),
setq( r,
repeat( |,
add(
words( grepi( %!, element.*.position, %qp )),
words( grepi( parent( %! ), element.*.position, %qp )),
-1
)
)
),
setq( r, replace( %qr, last( %qa ), %qn, |, | )),
// .. error-check
case( 0,
u( .isstaff, %# ),
u( .msg, %0/new, This command is staff-only ),
t( setr( e, u( f.element.validate, name, %1 ))),
u( .msg, %0/new, rest( %qe )),
not( comp(
set( u( d.database ), %qp%qc:%qr ),
@@( null )
)),
u( .msg, %0/new, Could not set initial entry for #%qc%; aborted ),
// .. ok -- set up any other entry prefixes that need it
// .. .. for each prefix, scan that prefix and add the |-delims for it
// .. >> we rely upon replace( ), which needs the delims there first
[iter(
setdiff(
iter(
lattrp( %!/element.*.position ),
elements( v( %i0 ), 2 )
),
entry.
),
set( u( d.database ),
%i0%qc:
[repeat( |,
dec( words( grepi( %!, element.*.position, %i0 )))
)]
),
, @@
)]
u( .msg, %0/new,
Set up new [strtrunc( %0, dec( strlen( %0 )))]
[ansi( h, #%qc )] with name '%qn'
)
)
)
/*
--------------------------------------------------------------------------------
-- /delete ---------------------------------------------------------------------
+<cmd>/delete <number>[=YES]
*/
&c.switch/delete [v( d.sass )]=
strcat(
setq( n, before( %1, = )),
setq( v, rest( %1, = )),
case( 0,
u( .isstaff, %# ),
u( .msg, %0/delete, Staff only ),
eq( attrcnt( u( d.database )/entry.%qn ), 1 ),
u( .msg, %0/delete, Entry not found ),
not( comp( %qv, YES )),
u( .msg, %0/delete,
If you are absolutely sure you want to delete this entry%,
type: +%0/delete %qn=YES
),
strcat(
u( .header, [u( .titlestr, %0 )]: Deleting #%qn ), %r,
ulocal( display.entry.full, %0, %qn ), %r,
// find every attribute prefix to clear for this.
setq( a,
setunion(
iter(
u( f.list.elements.position, * ),
elements( %i0, 2 ),
|
),
)
),
// Try to delete them, count the errors
setq( e,
iter( %qa,
set( u( d.database ), %i0%qn: ),
, |
)
),
// In footer, report errors found
u( .footer,
if( strlen( edit( %qe, |, )),
iter( %qe,
if( t( %i0 ),
error clearing
&[capstr( first( elements( %qa, inum()), . ))]%b
),
|,
@@
),
Deleted
)
),
)
)
)
/*
--------------------------------------------------------------------------------
-- /prove ----------------------------------------------------------------------
+<cmd>/prove <num>[/<element/list>]=<player list>
Prove an entry's element(s) to another player.
n: entry number
e: elements to check, else '#-2 full' for all of it
l: list|of|element|positions
p: player targets
d: dbrefs of player targets
*/
&c.switch/prove [v( d.sass )]=
strcat(
setq( n, first( before( %1, = ), / )),
setq( e,
if( setr( e, before( rest( %1, / ), = )),
%qe,
#-2 Display Entire Entry
)
),
setq( l,
u( .crumple,
iter(
ulocal( f.list.elements.position,
u( .crumple,
edit( %qe, /, %b )
)
),
first( %i0 ),
|, |
),
|
)
),
setq( p, rest( %1, = )),
setq( d, iter( %qp, if( t( setr( d, pmatch( %i0 ))), %qd ))),
case( 0,
and( isint( %qn ), gt( %qn, 0 )),
u( .msg, %0/prove, Lookup must be a positive integer ),
t( get( u( d.database )/entry.%qn )),
u( .msg, %0/prove, Entry not found ),
u( fil.entry.can-see, entry.%qn, %# ),
u( .msg, %0/prove, You have no access to that entry ),
cor( not( %qp ), t( %qd )),
u( .msg, %0/prove, No target players matched ),
cor( words( %ql ), strmatch( %qe, #-2* )),
u( .msg, %0/prove, Element(s) not found. ),
pemit(
if( t( %qd ), setunion( %# %qd, ), lcon( loc( %# ))),
u( display.entry.prove, %0, %qn, %ql, %qp )
)
)
)
/*
--------------------------------------------------------------------------------
-- /set ------------------------------------------------------------------------
+<cmd>/set <number>/<element>=<value>
Set <value> to <element>.
n: entry number
e: element
v: new value
*/
&c.switch/set [v( d.sass )]=
strcat(
setq( n, first( %1, / )),
setq( e, rest( first( %1, = ), / )),
setq( e, u( f.list.elements.position, %qe )),
setq( v, last( %1, = )),
case( 0,
u( .isstaff, %# ), u( .msg, %0/set, Staff only ),
t( %qn ), u( .msg, %0/set, Number not entered ),
t( %qe ), u( .msg, %0/set, Element not found ),
attrcnt( u( d.database )/entry.%qn ),
u( .msg, %0/set, Entry not found ),
eq( words( %qe, | ), 1 ),
u( .msg,
%0/set,
Multiple elements match: [iter( %qe, first( %i0 ), |, %,%b )]
),
comp( %qe, ), u( .msg, %0/set, Element not found ),
u( f.switch/set.workhorse, %0, %qn, first( %qe ), %qv )
)
)
/*
--------------------------------------------------------------------------------
-- /set.workhorse ------------------------------------------------------------
Does most of the checking and heavy lifting of editing an element.
0: <cmd>
1: entry number ( validated )
2: element name ( validated, only one )
3: new value ( not validated )
p: existing element's pledge data
c: converted value
v: validation result
e: element's set-check
*/
&f.switch/set.workhorse [v( d.sass )]=
strcat(
setq( p, ulocal( f.get.entry.elements, %1, %2 )),
setq( c, ulocal( f.element.convert, %2, %3 )),
setq( v, ulocal( f.element.validate, %2, %qc )),
// extra element-based checks, "1" if valid or not checked
setq( e,
udefault( element.%2.set-check, 1, %1 )
),
// process
case( 0,
t( %qv ), u( .msg, %0/set, rest( %qv )),
not( strmatch( %qe, #-1* )), u( .msg, %0/set, rest( %qe )),
// .. ok
u( f.switch/set.process, %0, %1, %2, %qp, %qc )
)
)