Jump to content



Photo
- - - - -

How to write it in the script ?


  • Please log in to reply
2 replies to this topic

#1 batch

batch

    VPFroggie

  • Members
  • PipPipPipPipPip
  • 2,177 posts
  • Location:Center of France

  • Flag: France

  • Favorite Pinball: Anyone if gaming and appearence are great

Posted Today, 11:57 AM

I start this topic because I'd like to learn how to write some simple things in a script.

 

The first one is how to link several lights to, for example, a target.

 

At the first hit, it would lit a light and add a score of xxx points.

 

At the second hit, it would lit another light and add a score of yyy points, and so on.

 

But it wouldn't be a bonus, just linked to this target.

 

Thanks in advance !


signature_24042026.jpg          DIRECT LINK TO MY TABLES http://www.vpforums....loads&mid=30858    

                                               LINK TO MY 204 BACKDROPS : Design Resources/ Main Resources/Table Templates/Table Resources/Backdrops for VPX Tables (DT 16/9)  2.0 


#2 kiwi

kiwi

    Pinball Fan

  • VIP
  • 2,671 posts

  • Flag: Italy

  • Favorite Pinball: Star Trek 25th Anniversary



Posted Today, 06:15 PM

You need to declare a variable to count how many hits the target receives, and use the "Cases" to manage lights, scores, and more.

You can use as many cases as you need.

 

Dim CounterHitsReceived
CounterHitsReceived = 0

Sub Target1_Hit
CounterHitsReceived = CounterHitsReceived + 1
CheckHits
End Sub
 
Sub CheckHits
    Select Case CounterHitsReceived
    Case 1:Light1.State = 1:Light2.State = 0:Light3.State = 0:AddScore 100
    Case 2:Light1.State = 0:Light2.State = 1:Light3.State = 0:AddScore 200
    Case 3:Light1.State = 0:Light2.State = 0:Light3.State = 1:AddScore 300
    End Select
End Sub

Then at the start or end of the game, start or end of the ball, end of the mission, 

in short, when needed, you'll need to reset the shot count variable to zero.

CounterHitsReceived = 0

If you want, you can also use the "If" method, it's perhaps less efficient and more confusing,

but if you only have a few cases, you can use it.

Dim CounterHitsReceived
CounterHitsReceived = 0

Sub Target1_Hit
CounterHitsReceived = CounterHitsReceived + 1
CheckHits
End Sub
 
Sub CheckHits

   If CounterHitsReceived = 1 Then
   AddScore 100
End If

   If CounterHitsReceived = 2 Then
   AddScore 200
End If

End Sub

 

 



#3 batch

batch

    VPFroggie

  • Members
  • PipPipPipPipPip
  • 2,177 posts
  • Location:Center of France

  • Flag: France

  • Favorite Pinball: Anyone if gaming and appearence are great

Posted Today, 06:51 PM

You need to declare a variable to count how many hits the target receives, and use the "Cases" to manage lights, scores, and more.

You can use as many cases as you need.

 

Dim CounterHitsReceived
CounterHitsReceived = 0

Sub Target1_Hit
CounterHitsReceived = CounterHitsReceived + 1
CheckHits
End Sub
 
Sub CheckHits
    Select Case CounterHitsReceived
    Case 1:Light1.State = 1:Light2.State = 0:Light3.State = 0:AddScore 100
    Case 2:Light1.State = 0:Light2.State = 1:Light3.State = 0:AddScore 200
    Case 3:Light1.State = 0:Light2.State = 0:Light3.State = 1:AddScore 300
    End Select
End Sub

Then at the start or end of the game, start or end of the ball, end of the mission, 

in short, when needed, you'll need to reset the shot count variable to zero.

CounterHitsReceived = 0

If you want, you can also use the "If" method, it's perhaps less efficient and more confusing,

but if you only have a few cases, you can use it.

Dim CounterHitsReceived
CounterHitsReceived = 0

Sub Target1_Hit
CounterHitsReceived = CounterHitsReceived + 1
CheckHits
End Sub
 
Sub CheckHits

   If CounterHitsReceived = 1 Then
   AddScore 100
End If

   If CounterHitsReceived = 2 Then
   AddScore 200
End If

End Sub

Thanks a lot, Kiwi, I'll try these methods.


signature_24042026.jpg          DIRECT LINK TO MY TABLES http://www.vpforums....loads&mid=30858    

                                               LINK TO MY 204 BACKDROPS : Design Resources/ Main Resources/Table Templates/Table Resources/Backdrops for VPX Tables (DT 16/9)  2.0