C
C#8mo 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
Thinker8mo ago
You have to create an instance of the form and then call FindMatchingImage on it.
Cringel
Cringel8mo ago
And how can I integrate that in my code?
No description
SinFluxx
SinFluxx8mo ago
It tells you there?
Thinker
Thinker8mo ago
By not asking chatgpt of all things
TheRanger
TheRanger8mo ago
did you create a new winform project from here?
No description
Cringel
Cringel8mo ago
its Visual Studio I use Rider
TheRanger
TheRanger8mo ago
ah rider cant create a winform project?
Cringel
Cringel8mo ago
But I use windows forms it can
TheRanger
TheRanger8mo ago
through a template because its suppose to generate some code in Program.cs
Cringel
Cringel8mo ago
creates some code, yes
TheRanger
TheRanger8mo 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
Cringel8mo ago
uhh
Cringel
Cringel8mo ago
I have that
No description
Cringel
Cringel8mo ago
The template start thing is that
No description
TheRanger
TheRanger8mo 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
Cringel8mo ago
yes
No description
Cringel
Cringel8mo ago
a yellow square
TheRanger
TheRanger8mo ago
can u show me that method
TheRanger
TheRanger8mo ago
ok so FindMatchingImage is part of Form1 not Form it looks like ur app only opens for 2 seconds then closes, correct?
Cringel
Cringel8mo ago
yes, because I set it in the function
Cringel
Cringel8mo 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
TheRanger8mo ago
isnt this ur problem atm?
Cringel
Cringel8mo ago
my problem is this atm Ui.MyFunction thing is totally ok
TheRanger
TheRanger8mo ago
so whats the problem in that code?
Cringel
Cringel8mo ago
BlazeBin - zonjixwvtmzk
A tool for sharing your source code with the world!
TheRanger
TheRanger8mo ago
?? whats the problem in this code?
Cringel
Cringel8mo ago
well, I want to make a function that does this code process and use it in the main script
TheRanger
TheRanger8mo ago
do it then
Cringel
Cringel8mo ago
but I dont know how to
TheRanger
TheRanger8mo ago
imagine ur calling a method called Walk() who exactly will Walk?
Cringel
Cringel8mo ago
method
TheRanger
TheRanger8mo ago
a human? a bear? and which human
Cringel
Cringel8mo ago
human
TheRanger
TheRanger8mo ago
which human tho imagine a game, where there are 1000 humans
Cringel
Cringel8mo ago
human number 1
TheRanger
TheRanger8mo ago
exactly right now ur trying to call the FindMatchingImage method but it doesnt know who will do that action
Cringel
Cringel8mo ago
so I need to make a class?
TheRanger
TheRanger8mo ago
No, that action belongs to Form1 class, correct?
Cringel
Cringel8mo ago
yes
TheRanger
TheRanger8mo ago
so you dont need to make one
Cringel
Cringel8mo ago
I meant static class line
Cringel
Cringel8mo ago
like that
No description
Cringel
Cringel8mo ago
or?
TheRanger
TheRanger8mo ago
well no, because you require the form to call its messagebox
Cringel
Cringel8mo ago
oh, I need to make the function public
TheRanger
TheRanger8mo ago
well thats 1 fix
Cringel
Cringel8mo ago
Form1 is already a class thing?
TheRanger
TheRanger8mo 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
Cringel8mo ago
No description
TheRanger
TheRanger8mo ago
close, but Form1 here is like a blue print of an object
Cringel
Cringel8mo ago
like class of a class?
TheRanger
TheRanger8mo 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
Cringel8mo ago
yes I need to make it not capital?
TheRanger
TheRanger8mo 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
Cringel8mo ago
I think I dont have that line in the script
TheRanger
TheRanger8mo 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
Cringel8mo ago
in the other one
TheRanger
TheRanger8mo 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
Cringel8mo ago
how?
TheRanger
TheRanger8mo 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
Cringel8mo ago
No description
TheRanger
TheRanger8mo 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
Cringel8mo ago
Thats what I can only make
No description
SinFluxx
SinFluxx8mo 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
Cringel8mo ago
I didnt see the same thing from the links above
SinFluxx
SinFluxx8mo 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
Cringel8mo ago
Yes, but I think I already know the fundamentals on like 30% of all
SinFluxx
SinFluxx8mo ago
ok, well, good luck
Accord
Accord8mo 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.