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

21
LINES

< > BotCompany Repo | #1004731 // loadStrategy

JavaX fragment (include)

// returns an object with a "strategy" method
static O loadStrategy(S id) {
  int type = getSnippetType(id);
  if (type == 34) {
    // JavaX Strategy
    final O strategy = run(id);
    ret strategy;
  } else {
    // Lua Strategy
    S lua = loadSnippet(id);
    Sandbox s = luaSandbox();
    evalLua(s, lua);
    final LuaValue strategy = s.get("strategy");
    assertNotNil(strategy);
    ret new O {
      S strategy(S text) {
        ret callLuaStrategy(strategy, text);
      }
    };
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004731
Snippet name: loadStrategy
Eternal ID of this version: #1004731/1
Text MD5: 654af3a28a43733bbb344d758bb00109
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-09-11 23:17:00
Source code size: 517 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 406 / 418
Referenced in: [show references]