Hello,
I’m having some trouble figuring out how to make a simple number counter that is connected to events in airtable.
Basically, i have a table which tracks at what time an event occured and i would like to have a counter appear in processing which counts each time that happens. So, say an event occured at 13:23, the counter in processing will show the number “1”, then at 14:30 another event occurs so the counter will increment +1 and show “2” and so on.
I found a code that works well for when you mousepressed
int score = 0;
PFont counter;
void setup (){
size(574, 323);
counter = createFont("Arial", 72, true);
noLoop();
smooth();
}
void draw() {
background(0);
textFont(counter, 72); // Specify font to be used
fill(#ffffff); // Specify font color
text(nf(score, 1), 125, 175); // Display Text and Location
}
void mousePressed() {
score = (score + 1);
redraw();
}
but now i need to integrate it in a complicated code so that instead of updating when you press your mouse, it updates once an event in airtable is fetched. i think this is where i need to integrate something, an array? a string? using the “if()” function.
void forward() {
if (selectedEvents.size() > 0) {
println(frameCount + " PLAY");
if (enemyPos < selectedEvents.size()-1)
enemies.get(enemyPos).show = true;
enemyPos ++;
}
if (currentDateTime >= starting_date.getTime() && currentDateTime < (starting_date.getTime() + oneweek_ms) - modeMS[mode]) {
currentDateTime += modeMS[mode];
} else {
currentDateTime = starting_date.getTime();
}
reset();
}
So i thought of making a class
class AgeCounter {
int num = 0;
PFont agecounter;
AgeCounter(int _num) {
// Constructor
num = _num;
}
void update() {
num = (num + 1);
redraw();
}
void display() {
agecounter = createFont("Arial", 20, true);
noLoop();
smooth();
textFont(agecounter, 72);
fill(#ffffff);
text(nf(num, 1), 125, 175);
}
}
but now i don’t know if this is the right way to go about it because i don’t know if i should make use of an array or a string?
I hope i was clear enough in my question and that i put the right snippets of code for you to understand what my problem is haha ^^’ i’m sorry i don’t think the code is testable because otherwise i would have to upload the whole sketch which contains several classes and a lot of lines of code. however if you deem it necessary i’ll do that, no problem.
thanks in advance to anyone who replies,
Please help me T_T