Jump to content



Photo
- - - - -

Delaying destroyball and createball


  • Please log in to reply
3 replies to this topic

#1 007

007

    Shaken, not stirred.

  • Platinum Supporter
  • 996 posts
  • Location:On Her Majesty's Secret Service

  • Flag: ---------

  • Favorite Pinball: EM:s

Posted 20 June 2010 - 09:18 AM

This is supposed to release three balls when a there are three captured balls, and a target is hit.
The problem is that the balls are created in a vertical upkicker, and it happens so fast that the balls collide and then gets stuck in the kicker.
I'm thinking that there should be a delay between each ball destroyed in captivity and released in the upkicker?

Can anyone help me out?
CODE
'************************************
Sub Kicker4_Hit()
if Multicount<>3 Then
Kicker4.Destroyball()
Else Kicker4.Destroyball
Kicker2.createball
Kicker2.SolenoidPulse()
Ballsonplayfield=Ballsonplayfield+1
End if
End Sub
'*************************************


One of us smells like a tart's handkerchief. Afraid it's me. Sorry about that, old boy.


#2 pinballwzd

pinballwzd

    Enthusiast

  • VIP
  • 176 posts
  • Location:Coquitlam, B.C. Canada

  • Flag: Canada

  • Favorite Pinball: Cyclone



Posted 20 June 2010 - 01:25 PM

Use a timer.. I am not a great coder but would something like this work ?

CODE
Dim checktimer
Dim x
Sub kicker_hit()
   enable the timer ( forget the syntex )
   checktimer
   solenoid pulse
   x=x+1
End Sub

Sub checktimer
  if timer.expired = True and x<4
     createball    
  else
  end if
end sub

- PINBALLWZD -

"It's not all about playing with balls..."

Tables: Alien Pinball Legacy (FP), Surgical R1 (FP), Pirahna - The Hunger(FP - WIP)

#3 Mystman

Mystman

    Enthusiast

  • Members
  • PipPipPip
  • 93 posts

  • Flag: Netherlands

  • Favorite Pinball: Sonic 2

Posted 21 June 2010 - 08:03 AM

Yup, you want to use a timer. Check the Table Components -> Timers article in the manual.

It's easiest to destroy/create a ball when the timer expires, and then restart the timer if there are still balls left. To track how many balls are left, you can use the .userdata variable that each timer has. (pinballwzd's script doesn't look like it will work, but I may be wrong)

CODE
sub Target_Hit()
    MultiTimer.Userdata = 3
    Multitimer.set true, 1000
end sub

sub MultiTimer_Expired()
    MultiTimer.Enabled = false
    MultiTimer.UserData = MultiTimer.Userdata - 1

    Kicker4.DestroyBall()
    Kicker2.CreateBall()
    Kicker2.SolenoidPulse()
    Ballsonplayfield=Ballsonplayfield+1

    if MultiTimer.UserData > 0 then
        MultiTimer.Set true, 1000
    end if
end sub

Edited by Mystman, 21 June 2010 - 08:09 AM.


#4 007

007

    Shaken, not stirred.

  • Platinum Supporter
  • 996 posts
  • Location:On Her Majesty's Secret Service

  • Flag: ---------

  • Favorite Pinball: EM:s

Posted 21 June 2010 - 07:15 PM

Thank you very much! I'm a complete noob when it comes to coding. This is going to require some serious thinking from my part, rolleyes.gif

Anyway, thanks for all the help.

One of us smells like a tart's handkerchief. Afraid it's me. Sorry about that, old boy.