Hacking Question Assistence understanding source code, for bot using shiny quagsire's splatoon printer source

  • Thread starter Deleted User
  • Start date
  • Views 1,296
  • Replies 3
D

Deleted User

Guest
OP
Hello!

So, I recently picked up a teensy myself, and am having a wonderful time learning how to use it, and found some awesome public "bots" for the Nintendo Switch that people can use. However I am noticing one trend thus far. I am seeing that the documentation on a lot of these "bots" is few and far between, and would like to try to make an application to make it easier for anyone in the community to make things like this for other games.

However that leads me to the one big issue that I can't seem to wrap my head around, nor some of my other friends that took a look at this and I was wondering if anyone here could ELI5.

The example code I would like to use for this is the Snowball thrower by bertrandom here. More specifically line 44 to 147. How is he determining how long to hold each button press for? Unless I'm having as massive brain fart he isn't using MS to determine the timing.

For everyones convenience I will also share the code in question here.

Admitting my programming experience is minimalistic to say the least however I do know just enough to get basic things done. So I would like to apologize if this is something very basic that anyone with actual knowledge should know.

The only other thing I could think of personally that this code uses to determine timing is that it goes off of cycles. However won't the teensy need to monitor more than it does to determine a cycle?

And of course like usual, if nothing here makes sense or my question isn't clear. I would like to apologize beforehand. Feel free to call me an idiot, and I would be more than happy to reword/elaborate further
Code:
static const command step[] = {
    // Setup controller
    { NOTHING,  250 },
    { TRIGGERS,   5 },
    { NOTHING,  150 },
    { TRIGGERS,   5 },
    { NOTHING,  150 },
    { A,          5 },
    { NOTHING,  250 },

    // Talk to Pondo
    { A,          5 }, // Start
    { NOTHING,   30 },
    { B,          5 }, // Quick output of text
    { NOTHING,   20 }, // Halloo, kiddums!
    { A,          5 }, // <- I'll try it!
    { NOTHING,   15 },
    { B,          5 },
    { NOTHING,   20 },
    { A,          5 }, // <- OK!
    { NOTHING,   15 },
    { B,          5 },
    { NOTHING,   20 }, // Aha! Play bells are ringing! I gotta set up the pins, but I'll be back in a flurry
    { A,          5 }, // <Continue>
    { NOTHING,  325 }, // Cut to different scene (Knock 'em flat!)
    { B,          5 },
    { NOTHING,   20 },
    { A,          5 }, // <Continue> // Camera transition takes place after this
    { NOTHING,   50 },
    { B,          5 },
    { NOTHING,   20 }, // If you can knock over all 10 pins in one roll, that's a strike
    { A,          5 }, // <Continue>
    { NOTHING,   15 },
    { B,          5 },
    { NOTHING,   20 }, // A spare is...
    { A,          5 }, // <Continue>
    { NOTHING,  100 }, // Well, good luck
    { A,          5 }, // <Continue>
    { NOTHING,  150 }, // Pondo walks away

    // Pick up Snowball (Or alternatively, run to bail in case of a non-strike)
    { A,          5 },
    { NOTHING,   50 },
    { LEFT,      42 },
    { UP,        80 },
    { THROW,     25 },

    // Non-strike alternative flow, cancel bail and rethrow
    { NOTHING,   30 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 }, // I have to split dialogue (It's nothing)
    { NOTHING,   15 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,  450 },
    { B,          5 }, // Snowly moly... there are rules!
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 }, // Second dialogue
    { NOTHING,   20 },
    { DOWN,      10 }, // Return to snowball
    { NOTHING,   20 },
    { A,          5 }, // Pick up snowball, we just aimlessly throw it
    { NOTHING,   50 },
    { UP,        10 },
    { THROW,     25 },

    // Back at main flow
    { NOTHING,  175 }, // Ater throw wait
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 }, // To the rewards
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
   
    { B,          5 }, // Wait for 450 cycles by bashing B (Like real players do!)
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 },
    { B,          5 },
    { NOTHING,   20 } // Saving, intermission
};
 

Falo

Well-Known Member
Member
Joined
Jul 22, 2012
Messages
656
Trophies
1
XP
2,389
Country
Germany
Look at the GetNextReport Function:
Code:
            duration_count++;

            if (duration_count > step[bufindex].duration)
            {
                bufindex++;
                duration_count = 0;               
}
This is where the numbers are used, it's not a loop or time check, he waits for the next report from the hardware to increase a counter, after x counter are passed, the next button step is used.
 

dpad_5678

Ape weak on own. Ape strong in unity.
Member
Joined
Nov 19, 2015
Messages
2,219
Trophies
1
XP
2,860
Country
United States
I feel you.
I wish the code was able to be used and compiled in the Arduino IDE so we could make custom controllers with the digitalRead, etc functions.
 

ccrider

Member
Newcomer
Joined
Dec 17, 2017
Messages
14
Trophies
0
Age
32
XP
31
Country
United States
The OP's code block is building an array as a constant. It's a declaration.

Later in the actual executing loop, the program can compare controller inputs to snippets of the list to identify relevent controller input patterns.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
    Psionic Roshambo @ Psionic Roshambo: https://youtu.be/VfCYZ3pks48