Author Topic: Where to set auto-plunger ball save??  (Read 1127 times)

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Where to set auto-plunger ball save??
« on: August 04, 2015, 09:47:37 PM »
Quote
- Auto-launches balls while ball save is active (if linked to a ball save object

Failing to see where?

Sorry , I am just way too used to doing this myself from the shooterLane and rather move onto something else than waste time scanning the trough any longer.



« Last Edit: August 04, 2015, 09:50:20 PM by dave_h »

MOcean

  • Moderator
  • ****
  • Posts: 822
  • Michael Ocean
    • View Profile
Re: Where to set auto-plunger ball save??
« Reply #1 on: August 04, 2015, 10:35:26 PM »
This example:
https://github.com/mjocean/PyProcGameHD-SkeletonGame/blob/master/SampleGame/my_modes/BaseGameMode.py#L63

Which registers this call-back:
https://github.com/mjocean/PyProcGameHD-SkeletonGame/blob/master/SampleGame/my_modes/BaseGameMode.py#L68

Not sure where I wrote that it autoplunges but it does not.  Can you let me know where you found that so I can fix it?  You might be able to hande it in a ball saved handler by firing an autoPlunge pulse after a short delay from within the saved event handler.

Thanks!

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Where to set auto-plunger ball save??
« Reply #2 on: August 04, 2015, 10:47:38 PM »
Nice, glad I gave up  8)

The shooterlane is overidden in the trough I think and couldn't even add a switch handler. I have been trying my best not to go in and edit anything in the procgame, for some reason I have been wanting to keep it clean for the time being.

All in the trough.py I think mate. You will find that comment right at the very top.

And here at very bottom.
Code: [Select]
def shooter_lane_active(self, sw):

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Where to set auto-plunger ball save??
« Reply #3 on: August 04, 2015, 10:50:05 PM »
Multiballs not a problem, just the auto plunger when in a mulitball or ball save.

Code: [Select]
        self.game.trough.launch_balls(3)
        self.game.ball_saver_enable(4,20,True,True)

Gerry Stellenberg

  • Administrator
  • *****
  • Posts: 2399
    • View Profile
    • PinballControllers.com
Re: Where to set auto-plunger ball save??
« Reply #4 on: August 05, 2015, 12:54:13 AM »
Unless I'm mistaken, the use of the word "launch" might be confusing.  The trough launches a ball by kicking it into the shooter lane.  I'd expect a game-specific mode to either autolaunch the ball into play or not, depending on what's going on in the game.

You could potentially use the ballsaved callback as Mocean mentioned, or you could put a shooterLane switch handler in a game mode.  Most games always autofire except at the start of a ball and after a ball lock.

Here's how I did this way back when in JD.  This one shooterL handler takes care of all autolaunches: https://github.com/preble/JD-pyprocgame/blob/master/jd_modes.py#L655

- Gerry

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Where to set auto-plunger ball save??
« Reply #5 on: August 05, 2015, 01:13:57 AM »
Yes, I've actually used a stripped down JD all the way up until this point as a base for all my other games in the exact way you mention.

Quote
you could put a shooterLane switch handler in a game mode
This is how I would normally would be doing it.

I thought the idea with this skeleton game was to take care of that for you, which it does by this added "Constant" shooter switch name in the trough.py?

This was overriding it I think. Maybe if I added a longer "active_for" in my base it may work the same but I'm sure I did this anyway and came here. Will treble check :)

skeleton trough.py
Code: [Select]
    def shooter_lane_active(self, sw):
        """ Invoked automatically when the shooterlane has been active for 0.5 seconds """
        if(self.launch_in_progress):
            # great!  We are trying to launch a ball and the ball got there; commit
            self.num_balls_to_launch -= 1

            # Only increment num_balls_in_play if there are no more
            # stealth launches to complete.
            if self.num_balls_to_stealth_launch > 0:
                self.num_balls_to_stealth_launch -= 1
            else:
                self.num_balls_in_play += 1
            # If more balls need to be launched, delay 1 second
            if self.num_balls_to_launch > 0:
                            self.delay(name='launch', event_type=None, delay=1.0, \
                           handler=self.common_launch_code)
            else:
                self.game.log("trough: saw shooter lane -launch successful")
                self.launch_in_progress = False
                if self.launch_callback:
                    self.launch_callback()






dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Where to set auto-plunger ball save??
« Reply #6 on: August 05, 2015, 01:24:38 AM »
Code: [Select]
if not self.game.base_game_mode.ball_starting:
self.game.coils.autoPlunger.pulse()

Used to having this ball_starting variable as well, maybe I have just been missing this!

A lot of this I think is taken care of elsewhere, along with :

Code: [Select]
    # You should NOT need ANY of these

    # def start_ball(self):
    #     super(T2Game, self).start_ball()

    # def start_game(self):
    #     """ called (by attract) when the game is starting """
    #     super(T2Game,self).start_game()

    # def ball_starting(self):
    #     """ this is auto-called when the ball is actually starting
    #         (so happens 3 or more times a game) """

    # def ball_ended(self):
    #     """ Called by end_ball(). At this point the ball is over """
    #     super(T2Game, self).ball_ended()

    # def game_ended(self):
    #     super(T2Game, self).game_ended()

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Where to set auto-plunger ball save??
« Reply #7 on: August 05, 2015, 02:06:08 AM »
Cheers guys :)

Going through the trough really threw me off course on this one! I was expecting it to be doing it for me, ;) and the comment there confused me.

I've seen enough trough.py's by now, but never took any notice of that summary.

Anyway, to summarize this thread:

Add back in an "is_mbActive" variable / method to base and modes and use own "sw_shooterlaneswitch" handler

And the "blatent" ballsaved callback
Code: [Select]
    def ballsaved(self):
        """ this is the method that we told the ball-saver to call if
            the ball is saved by the ball-saver; see the call to
            ball_saver_enable.  This just shows a message and plays a
            sound but does NOT launch balls.  The ballsaver/trough
            handle this for us!
        """
        self.game.log("BaseGameMode: BALL SAVED from Trough callback")
        self.game.sound.play('ball_saved')
        self.game.displayText('Ball Saved!')
        self.game.coils.plunger.pulse()
        # Do NOT tell the trough to launch balls!  It's handled automatically!
        # self.game.trough.launch_balls(1)

 :D