GPC To Py.

GPC2 script programming for Titan Two. Code examples, questions, requests.

GPC To Py.

Postby CryptoP » Sat Feb 03, 2024 10:23 am

Hello.

I need some help and was wondering if anyone could be help me please?

Pressing Button7 and Button4 starts the process, stage_one has other stuff going on before paddle_1 is triggered and triggering paddle_1 is moving the process over to *.py. everything up to *.py is working as expected.

whats happening is *.py is being hit multiple times which is confirmed by the print statement printing out to gtuner, i have this unexpected behaviour with my script and suspect that *.py is being called multiple times before it has time to return the outcome of the first call.

is there any way i can only call the *.py script only once?.


Code: Select all
main {
 
    if (get_actual(BUTTON_7) && event_active(BUTTON_4)) {
        combo_run(stage_one);
        }
 
combo stage_one {
    set_val(PADDLE_1,100); wait(400);
    printf("Passing to py");
    }
}
 


*.py
Code: Select all
 
        def process(self, frame):
        if gtuner.get_val(gtuner.PADDLE_1) >= self.PADDLE_THRESHOLD:
            print('py being hit')
 
 
User avatar
CryptoP
Sergeant
Sergeant
 
Posts: 7
Joined: Wed Dec 27, 2023 2:49 pm

Re: GPC To Py.

Postby Scachi » Sun Feb 04, 2024 6:12 pm

create a flag on the py side memorizing the previous state of the paddle and only start your processing there when gtuner.PADDLE_1 is getting active, not while staying active (writing your own event_active alike python function).
or use some other way send a command to .py:
https://github.com/J2Kbr/GtunerIV/issues/406
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: GPC To Py.

Postby CryptoP » Mon Feb 05, 2024 11:09 pm

Scachi wrote:create a flag on the py side memorizing the previous state of the paddle and only start your processing there when gtuner.PADDLE_1 is getting active, not while staying active (writing your own event_active alike python function).
or use some other way send a command to .py:
https://github.com/J2Kbr/GtunerIV/issues/406


Thank you for your reply. Ive managed to stop the multiple hit like this in the end;

Code: Select all
 
 
if gtuner.get_val(gtuner.PADDLE_4) >= self.PADDLE_THRESHOLD:
            try:
                    numbers_int = self.extract_int_from_frame(frame, self.FRAME_SLICE_DUMP)
 
                    if numbers_int <= 780 and self.found:
                        print("Passing back")
                        self.found = False
                        self.gcvdata[0] = 4 
                        return frame, self.gcvdata 
                    elif numbers_int > 780 and self.gcvdata[0] == 4 :
                         pass
                    else:
                         self.found = True
 
            except Exception as e:
                print(f"Error: {str(e)}")
 
 
User avatar
CryptoP
Sergeant
Sergeant
 
Posts: 7
Joined: Wed Dec 27, 2023 2:49 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: Majestic-12 [Bot] and 130 guests