Kruiser8 / Kruiz-Control

Kruiz Control enables a pseudo code approach to manage and automatically handle Twitch Channel Points, Twitch Chat, OBS or SLOBS, and StreamElements or Streamlabs alerts.
Other
233 stars 32 forks source link

Integration: LiveSplit? (and/or TheRun.gg?) #75

Open TheTaraStark opened 8 months ago

TheTaraStark commented 8 months ago

Would love to use Livesplit as a trigger for events, and I know many other speedrunners would as well.

If I'm reading this right, it looks like LiveSplit's native server function might only allow for other programs to control LiveSplit, and not the other way around.

I might instead reccomend prioritizing TheRun.gg support, since it appears to have a more comprehensive API (and better documentation) allowing for LiveSplit to be used as the trigger, rather than only accepting events.

Fwiw, they both appear to work with streamer.bot, so it feels like this should work too, but I'm not a dev, I'm an amateur code-reader at best, so I'll let y'all figure out what's actually feasible to integrate into KC.

Thanks for looking this over!

Kruiser8 commented 8 months ago

It does look like it would be possible, and these commands would be available: https://github.com/LiveSplit/LiveSplit.Server?tab=readme-ov-file#commands

Which ones would be nice to have?

TheTaraStark commented 8 months ago

As a runner, triggers and parameters would be a lot more useful than actions.

The only scenario I can think of for wanting LiveSplit actions beyond "give me parameters" would be having a moderator or VIP etc undo a split or skip a split for me because I missed something and can't put a controller down - those situations are rare and the level of trust to have someone else do those things for a runner is even rarer. RunStatus could serve as a "parameter grabbing" action, and would probably be the most used action.

Triggers would probably be more applicable/useful than actions, in this case (which is why I included TheRun.gg's API as well, specifically their live-api and the example of usage), and each of these triggers could return the same parameters as RunStatus. I'm going to include a few potential uses for these triggers at the end of this post, but

OnRunStart (the start of a speedrun) OnRunSplit (could be every split, or use parameters for split # or name) OnRunReset (when a run is reset or ended without being completed) OnRunFinish (when the final split is completed) OnRunBestSeg (when a segment/split achieves a new lowest time) OnRunPB (when a full/complete run achieves a new lowest time)

The most useful parameter ideas I had (tried to order by potential usefulness):

<activity> Is the timer currently active, paused, or inactive <splitname> the name of the segment/split a runner is currently on <splitnumber> the number of the segment/split a runner is currently on <game> the current game being run <category> the category being run in a game <variables> any applicable variables for a run <lastsplitdelta> how far ahead/behind of current comparison the past split is <lastsegdelta> how far ahead/behind of current comparison the past segment is

Some parameters that might be used less often, but would be nice to have (again, ordered by potential usefulness):

<runtime> the current time in a run <comparison> the current comparison a run is using (Comparing against "personal best" "sum of best" "averages" etc) <comparerun> the comparison time of a run (or final split of a run) <comparesplit> the comparison time of the current split <segtime> the current time of a segment <compareseg> the comparison time of the current segment <rundelta> how far ahead/behind of current comparison the current run is <splitdelta> how far ahead/behind of current comparison the current split is <segdelta> how far ahead/behind of current comparison the current segment is

For me personally, being able to use to turn certain Channel Point rewards on/off or pause them would be incredibly useful, as there are certain rewards I simply cannot fulfill while being occupied by a run. I also love the idea of being able to trigger my custom DanceMode action when I reach splits where the in-game music is really good, and turning it off when I leave those splits.

I can also see more common situations for runners where starting/ending a run triggers a custom text effect, or a new Best Seg/PB could trigger confetti on screen, or reaching certain splits could change a background color/image to match the theme of a level.

Hopefully this is helpful - thanks again for considering this!

lumilauraa commented 8 months ago

i joined github just to enter this conversation- this would be an absolute godsend as a full time speedrunner and avid user of Kruiz Control. Tara has pretty much nailed the paramaters, i can't think of anything else to add, but absolutely want to show my support for this idea. i've always wanted OBS/SLOBS (i use slobs) integration with livesplit.

Kruiser8 commented 8 months ago

Hey there, I spent some time this evening looking into LiveSplit and TheRun.gg. I don't think I can implement either of them.

LiveSplit As far as I could tell, Kruiz Control is unable to connect to the LiveSplit server due to browser restrictions. Browsers aren't allowed to connect to TCP pipes. Also, while the LiveSplit.Server component says it was incorporated into the current LiveSplit release, I could find no evidence of that. I installed the server component, added it to the LiveSplit layout, and started the server. Still no connection.

TheRun.gg The websocket and API are easy to use, but connecting to the websocket is blocked due to a security rule. TheRun.gg, like most websites, has a CORS security setting that blocks access from localhost. This blocks access for Kruiz Control.

I loved this idea, but I hit walls both ways. If anyone finds a solution to this, let me know and I'd be happy to add it.

just-ero commented 7 months ago

One thing I want to chime in with is: when you have both OnRunSplit and OnRunFinish, what do you expect the behavior of the final split to be? Does it execute both OnRunSplit and OnRunFinish (in that order)? Or only OnRunFinish?

This goes for a few things: OnRunSplit/OnRunBestSeg, OnRunSplit/OnRunFinish/OnRunPB.

TheTaraStark commented 7 months ago

To @Kruiser8, it looks like this LiveSplit component could give you some websockets to work with? It's unmaintained, but it's still available and still works. https://github.com/Xenira/LiveSplit-Websocket

To @just-ero, very good questions! Had to think about this for a bit, maybe the solution is to turn conflict triggers into parameters, ie OnRunSplit could return true/false for parameters <is_BestSeg>, <is_RunFinish>, <is_RunPB>, etc. Thoughts?

TheTaraStark commented 7 months ago

There was also some discussion about the security lockup in TheRun.gg's discord server!