Skip to content

Commit

Permalink
Added counter node
Browse files Browse the repository at this point in the history
  • Loading branch information
paulobarcelos committed May 4, 2018
1 parent 74479b1 commit 4eb755c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/NodeCounter.cpp
@@ -0,0 +1,22 @@
#include "NodeCounter.h"

Counter::Counter():
HasTrigger
(this){
};
Counter::~Counter(){
registerInput(amount);

amount = 1.0;

count = 0.0;
}

void Counter::onInternalInputChange(BaseInput &internalInput){
if(&internalInput == &trigger){
if(isTriggerActive()){
count += amount.get();
out.set(count);
}
}
};
24 changes: 24 additions & 0 deletions src/NodeCounter.h
@@ -0,0 +1,24 @@
#ifndef NodeCounter_h_
#define NodeCounter_h_

#include "CommonNodeIncludes.h"

class Counter:
public Node,
public HasTrigger
{
public:

Counter();
~Counter();

Input amount;

Output out;

protected:
void onInternalInputChange(BaseInput &internalInput);

float count;
};
#endif
1 change: 1 addition & 0 deletions src/Quirkbot.h
Expand Up @@ -16,6 +16,7 @@
#include "NodeConverter.h"
#include "NodeComparison.h"
#include "NodeConstrain.h"
#include "NodeCounter.h"
#include "NodeGate.h"
#include "NodeList.h"
#include "NodeLogic.h"
Expand Down

0 comments on commit 4eb755c

Please sign in to comment.