tpmkms_4wp 7.4.3-beta.5 → 7.4.3-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of tpmkms_4wp might be problematic. Click here for more details.
- package/common/pipboy.instance.json +2 -0
- package/common/pipboy.js +131 -0
- package/common/pipboy.test.json +1430 -0
- package/package.json +5 -2
package/common/pipboy.js
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
const { Config, knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
|
2
|
+
const hierarchy = require('./hierarchy.js')
|
3
|
+
const pipboy_tests = require('./pipboy.test.json')
|
4
|
+
|
5
|
+
class API {
|
6
|
+
// id in stats, inv, data, map, radio
|
7
|
+
setDisplay(id) {
|
8
|
+
this.objects.display = id
|
9
|
+
}
|
10
|
+
|
11
|
+
setWeapon(id) {
|
12
|
+
}
|
13
|
+
|
14
|
+
getWeapons() {
|
15
|
+
}
|
16
|
+
}
|
17
|
+
const api = new API()
|
18
|
+
|
19
|
+
let config = {
|
20
|
+
name: 'pipboy',
|
21
|
+
operators: [
|
22
|
+
"([show] ([showable|]))",
|
23
|
+
"(([content]) [tab])",
|
24
|
+
],
|
25
|
+
bridges: [
|
26
|
+
{
|
27
|
+
id: "show",
|
28
|
+
isA: ['verby'],
|
29
|
+
level: 0,
|
30
|
+
bridge: "{ ...next(operator), showable: after[0] }",
|
31
|
+
generatorp: ({context, g}) => `show ${g(context.showable)}`,
|
32
|
+
semantic: ({api, context}) => {
|
33
|
+
debugger;
|
34
|
+
api.setDisplay(context.showable.value)
|
35
|
+
}
|
36
|
+
},
|
37
|
+
{
|
38
|
+
id: "tab",
|
39
|
+
level: 0,
|
40
|
+
isA: ['showable'],
|
41
|
+
bridge: "{ ...next(operator), showable: before[0], modifiers: ['showable'] }"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
id: "showable",
|
45
|
+
level: 0,
|
46
|
+
isA: ['theAble'],
|
47
|
+
bridge: "{ ...next(operator) }" ,
|
48
|
+
},
|
49
|
+
{
|
50
|
+
id: "content",
|
51
|
+
level: 0,
|
52
|
+
isA: ['showable'],
|
53
|
+
bridge: "{ ...next(operator) }" ,
|
54
|
+
words: [['stat', 'stats'], ['stats', 'stats'], ['statistics', 'stats'], ['inventory', 'inv'], ['data', 'data'], ['map', 'map'], ['radio', 'radio']].map(
|
55
|
+
([word, value]) => { return { word, value } })
|
56
|
+
},
|
57
|
+
],
|
58
|
+
|
59
|
+
generators: [
|
60
|
+
{
|
61
|
+
where: where(),
|
62
|
+
match: ({context}) => context.marker == 'currency' && !context.isAbstract,
|
63
|
+
apply: ({context, g}) => {
|
64
|
+
word = Object.assign({}, context.amount)
|
65
|
+
word.isAbstract = true
|
66
|
+
word.marker = 'currency'
|
67
|
+
word.units = context.units
|
68
|
+
word.value = context.amount.value
|
69
|
+
// generator = [({context}) => context.marker == 'currency' && context.units == words.units && context.value > 1 && context.isAbstract, ({context, g}) => words.many ]
|
70
|
+
return `${g(context.amount.value)} ${g(word)}`
|
71
|
+
}
|
72
|
+
},
|
73
|
+
],
|
74
|
+
|
75
|
+
semantics: [
|
76
|
+
{
|
77
|
+
match: ({objects, context}) => context.marker == 'in',
|
78
|
+
where: where(),
|
79
|
+
apply: ({objects, api, context}) => {
|
80
|
+
const from = context.from
|
81
|
+
const to = context.to
|
82
|
+
const value = api.convertTo(from.amount.value, from.units, to.units)
|
83
|
+
context.marker = 'currency'
|
84
|
+
context.isAbstract = false
|
85
|
+
context.amount = { value }
|
86
|
+
context.units = to.units
|
87
|
+
context.isResponse = true
|
88
|
+
}
|
89
|
+
}
|
90
|
+
],
|
91
|
+
};
|
92
|
+
|
93
|
+
config = new Config(config, module)
|
94
|
+
config.add(hierarchy)
|
95
|
+
config.api = api
|
96
|
+
config.initializer( ({config, objects, api, uuid}) => {
|
97
|
+
/*
|
98
|
+
units = api.getUnits()
|
99
|
+
for (word in units) {
|
100
|
+
words = config.get('words')
|
101
|
+
def = {"id": "currency", "initial": { units: units[word] }, uuid}
|
102
|
+
if (words[word]) {
|
103
|
+
words[word].push(def)
|
104
|
+
} else {
|
105
|
+
words[word] = [def]
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
unitWords = api.getUnitWords();
|
110
|
+
for (let words of unitWords) {
|
111
|
+
config.addGenerator(
|
112
|
+
({context}) => context.marker == 'currency' && context.units == words.units && context.value == 1 && context.isAbstract,
|
113
|
+
({context, g}) => words.one, uuid
|
114
|
+
);
|
115
|
+
config.addGenerator(
|
116
|
+
({context}) => context.marker == 'currency' && context.units == words.units && !isNaN(context.value) && (context.value != 1) && context.isAbstract,
|
117
|
+
({context, g}) => words.many, uuid
|
118
|
+
)
|
119
|
+
}
|
120
|
+
*/
|
121
|
+
})
|
122
|
+
|
123
|
+
knowledgeModule({
|
124
|
+
module,
|
125
|
+
description: 'Control a pipboy with speech',
|
126
|
+
config,
|
127
|
+
test: {
|
128
|
+
name: './pipboy.test.json',
|
129
|
+
contents: pipboy_tests
|
130
|
+
},
|
131
|
+
})
|