Jump to content



Photo
- - - - -

Using MOD to get every x hits


  • Please log in to reply
7 replies to this topic

#1 s1500

s1500

    Enthusiast

  • Members
  • PipPipPip
  • 396 posts
  • Location:twin cities

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

  • Favorite Pinball: Fun House

Posted 12 May 2012 - 03:17 PM

I've done this coding before, but it's not working in FP for some reason.

What I want to do is do something after every x amount of hits. Great for trash talk sounds, etc.

So something like this:


BumperHits = BumperHits +1

if (bumperhits mod 5) = 0 then
print "do something"
end if


I try this code out, and it's doing after every hit, not after every 5th one. Am I using modulus wrong?

#2 destruk

destruk

    VPF Veteran

  • VPF Staff
  • 6,338 posts
  • Location:Colorado Springs, CO

  • Flag: United States of America

  • Favorite Pinball: Ultrapin!



Posted 12 May 2012 - 03:40 PM

If bumperhits/5=INT(bumperhits/5) Then

That does the same thing as
if bumperhits mod 5 = 0
You're using it right, just perhaps some other code is taking over producing the result.

Bumperhits should be a global variable if you want it to retain its value outside the subroutine.

Depending on the placement and strength of your bumpers, 5 hits might be way too often to have something said in the game - to get repetitive/annoying. It might be better to randomize the speech play routine to play at 20/25/30 hits randomly rather than every 5 to avoid the speech clip getting cut off or overwritten with more sounds.

Edited by destruk, 12 May 2012 - 03:41 PM.

Build a fire, vipers love the heat.


#3 s1500

s1500

    Enthusiast

  • Members
  • PipPipPip
  • 396 posts
  • Location:twin cities

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

  • Favorite Pinball: Fun House

Posted 12 May 2012 - 05:02 PM

I might try your Int method, since I've tried the MOD thing(worked fine on VP IIRC) to no avail. The "bumperhits" variable I used is global, and definitely not decleared in the hit() sub.

I've learned to use AddDebug text quite frequently for stub code to see what the counts are, and the fact I'm getting it to activate after each 1 is weird. Even used parentheses to be more blunt in my evaluation.

Then there's the mystery issue where my drop targets NEVER hit. Ugh. Even looked at another table's code for drop targets, and it's basically the same. The targets just sit there.

And then there's the marquee message I send to when I hit a trigger, that's repeating itself several times for no real reason, intermittently.

First world pinball problems. smile.gif

#4 destruk

destruk

    VPF Veteran

  • VPF Staff
  • 6,338 posts
  • Location:Colorado Springs, CO

  • Flag: United States of America

  • Favorite Pinball: Ultrapin!



Posted 12 May 2012 - 06:03 PM

If you are getting multiple hits on objects in Future Pinball, make sure V-Sync is on in the video options.

Build a fire, vipers love the heat.


#5 s1500

s1500

    Enthusiast

  • Members
  • PipPipPip
  • 396 posts
  • Location:twin cities

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

  • Favorite Pinball: Fun House

Posted 13 May 2012 - 03:12 AM

QUOTE (destruk @ May 12 2012, 01:03 PM) <{POST_SNAPBACK}>
If you are getting multiple hits on objects in Future Pinball, make sure V-Sync is on in the video options.


Where's the vsync options? I'm looking at the video options and not seein' em.

#6 destruk

destruk

    VPF Veteran

  • VPF Staff
  • 6,338 posts
  • Location:Colorado Springs, CO

  • Flag: United States of America

  • Favorite Pinball: Ultrapin!



Posted 13 May 2012 - 08:05 AM

"Vertical Sync" on the left under the color depth circles 16bpp/32bpp - there is a checkbox there.

Build a fire, vipers love the heat.


#7 Sebek74

Sebek74

    Enthusiast

  • Members
  • PipPipPip
  • 114 posts
  • Location:Lodz, Poland

  • Flag: Poland

  • Favorite Pinball: Pinball Dreams: Ignition

Posted 07 July 2012 - 10:05 AM

s1500

Should work. Have you reset BumperHits to 0 at the beginning? I've tried this with success:

CODE
Dim BumperHits
BumperHits = 0


Sub Bumper1_Hit
    BumperHits = BumperHits +1
    if BumperHits mod 5 = 0 then
        MyDmd.Text = "[f1][yc][xc]" & CInt(BumperHits / 5) & " hits"
    end if
End Sub


Sebek74
Visit http://futurepinball.mm.com.pl/ for my tables download: Ignition, Beat-Box, Nightmare, Billion Dollar Gameshow, Wild West
http://futurepinball...om.pl/Gfx2DmdF/ for Gfx2DmdF font conversion
http://picasaweb.google.com/sebek74 - personal photo gallery

#8 s1500

s1500

    Enthusiast

  • Members
  • PipPipPip
  • 396 posts
  • Location:twin cities

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

  • Favorite Pinball: Fun House

Posted 07 July 2012 - 06:07 PM

I did some code changes, and whatever I did works now. It's doing a soundbyte/msg every x hits on the slingshots & pop-bumpers.