C
C#2y ago
Chris TCC

shared variables between actions

Is there any way to do this? I've got a system that plays videos, but from mulitple actions - I wanna be able to make a queue system so they play one after another.
10 Replies
Chris TCC
Chris TCCOP2y ago
currently I'm using this system:
using System;

public class CPHInline
{
public bool Execute()
{
//initialization
string userName = args["user"].ToString();
string userMessage = args["message"].ToString();

//message mentions wolok, not sent by wolok, video overlay isn't currently in use (is disabled)
if(userMessage.Contains("test") && userName != "WorldLOck1q" && !CPH.ObsIsSourceVisible("(Video Overlays)", "Video Overlay"))
{
//Video initialization
CPH.ObsSetMediaSourceFile("(Video Overlays)", "Video Overlay", "C:/Users/Chris/Desktop/ChrisTCC/Twitch/Streamer.Bot/Video Clips/Monke.mp4");

//play video
CPH.ObsShowSource("(Video Overlays)", "Video Overlay");
CPH.ObsMediaRestart("(Video Overlays)", "Video Overlay");
CPH.SendMessage("done.");
CPH.Wait(3200); //3 seconds
CPH.ObsHideSource("(Video Overlays)", "Video Overlay");
}
return true;
}
}
using System;

public class CPHInline
{
public bool Execute()
{
//initialization
string userName = args["user"].ToString();
string userMessage = args["message"].ToString();

//message mentions wolok, not sent by wolok, video overlay isn't currently in use (is disabled)
if(userMessage.Contains("test") && userName != "WorldLOck1q" && !CPH.ObsIsSourceVisible("(Video Overlays)", "Video Overlay"))
{
//Video initialization
CPH.ObsSetMediaSourceFile("(Video Overlays)", "Video Overlay", "C:/Users/Chris/Desktop/ChrisTCC/Twitch/Streamer.Bot/Video Clips/Monke.mp4");

//play video
CPH.ObsShowSource("(Video Overlays)", "Video Overlay");
CPH.ObsMediaRestart("(Video Overlays)", "Video Overlay");
CPH.SendMessage("done.");
CPH.Wait(3200); //3 seconds
CPH.ObsHideSource("(Video Overlays)", "Video Overlay");
}
return true;
}
}
basically adding a check during my if statement to check if the overlay is enabled turns out - it isn't working as intended. I just want it to fail the if statement, but it seems like it just queues the video somehow
Yawnder
Yawnder2y ago
You're missing a key concept of OOP it seems: Objects can have fields and properties. You don't have enough code or explanation to go in the details, but for example, you could have a field/property at the class level (outside of the method's scope) that would be your queue, and you would add/remove items into that object.
Chris TCC
Chris TCCOP2y ago
and where would I put that class? I'm self-taught, I have no idea what the heck that means
Yawnder
Yawnder2y ago
public class Potato {
public string ThisIsAPublicProperty { get; set; }
private string thisIsAPrivateField;
public void ThisIsAMethod() {
DoSomething();
}
}
public class Potato {
public string ThisIsAPublicProperty { get; set; }
private string thisIsAPrivateField;
public void ThisIsAMethod() {
DoSomething();
}
}
As long as your instance of that class lives, these members will persist.
Chris TCC
Chris TCCOP2y ago
yeah but where? if I put the class in this action would scripts in other actions be able to access it?
Yawnder
Yawnder2y ago
What scripts? What actions? These aren't things in C#.
Chris TCC
Chris TCCOP2y ago
ah crap wrong discord I just noticed 🤦‍♂️
Yawnder
Yawnder2y ago
(Well, Action<T> is, but I don't think you're talking about that.)
Chris TCC
Chris TCCOP2y ago
sorry mate, I posted wrong discord, I'm working on a script for a program called Streamer.bot
Yawnder
Yawnder2y ago
Oh. Alright. Have fun!
Want results from more Discord servers?
Add your server