add-a-ball script ? help

fastdraw

Inserted Coin
Joined
Dec 16, 2015
Messages
226
Reaction score
159
Points
56
Favorite Pinball Machine
afm mm cv
voici la table que j'utilise toujours comme base de départ .
j'aimerai ajouter un add-a-ball.


exemple 1 trigger et 2 kickers.
après 3 passages sur le trigger les 2 kickers relâchent 1 bille chacun.


here is the table I always use as a starting point.
I would like to add an add-a-ball.

example 1 trigger and 2 kickers.
after 3 passes on the trigger the 2 kickers release 1 ball each.





dim a


sub trigger1_hit()
a=a+1
if a=3 then
kicker1.createball:kicker1.kick 170,10
kicker2.createball:kicker2.kick 170,10
a=0
end if
end sub


comment programme t'on le add-a-ball pour que le décompte de billes soit correct ?
J'aimerai aussi qu'il n'y ait pas plus de 5 billes sur la PF.
Si quelqu'un pouvez insérer le code avec le script de table de départ...
merci.


how do you program add-a-ball so that the ball count is correct?
I would also like there to be no more than 5 balls on the PF.
If someone can insert the code with the starting table script ...
thank you.



my starting script (starter) :


Code:
Option Explicit 

Randomize


Dim Ball
Dim Balls
Dim Score
Dim ScoreToAdd
Dim InProgress: Inprogress=False
Dim Credits: Credits=0
Dim light
ball=0
balls=3
score=0

'**********KEYS DOWN**********

Sub Table1_KeyDown(ByVal keycode)

    If InProgress = True Then
    If keycode = LeftFlipperKey Then
        LeftFlipper.RotateToEnd
        PlaySound "flipperup"
    End If
    End If
    
    If InProgress = True Then
    If keycode = RightFlipperKey Then
        RightFlipper.RotateToEnd
        PlaySound "flipperup"
    End If
    End If

    If keycode = PlungerKey Then
        Plunger.PullBack
    End If
    
    If keycode = LeftTiltKey Then
        Nudge 90, 2
    End If
    
    If keycode = RightTiltKey Then
        Nudge 270, 2
    End If
    
    If keycode = CenterTiltKey Then
        Nudge 0, 2
    End If
    
    If keycode = AddCreditKey Then
         Credits=credits + 1
         CreditBox.Text=Credits
         If InProgress= False Then ScoreBox.Text = "Press Start"
         PlaySound "coin"
    End If
   
    If InProgress = False Then
    If Keycode = StartGameKey And Credits>0 Then  
        Credits=Credits-1
        CreditBox.Text=Credits
        NewGame     
        InProgress=True 
    End If
   End If
End Sub

'**********KEYS UP**********

Sub Table1_KeyUp(ByVal keycode)

    If keycode = PlungerKey Then
        Plunger.Fire
        PlaySound "plunger"
    End If
    
    If InProgress = True Then
    If keycode = LeftFlipperKey Then
        LeftFlipper.RotateToStart
        PlaySound "flipperdown"
    End If
    
    If keycode = RightFlipperKey Then
        RightFlipper.RotateToStart
        PlaySound "flipperdown"
    End If
    End If
End Sub

'**********NEW GAME**********

Sub NewGame
     InProgress=True
     DrainTimer.Interval=4000
     DrainTimer.Enabled = True
    ScoreBox.Text=""
    Score=0
    Ball=0
    BallBox.Text=Ball
    ScoreBox.Text=Score
    TextBox2.Text = "BALL"
End Sub




'**********SCORE**********

Sub AddScore(ScoreToAdd)
     Score=Score+ScoreToAdd
    ScoreBox.Text=Score    
End Sub

'**********TABLE INIT**********

Sub Table1_Init()
    Randomize
    TextBox2.Text = "BALL"
    BallBox.Text = ball
    Ball=0
    Balls=3
    score=0
    ScoreBox.Text = "Insert Coin"
End Sub

'**********DRAIN**********

Sub Drain_Hit()
     Drain.DestroyBall
     If Ball < Balls Then   ' Is ball played less than total Balls or is the Game Over
         DrainTimer.Interval=3000
        DrainTimer.Enabled = True    ' If not, then let's play another ball, but let's set the timer for a delay
          Else        ' Sorry, but the game is now over
          GameOver    ' Go to game over to finish up
        End If 
End Sub

Sub DrainTimer_Timer()
    DrainTimer.Enabled = False    ' When timer runs out we will do the stuff below
    Kicker1.CreateBall
    Kicker1.Kick 90,10
    PlaySound "ballrel"
    Ball = Ball + 1
    BallBox.Text=Ball
End Sub


'**********GAME OVER**********
Sub GameOver
        LeftFlipper.RotateToStart
        RightFlipper.RotateToStart
    TextBox2.Text = "BALL"
    BallBox.Text = 0
    InProgress=False
    ScoreBox.Text="Game Over"
End Sub



'****************RULES*****************

Sub Bumper001_hit()
addscore 1000
End Sub

Sub Bumper002_hit()
addscore 1000
End Sub

Sub Bumper003_hit()
addscore 1000
End Sub
 
Solution
Dim Balls, BIP

Sub Table1_KeyDown(ByVal keycode)

Sub If keycode = plungerkey Then
Plunger.Pullback
PlaySound "plunger"
If keycode = plungerkey and BIP = 0 Then
Balls = Balls + 1:BIP = 1:plunger.CreateBall:plunger.Kick 90,7
End If
End Sub


Using the above, we call the plungerkey usage by the player. No matter when the player uses the plunger key, a sound can be made. If the player uses the plunger and BIP = 0 then the know another ball can be called up, so If keycode = plungerkey and BIP = 0 then allows a single ball into play and counts another ball using the Balls = Balls + 1. Everything using the statements above can be controlled anywhere within the script, and the more well placed the more realistic a table can...
By using the proper variable in a DIM, you can manipulate those. I always use BALLS = BALLS (+1 or -1) depending on how you're using this statement and if you're counting up or down using them. Or you can even use the BIP = 0 or BIP = 1 (BIP = Ball In Play, 0 = none, 1 = 1 ball on the play field).


You can place this just about anywhere in your table and it will work. Just make sure if you're showing the correct balls on the screen you don't forget to add the proper text box statements.
 
ok but how to block the creation of ball (plunger), as long as there is balls on the pf ?
 
Dim Balls, BIP

Sub Table1_KeyDown(ByVal keycode)

Sub If keycode = plungerkey Then
Plunger.Pullback
PlaySound "plunger"
If keycode = plungerkey and BIP = 0 Then
Balls = Balls + 1:BIP = 1:plunger.CreateBall:plunger.Kick 90,7
End If
End Sub


Using the above, we call the plungerkey usage by the player. No matter when the player uses the plunger key, a sound can be made. If the player uses the plunger and BIP = 0 then the know another ball can be called up, so If keycode = plungerkey and BIP = 0 then allows a single ball into play and counts another ball using the Balls = Balls + 1. Everything using the statements above can be controlled anywhere within the script, and the more well placed the more realistic a table can be made.


So, the above shows that if BIP = 0 means placed at any drain or hole or placement within the table and is called, will allow the plunger to bring up another ball, hence BIP = 0. If BIP = 1 then that would mean a ball is currently in play and the plunger refuses to allow another onto the playfield because BIP = 1. But, the plunger still allows a sound to be played, blocking another ball to be made.


The Balls = Balls + 1 statement counts a ball one at a time to be counted if BIP = 0 ONLY, otherwise it will not count one to your ball counter and will not allow a player another ball into the play unless BIP = 1.
So, once the ball is created, the BIP = 1 statement is called and the plunger can no longer create ball until BIP = 0 once again which is called via the scripting.



There you go. ANY of the above statements can be called throughout the script at anytime for ball control.


Hope this helps.

PS: You may have to alter the plunger statement and place the above into a keypress, getting rid of the basic plunger statement within VP. I do this every time since it is useless and just used as a type of "crutch" for beginners to see how a ball is called to the plunger.


PPS: I realize all these DIM array statements and calls can be a bit confusing and daunting at first, but as you use VP you'll realize you just have to keep track of them and you'll get used to it quite quick.



ok but how to block the creation of ball (plunger), as long as there is balls on the pf ?
 
Last edited:
Solution
thank you Druadic , it work



but is the variable A is really re-initialized to zero. tr2 and tr3 = triggers


Code:
'*********ADD-A-BALL  +2 balls*************

dim a


sub tr2_hit()
a=a+1
if a=3 then
kicker2.createball:kicker2.kick 170,10
kicker3.createball:kicker3.kick 170,10
a=0
end if
end sub

sub tr3_hit()
a=a+1
if a=3 then
kicker2.createball:kicker2.kick 170,10
kicker3.createball:kicker3.kick 170,10
a=0
end if
  end sub
because the 2 kickers create lots of other balls...
how to limit the number of balls on the pf to 3.


should the triggers be disabled while there is more than 1 ball on the pf ?



lower the table
 

Attachments

  • template.rar
    4.5 MB · Views: 232
Last edited:
The best thing to do is to mess around with the variables BUT, if you can control the ball count using triggers (which I have also done) then turn them off. You can always turn them back on in the script.


By using the enabled = false routine you can turn them off and by using the true statement you can turn them back on ANYTIME.


The one thing you have to watch is that visual pinball is famous turning on a trigger numerous times even though the ball passes over it once. Just FYI!


Kickers also are ALWAYS ENABLED unless you turn them off as well OR in the main visual pinball program, leave them unchecked for enabled. You can still use the kicker but no ball will be able to land into it!





Glad it worked for you and hope you're finding programming in visual basic a bit of fun. Some of it can be a challenge but overall I find it to be a puzzle I enjoy to figure out.


:)
 
Last edited:
sorry, I thought it was working
but no. my plunger is timed at 3s, which is why I thought the plunger was neutralized.....so I still have the problem of ball creation during add-a-ball...
 
The best way to add balls is via kicker to keep track of the BIP statements, using the kicker to create a new ball. Of course you can use the plunger but it requires more fiddling around with the scripting which I avoid usually like the plague. You can also use triggers to create a ball from a kicker, use the BIP = BIP + 1 statement, then kick a ball into the playfield.


Using a kicker, create a ball, add the BIP = BIP + 1 statement then kick the ball into the playfield or area you wish to add the ball.


Not much else really to do unless you're fiddling with tons of array statements.



sorry, I thought it was working
but no. my plunger is timed at 3s, which is why I thought the plunger was neutralized.....so I still have the problem of ball creation during add-a-ball...
 
thank you for your patience
I'm going to try.


on my template , i have balls and ball. balls :number of balls per game and ball : number of ball on the playfield.


so ball = BIP (for you) ?
 
. Of course you can use the plunger .


oh no!!!
my plunger, creates only the balls of the game (3 or 5) of start.
it's already complicated enough like this....


I will use the same notation (bip),otherwise it creates confusion.
at first, I thought that bip was a pre-coded script. ready to use.
 
Last edited:
I use the DIM array statement of BIP for "balls in play" and BALLS for balls during play. I also use other statements if I have one or more balls that are "live" on the play field to keep track of each and every ball during a game, I use another DIM array statement such as BL to keep track of those after a game and when they drain.


Yes, this can be confusing and trust me sometimes I get over my head with them because if you don't keep track of them you'll know it. Sorry for the confusion.


DIM array statements can be used anyway you wish by using a non command under the visual basic script. You can use whatever you want actually, I just find using BIP a bit easier to deal with. Sorry about that, I thought you may have understood me but it's just using DIM array statements that can make the entire process of table making much easier and you can keep track of everything all at once.



oh no!!!
my plunger, creates only the balls of the game (3 or 5) of start.
it's already complicated enough like this....


I will use the same notation (bip),otherwise it creates confusion.
at first, I thought that bip was a pre-coded script. ready to use.
 
Glad you figured it out. It can take time to juggle all the DIM arrays you have but in the long run it can really solve many problems when you're keeping track of things. :)
 
en résumé drain_hit() : bip=bip-1
kicker.createball : bib=bip=bip+1
kicker.destroyball : bip=bip-1


if kicker1_destroyball : kicker2.createball ?? çà annule le bip ou bien il faut mettre bip=bip-1:bip=bip+1 ??!!!


j'ai posté une table vpx houdini , j'ai suivi la procédure et pourtant le pinball s'emballe , tu pourrais jeter un œil , pour voir ce qu'il ne va pas ?


trad. google :
I posted a vpx houdini table, I followed the procedure and yet the pinball is racing, you could take a look, to see what's wrong?


would you like to be my table coder (script basic with 3/4 multiball) because modern table
 
Last edited:
First off, I can see via the screenshot you have BIP = - 1 so somewhere in your code you are going below the normal zero (or 0).


In your code somewhere you're counting BIP = BIP - 1 TWICE OR you're missing this code in the starting point of your table during initialization. I've had this problem a LOT and it's not fun to find the issue, but I'll download the table and check it out. Who knows, it may be just a basic line or added piece of code that could be been over missed. I've done this. I usually only use BIP when the ball is kicked out to the plunger and nowhere else unless you have multiball which you do have. Your BIP would not go above the amount of balls on the play field that are moving and live.


As for a coder, I'm really not great at it at all so I keep to the flipperless tables that require very little amounts of it but I can always look at your tables. Not an issue BUT - I can talk with a few folks in the VP author world who would more than likely would be your table coder. Let me know.


Like I said, I'll look at your script and see what is up.


As for the ball "racing" I have no idea what that is but if you could explain a little more in detail I will look into it.
 
Last edited:
euh best traduction google maybe pinball is racing ==> the pinball get carried away ))


and ok if you can talk with a few folks in the VP author world who would more than likely would be your table coder


bip -1 is magic , the magic houdini ))
 
Sorry I have not responded as I'm on a bunch of pills for my health, but I TRIED to get this table to run but was bombarded with numerous "scripting" errors. I don't use VPM if this table uses it and I never have. If it does, please let me know. I can't even get the table to load so I must be doing something really wrong on my end.
 
Forum activity
Help Users
You can interact with the ChatGPT Bot in any Chat Room and there is a dedicated room. The command is /ai followed by a space and then your ? or inquiry.
ie: /ai What is a EM Pinball Machine?
  • No one is chatting at the moment.
      Mibs Mibs: Itchigo has posted a new reply in the thread "Sounds library".
      Back
      Top