tpmkms_4wp 7.12.7 → 7.12.8-beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. package/common/animals.instance.json +0 -44
  2. package/common/dialogues.js +106 -3
  3. package/common/dimension.instance.json +736 -62
  4. package/common/dimension.js +15 -7
  5. package/common/edible.instance.json +2 -190
  6. package/common/fastfood.instance.json +886 -922
  7. package/common/formulas.instance.json +992 -0
  8. package/common/formulas.js +18 -5
  9. package/common/formulas.test.json +1187 -3651
  10. package/common/length.instance.json +261 -505
  11. package/common/math.instance.json +1979 -1
  12. package/common/math.js +17 -5
  13. package/common/ordering.instance.json +0 -52
  14. package/common/pipboy.instance.json +23454 -1101
  15. package/common/pipboy.js +31 -4
  16. package/common/pipboy.test.json +13 -9
  17. package/common/pokemon.instance.json +0 -44
  18. package/common/pressure.instance.json +80 -0
  19. package/common/reports.instance.json +17 -1
  20. package/common/temperature.instance.json +80 -60
  21. package/common/ui.instance.json +8 -0
  22. package/common/weight.instance.json +272 -48
  23. package/main.js +0 -8
  24. package/package.json +4 -20
  25. package/common/dimensionTemplate.instance.json +0 -582
  26. package/common/dimensionTemplate.js +0 -35
  27. package/common/dimensionTemplate.test.json +0 -2
  28. package/common/formulasTemplate.instance.json +0 -483
  29. package/common/formulasTemplate.js +0 -30
  30. package/common/formulasTemplate.test.json +0 -2
  31. package/common/mathTemplate.instance.json +0 -1635
  32. package/common/mathTemplate.js +0 -32
  33. package/common/mathTemplate.test.json +0 -1422
  34. package/common/pipboyTemplate.instance.json +0 -17420
  35. package/common/pipboyTemplate.js +0 -48
  36. package/common/pipboyTemplate.test.json +0 -2
@@ -5926,28 +5926,6 @@
5926
5926
  1
5927
5927
  ]
5928
5928
  ],
5929
- [
5930
- [
5931
- "bird",
5932
- 0
5933
- ],
5934
- [
5935
- "is",
5936
- 0
5937
- ],
5938
- [
5939
- "list",
5940
- 0
5941
- ],
5942
- [
5943
- "unknown",
5944
- 0
5945
- ],
5946
- [
5947
- "unknown",
5948
- 1
5949
- ]
5950
- ],
5951
5929
  [
5952
5930
  [
5953
5931
  "bird",
@@ -8774,28 +8752,6 @@
8774
8752
  1
8775
8753
  ]
8776
8754
  ],
8777
- [
8778
- [
8779
- "bird",
8780
- 0
8781
- ],
8782
- [
8783
- "is",
8784
- 0
8785
- ],
8786
- [
8787
- "list",
8788
- 0
8789
- ],
8790
- [
8791
- "unknown",
8792
- 0
8793
- ],
8794
- [
8795
- "unknown",
8796
- 1
8797
- ]
8798
- ],
8799
8755
  [
8800
8756
  [
8801
8757
  "bird",
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { Config, knowledgeModule, where, stableId } = require('./runtime').theprogrammablemind
2
2
  const meta = require('./meta.js')
3
3
  const gdefaults = require('./gdefaults.js')
4
4
  const sdefaults = require('./sdefaults.js')
@@ -893,6 +893,105 @@ let configStruct = {
893
893
  ],
894
894
  };
895
895
 
896
+ // move ask to the KM's since verbatim is called probably in dialogues?
897
+ const getAsk = (config) => (uuid) => {
898
+ // if (!uuid) {
899
+ // debugger
900
+ //}
901
+ return (asks) => {
902
+ const ask = (ask) => {
903
+ let oneShot = true // default
904
+ if (ask.oneShot === false) {
905
+ oneShot = false
906
+ }
907
+
908
+ const id_q = stableId('semantic')
909
+ const id_rs = []
910
+ let wasAsked = false
911
+ let wasApplied = false
912
+ const getWasAsked = () => {
913
+ return wasAsked
914
+ }
915
+ const setWasAsked = (value) => {
916
+ wasAsked = value
917
+ }
918
+ const getWasApplied = () => {
919
+ return wasApplied
920
+ }
921
+ const setWasApplied = (value) => {
922
+ wasApplied = value
923
+ }
924
+
925
+ const semanticsr = ask.semanticsr || []
926
+ if (semanticsr.length == 0) {
927
+ semanticsr.push({ match: ask.matchr, apply: ask.applyr })
928
+ }
929
+ for (const semantic of semanticsr) {
930
+ const id_r = stableId('semantic')
931
+ id_rs.push(id_r)
932
+ config.addSemantic({
933
+ uuid,
934
+ id: id_r,
935
+ tied_ids: [id_q],
936
+ oneShot,
937
+ where: semantic.where || ask.where || where(2),
938
+ source: 'response',
939
+ match: (args) => semantic.match(args),
940
+ apply: (args) => {
941
+ setWasApplied(true)
942
+ semantic.apply(args)
943
+ },
944
+ })
945
+ }
946
+
947
+ config.addSemantic({
948
+ uuid,
949
+ oneShot,
950
+ id: id_q,
951
+ tied_ids: id_rs,
952
+ where: ask.where,
953
+ isQuestion: true, // do one question at a time
954
+ getWasAsked,
955
+ getWasApplied,
956
+ onNevermind: ask.onNevermind,
957
+ source: 'question',
958
+ match: ({ context }) => context.marker == 'controlEnd' || context.marker == 'controlBetween',
959
+ apply: (args) => {
960
+ let matchq = ask.matchq
961
+ let applyq = ask.applyq
962
+ if (!matchq) {
963
+ let wasAsked = false
964
+ matchq = () => !wasAsked,
965
+ applyq = (args) => {
966
+ wasAsked = true
967
+ return ask.applyq(args)
968
+ }
969
+ }
970
+ if (matchq(args)) {
971
+ setWasAsked(true)
972
+ setWasApplied(false)
973
+ // args.context.motivationKeep = true
974
+ args.verbatim(applyq(args))
975
+ /*
976
+ args.context.verbatim = applyq(args)
977
+ args.context.isResponse = true;
978
+ delete args.context.controlRemove;
979
+ */
980
+ args.context.controlKeepMotivation = true
981
+ }
982
+ args.context.cascade = true
983
+ }
984
+ })
985
+ }
986
+ if (!Array.isArray(asks)) {
987
+ asks = [asks]
988
+ }
989
+
990
+ [...asks].reverse().forEach( (a) => ask(a) )
991
+ }
992
+ }
993
+
994
+
896
995
  const createConfig = () => {
897
996
  const config = new Config(configStruct, module)
898
997
  config.stop_auto_rebuild()
@@ -904,7 +1003,7 @@ const createConfig = () => {
904
1003
  e: (context) => config.api.getEvaluator(args.s, args.log, context),
905
1004
  }))
906
1005
  */
907
- config.addArgs(({isA}) => ({
1006
+ config.addArgs(({config, isA}) => ({
908
1007
  isAListable: (context, type) => {
909
1008
  if (context.marker == 'list' || context.listable) {
910
1009
  return context.value.every( (element) => isA(element.marker, type) )
@@ -912,7 +1011,7 @@ const createConfig = () => {
912
1011
  return isA(context.marker, type)
913
1012
  }
914
1013
  },
915
- toContext(v) {
1014
+ toContext: (v) => {
916
1015
  if (Array.isArray(v)) {
917
1016
  return { marker: 'list', level: 1, value: v }
918
1017
  }
@@ -921,6 +1020,10 @@ const createConfig = () => {
921
1020
  }
922
1021
  return v
923
1022
  },
1023
+ getUUIDScoped: (uuid) => { return {
1024
+ ask: getAsk(config)(uuid),
1025
+ }
1026
+ },
924
1027
  }))
925
1028
  objects.mentioned = []
926
1029
  objects.variables = {