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

36
LINES

< > BotCompany Repo | #1027426 // Proposed Actions [dev.]

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

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

!7

sclass Prop {
  S text, module;
  Runnable action;
  long date = now();
  
  [stdEq]
}

cmodule ProposedActions > DynObjectTable<Prop> {
  transient int expiryTime = 10000;
  transient long timer; // When we began thinking
  transient int thinkTime = 2000;
  
  start {
    dontPersist(); // can't persist foreign Runnables
    //doEvery(1000, r cleanList);
  }
  
  void addProposition(S text, Runnable action, S module) {
    add(nu(Prop, +text, +action, +module));
  }
  
  void cleanList {
    setField(data := objectsWhereFieldGreaterThan(cloneList(data), date := now()-expiryTime));
    if (syncNempty(data)) {
      if (timer == 0) timer = now();
      if (now() >= timer+thinkTime) {
        S out = getString(random(data), 'text);
        clear();
        timer = 0;
      }
    }
  }
}

Author comment

Began life as a copy of #1016982

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1027426
Snippet name: Proposed Actions [dev.]
Eternal ID of this version: #1027426/4
Text MD5: 5ffeee8fd4b0ebd7795300efd60a3d7a
Transpilation MD5: 3171e1f4e1ed9bfcc898fab9827435c5
Author: stefan
Category: javax / dynamic modules
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-18 20:00:45
Source code size: 834 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 112 / 284
Version history: 3 change(s)
Referenced in: [show references]