Jump to content



Photo
- - - - -

Do you know how to use Collections & EVAL?

script

  • Please log in to reply
No replies to this topic

#1 samballuga2

samballuga2

    Enthusiast

  • Members
  • PipPipPip
  • 51 posts
  • Location:Barcelona

  • Flag: Spain

  • Favorite Pinball: Andromeda.1.0

  • PS3 Gamer Tag: samballuga2
  • 360 Gamer Tag: samballuga2

Posted 14 December 2020 - 11:18 AM

Do you know how to use Collections & EVAL?


Previously:
We have, for example, 50 Walls, Flahers or any object that supports properties / methods at runtime.
We want each time one of them is hit to produce a series of performances.
Normally, we would build 50 subroutines of type _HIT. One for each WALL ...
Very bulky. Also, if we want to add a performance later, we must play all 50 routines.



We will create a collection with the desired elements. Name: C1.
Elements:

WALL1
WALL2
WALL3

...
WALL50

The HIT Event will be accompanied by n, which indicates the ordinal number of the trigger object counting from 0.
If the ball hits WALL1, n will be worth 0. In the example we will always add 1 to n.

(Another possibility would be to call the objects also numbering from zero ... WALL0, WALL1, ETC ...)

SUB C1_HIT (n)
   EVAL ("WALL" & n + 1) .Isdropped = True
   TIMER1.ENABLED = TRUE
   PlaySound "SOME_SOUND" & n (If each WALL has its own sound ... etc ...)
    ADDSCORE (1000)
    IF EVAL ("WALL" & n) .XXX = ??? THEN '
    XXX'X
    XXX
    END IF
End sub


We have reduced the number of font lines in a brutal way.

Greetings and Happy Holidays !!!




 







Also tagged with one or more of these keywords: script