Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

43
LINES

< > BotCompany Repo | #1022220 // Gazelle Dialog Runner [Demo]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (2885L/15K).

!7

cmodule GDialogRunner > DynPrintLog {
  GModuleInfo gInfo;
  
  LS dialog = tlft([[
    can you add numbers?
    sure. which numbers would you like to add?
    5
    ok, and?
    3
    that makes 8
    thanks
  ]]);
  
  int index = 1; // first line is trigger
  
  S answer(S s) {
    if (nextLineIsBotLine())
      ret nextLine();
    S line = nextLine();
    if (match(line, ai_dropLeadingPhrases_one(s, "ok")))
      ret nextLine();
    else {
      --index;
      ret "Nah dude. You are supposed to say: " + line;
    }
  }
  
  S initialAnswer(O... _) {
    ret nextLine();
  }
  
  bool nextLineIsBotLine() { ret odd(index); }
  
  S nextLine() {
    S line = get(dialog, index);
    if (line == null)
      ret null with gazelle_stop();
    ++index;
    ret line;
  }
}

Author comment

Began life as a copy of #1022077

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1022220
Snippet name: Gazelle Dialog Runner [Demo]
Eternal ID of this version: #1022220/8
Text MD5: 556d6d959b55053228234965d69a9b43
Transpilation MD5: 324e58454baf36ca4ff75f7cde4a2960
Author: stefan
Category: javax / gazelle
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-11 12:54:43
Source code size: 823 bytes / 43 lines
Pitched / IR pitched: No / No
Views / Downloads: 282 / 3055
Version history: 7 change(s)
Referenced in: [show references]