Date: 2014/09/23 22:51:27 UTC-07:00
Type: Denizen Script
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
# Script that replaces predefined characters for their ASCII equivalents
# Utilizes a database to read from.
"Determine Word Replacement":
#############################################################################################################################
# #
# Specific to the word replacement typing as it checks the sai database script for its values #
# #
#############################################################################################################################
type: procedure
definitions: word
script:
#Selective escaping
- define replacement <def[word].replace[<&dot>].with[$dot$]>
# made by reason of the root node
# This script fails here as its got issues parsing tags within the wrong place (prob right after the 2nd '[')
- define replacement <yaml[word_replacement].read[Replace.<def[replacement]>]>
- define replacement <def[replacement].replace[$dot$].with[<&dot>]>
- if <def[replacement]> != null {
- define word <def[replacement]>
}
- determine <def[word]>
# The issue is where you start to add the arguments to this script as the <def[new_list]||li@>. The fallback fails or gets parsed
# diferently... but Ive checked.
# edit: fixed the line -define bad_list... the first arg to list append right was the incorrect list reference.
List Append Right:
#############################################################################################################################
# #
# Takes an escaped <escape:iterable> #
# Takes a value to append to that iterable (can be another list :) ) #
# Returns a list #
# notice: This escapes the return value. Youll NEED TO <unescape:> or <element.unescaped>IT FIRST! #
# #
# ex: #
# - define griefer_list <p@chemical_Datas>|<p@calico-kid>|<p@ghost_bawb>|<p@noobzilla> #
# - foreach <def[griefer_list].as_list> { #
# - if !<def[value].is_op> { #
# - define bad_list "<proc[List Append Right].context[<def[bad_list]||li@>|<def[value]>]>" #
# } #
# } #
# #in some other script that recieved a list from this..... #
# - foreach <def[bad_list].unescaped> { #
# - execute as_server "ban <def[value].name>" #
# } #
# #
#############################################################################################################################
debug: false
type: procedure
definitions: iterable|value
script:
- announce "iterable<&co> <blue><def[iterable]>"
- define iterable <def[iterable].unescaped||none>
- announce "iterable<&co> <blue><def[iterable]>"
- if <def[iterable]> == none {
- determine <def[value].unescaped.as_list.escaped||<li@.escaped>>
} else {
- determine <def[iterable].as_list.include[<def[value].unescaped.as_list||li@>].escaped>
}
#edit: example: the 2nd time - define op_locations comes up, the procedure should be 'list append right' as that matches the way the args are passed to it.
#edit: example: the other fix is the first argument to the example definition op_locations. Changed from <escape:list> to <def[op_locations]||li@>
#edit: example: the list fix is the second argument to the example define op_locations. Changed <el@%value%.length> to <def[value].length>
Transform List:
#############################################################################################################################
# #
# The idea is that it takes a list then a string to apply to each element in that list #
# #
# #
# ex: #
# <server.list_online_ops> | name #
# turns it into a list of player names #
# ex: #
# define op_locations "<proc[Transform List].context[''|<escape:<server.list_online_ops>>|location]>" #
# instead of: #
# - foreach <server.list_online_ops> { #
# - define op_locations "<proc[List Append Left].context[<escape:list>|<%value%.location>]>" #
# } #
# #
# - define name_length "<proc[Transform List].context[<escape:el@>|<escape:<server.list_online_players>>|length]>" #
# instead of: #
# - foreach <server.list_online_players> { #
# - define op_locations "<proc[List Append Right].context[<def[op_locations]||li@>|<def[value].length>]>" #
# } #
# #
#############################################################################################################################
type: procedure
definitions: precursor|list|transformer
script:
- define precursor "<def[precursor].unescaped||>"
- foreach <def[list].unescaped.as_list> {
- announce "before transformer <def[value]>"
- define new_value <%precursor%%value%.%transformer%>
- announce "after transformer <def[new_value]>"
- define return "<proc[List Append Right].context[<def[return]||li@>|%new_value%]>"
- announce "after list append <def[return].unescaped>"
}
- determine <def[return].unescaped>
tlist:
type: procedure
script:
- determine "<proc[Transform List].context[|<server.list_online_players.escaped>|location|]>"