I've been trying to code for TwitchPlays. So far I've been successful on getting Direct Keyboard Input from a text, but I would like to have more accurate precision on the key inputs (for example, https://clips.twitch.tv/SmilingDelightfulWalrusTakeNRG). There's an obvious Jump, down, left, right, dash command but you can see from a video clip that the viewer can optionally make the input more accurate by allowing hold buttons by adding any frame numbers afterwards (ie text "jump 25" translates to holding the jump button--or "C" for however many frame or seconds the viewer wants)
Here's my code (this part is kind of useless for this conversation, but i've put it here for the context) (also for the direct key import, I just used the code from Simulate Python keypresses for controlling a game)
import twitch
from directkey import PressKey, ReleaseKey
import time
t = twitch.Twitch();
k = keypresser.Keypresser();
#Directkeyboard input code
C = 0x2E
Z = 0x2C
username = "My username";
key = "my authcode";
t.twitch_connect(username, key);
This is the command part that I need to somehow change
while True:
new_messages = t.twitch_recieve_messages();
if not new_messages:
continue
else:
for message in new_messages:
msg = message['message'].lower()
username = message['username'].lower()
print(username + ": " + msg.encode('utf-8'));
if msg == "dash":
PressKey(C)
time.sleep(0.1)
ReleaseKey(C);
if msg == "jump":
PressKey(Z)
time.sleep(0.1)
ReleaseKey(Z);
Also I was able to run the Commands Dash and Jump, but how can I code it so that is someone inputs "dash dash dash" on twitch, it translates to the input C C C (currently, since I don't have the command specific for "dash dash dash", python can't understand except for the single "dash" command). I would like to have the flexibility to input however amount of commands (ie dash jump dash jump) without me having to specifically add that command.
Sorry for the messy code, and any help is greatly appreciated. Thank you