Jump to content



Photo
- - - - -

_Hit() Events


  • Please log in to reply
3 replies to this topic

#1 JayJay96

JayJay96

    Enthusiast

  • Members
  • PipPipPip
  • 132 posts
  • Location:Ontario, Canada

  • Flag: Canada

  • Favorite Pinball: WipeOut

Posted 11 September 2010 - 05:42 PM

I am still quite a noob at this game but have made lots of progress since ive first started. I was wondering if there was a way to change an event each time a trigger has been hit. Example:

Trigger1_Hit()
Light2.FlashForMs 1000, 100, BulbOff

Then when the ball hits trigger1 a second time i want it to perform a different action , maybe as many times up to 5. Then after 5, start over again back to the first action? Is this possible?

Edited by JayJay96, 11 September 2010 - 05:45 PM.


#2 Mystman

Mystman

    Enthusiast

  • Members
  • PipPipPip
  • 93 posts

  • Flag: Netherlands

  • Favorite Pinball: Sonic 2

Posted 11 September 2010 - 06:02 PM

Hi. Have you read the excellent FP scripting guides?

http://www.vpforums....cript_guide.htm

http://www.vpforums....s/BigDraco.html

What you want to do:

1. Declare a global variable (something like "Target1TimesHit")

2. In the ResetForNewGame(), or ResetForNewPlayerBall() sub, initialize your variable to 0.

3. In the Target1_Hit sub, increase the variable by 1, and reset to 0 once it reaches 5 by using the "mod" operator (google for "mod vbs" to see how it works).

4. After that, in the Target1_Hit sub, create a "select case" that does something based on how much your variable is.

so in script..

CODE
dim Target1TimesHit

sub ResetForNewGame()
      Target1TimesHit = 0
end sub

sub Target1_Hit()
      Target1TimesHit = (Target1TimesHit+1) mod 5

      select case Target1TimesHit
      case 0
            do some stuff
      case 1
            do some other stuff
      case 2
           doing more stuff
      case 3
            stuff
      case 4
            you guessed it..
      case 5
            this one will actually never be selected, because 4 is the highest result you'll get when you do x mod 5.
      end select
end sub





#3 faralos

faralos

    VPF Veteran

  • Members
  • PipPipPipPipPipPip
  • 7,838 posts
  • Location:Eastern Pa,USA

  • Flag: United States of America

  • Favorite Pinball: Flash (Williams) 1979, Flash2 Updated




  • Trophies:

Posted 11 September 2010 - 09:18 PM

say could you also write that in VP9? I would like to have that same thing happen in vp9 but am unsure how to go about it.
"Don’t let the noise of others’ opinions drown out your own inner voice.
And most important, have the courage to follow your heart and intuition.”
----Steve Jobs


#4 Mystman

Mystman

    Enthusiast

  • Members
  • PipPipPip
  • 93 posts

  • Flag: Netherlands

  • Favorite Pinball: Sonic 2

Posted 12 September 2010 - 10:01 AM

I'm not familiar with VP, but I believe it also uses Visual Basic Script just like FP. So the mod operator, global variables, and select case should all work. Implementing them in the VP equivalents of the _Hit() and ResetForNewGame() subs should be easy enough I think.

Edited by Mystman, 12 September 2010 - 10:02 AM.