C
C#13mo ago
Cringel

❔ Some image detecting thing

So, I took this script from talkai and I want to use it from the main script https://paste.mod.gg/zonjixwvtmzk/0 Does it work with png and how do I use it from the main script? This thing is in a form and the main script is the main script.
BlazeBin - zonjixwvtmzk
A tool for sharing your source code with the world!
No description
No description
No description
71 Replies
Thinker
Thinker13mo ago
You have to create an instance of the form and then call FindMatchingImage on it.
Cringel
CringelOP13mo ago
And how can I integrate that in my code?
No description
SinFluxx
SinFluxx13mo ago
It tells you there?
Thinker
Thinker13mo ago
By not asking chatgpt of all things
TheRanger
TheRanger13mo ago
did you create a new winform project from here?
No description
Cringel
CringelOP13mo ago
its Visual Studio I use Rider
TheRanger
TheRanger13mo ago
ah rider cant create a winform project?
Cringel
CringelOP13mo ago
But I use windows forms it can
TheRanger
TheRanger13mo ago
through a template because its suppose to generate some code in Program.cs
Cringel
CringelOP13mo ago
creates some code, yes
TheRanger
TheRanger13mo ago
there is suppose to be something like Application.Run(new Form1()); in the Program.cs which basically will run your form instance when the app runs
Cringel
CringelOP13mo ago
uhh
Cringel
CringelOP13mo ago
I have that
No description
Cringel
CringelOP13mo ago
The template start thing is that
No description
TheRanger
TheRanger13mo ago
can u comment out line 26 and run ur program? does a form open? what is UI.MyFunction is it a method u created?
Cringel
CringelOP13mo ago
yes
No description
Cringel
CringelOP13mo ago
a yellow square
TheRanger
TheRanger13mo ago
can u show me that method
Cringel
CringelOP13mo ago
TheRanger
TheRanger13mo ago
ok so FindMatchingImage is part of Form1 not Form it looks like ur app only opens for 2 seconds then closes, correct?
Cringel
CringelOP13mo ago
yes, because I set it in the function
Cringel
CringelOP13mo ago
But my actual problem is with this thing https://paste.mod.gg/zonjixwvtmzk/0, image detection
BlazeBin - zonjixwvtmzk
A tool for sharing your source code with the world!
TheRanger
TheRanger13mo ago
isnt this ur problem atm?
Cringel
CringelOP13mo ago
my problem is this atm Ui.MyFunction thing is totally ok
TheRanger
TheRanger13mo ago
so whats the problem in that code?
Cringel
CringelOP13mo ago
BlazeBin - zonjixwvtmzk
A tool for sharing your source code with the world!
TheRanger
TheRanger13mo ago
?? whats the problem in this code?
Cringel
CringelOP13mo ago
well, I want to make a function that does this code process and use it in the main script
TheRanger
TheRanger13mo ago
do it then
Cringel
CringelOP13mo ago
but I dont know how to
TheRanger
TheRanger13mo ago
imagine ur calling a method called Walk() who exactly will Walk?
Cringel
CringelOP13mo ago
method
TheRanger
TheRanger13mo ago
a human? a bear? and which human
Cringel
CringelOP13mo ago
human
TheRanger
TheRanger13mo ago
which human tho imagine a game, where there are 1000 humans
Cringel
CringelOP13mo ago
human number 1
TheRanger
TheRanger13mo ago
exactly right now ur trying to call the FindMatchingImage method but it doesnt know who will do that action
Cringel
CringelOP13mo ago
so I need to make a class?
TheRanger
TheRanger13mo ago
No, that action belongs to Form1 class, correct?
Cringel
CringelOP13mo ago
yes
TheRanger
TheRanger13mo ago
so you dont need to make one
Cringel
CringelOP13mo ago
I meant static class line
Cringel
CringelOP13mo ago
like that
No description
Cringel
CringelOP13mo ago
or?
TheRanger
TheRanger13mo ago
well no, because you require the form to call its messagebox
Cringel
CringelOP13mo ago
oh, I need to make the function public
TheRanger
TheRanger13mo ago
well thats 1 fix
Cringel
CringelOP13mo ago
Form1 is already a class thing?
TheRanger
TheRanger13mo ago
u see this code in ur detect position.cs
form.BackColor = Color.Yellow;
form.BackColor = Color.Yellow;
doing BackColor = Color.Yellow; wont work it needs to know which object to change its backcolor
Cringel
CringelOP13mo ago
No description
TheRanger
TheRanger13mo ago
close, but Form1 here is like a blue print of an object
Cringel
CringelOP13mo ago
like class of a class?
TheRanger
TheRanger13mo ago
no, Form1 is the class like Human, human is a class and you're an instance of a Human doing Human.Walk() wouldnt make sense, because Human here is a type see this code for example its form.BackColor = Color.Yellow; not Form.BackColor = Color.Yellow;
Cringel
CringelOP13mo ago
yes I need to make it not capital?
TheRanger
TheRanger13mo ago
that's not the issue, form is an object of Form because of this line Form form = new Form(); imagine we are in a game
Cringel
CringelOP13mo ago
I think I dont have that line in the script
TheRanger
TheRanger13mo ago
Human theRanger = new Human();
Human cringel = new Human();
theRanger.Run();
cringel.Walk();
Human theRanger = new Human();
Human cringel = new Human();
theRanger.Run();
cringel.Walk();
i literally copy pasted it from ur code
Cringel
CringelOP13mo ago
in the other one
TheRanger
TheRanger13mo ago
well ofcourse, the reference of your new form is in the detect position.cs so it would make sense to call your method in that file
Cringel
CringelOP13mo ago
how?
TheRanger
TheRanger13mo ago
like this form.FindMatchingImage(); this is calling a method of an instance note that i am really busy right now so how about going through the fundamentals in the links below $helloworld
Cringel
CringelOP13mo ago
No description
TheRanger
TheRanger13mo ago
. its not a global variable, its a local variable when you say My PC ur obviously refering to your own computer right? the variable only exists within its scope in the detect position.cs anyway g2g, those links above will help you
Cringel
CringelOP13mo ago
Thats what I can only make
No description
SinFluxx
SinFluxx13mo ago
it's a new Form1() you would need, not a new FindMatchingImage() Did you work through the course that was linked above? As it seems a bit like you're stumbling through things rather than understanding how they all piece together
Cringel
CringelOP13mo ago
I didnt see the same thing from the links above
SinFluxx
SinFluxx13mo ago
There won't be strictly the same thing in there, I think the point was you probably need to try and learn the fundamentals of C# first to get an understanding of how things work, as you're kind of jumping around/asking chatgpt for things that you don't fully understand and getting a bit lost in it all
Cringel
CringelOP13mo ago
Yes, but I think I already know the fundamentals on like 30% of all
SinFluxx
SinFluxx13mo ago
ok, well, good luck
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server