question script

fastdraw

Inserted Coin
Joined
Dec 16, 2015
Messages
226
Reaction score
159
Points
56
Favorite Pinball Machine
afm mm cv
are we allowed to do this?

it works ?

and
exit sub

we use it for what circumstance

Code:
'***********************************************
'****************TARGETS************************
'***********************************************

sub target1_hit()
    t1=1
    light1.state=1
    addscore(1000)
    if t1+t2+t3+t4+t5=5 then
        multiball
    end if
end sub

sub target2_hit()
    t2=1
    light2.state=1
    addscore(1000)
    if t1+t2+t3+t4+t5=5 then
        multiball
    end if
end sub

sub target3_hit()
    t3=1
    light3.state=1
    addscore(1000)
    if t1+t2+t3+t4+t5=5 then
        multiball
    end if
end sub

sub target4_hit()
    t4=1
    light4.state=1
    addscore(1000)
    if t1+t2+t3+t4+t5=5 then
        multiball
    end if
end sub

sub target5_hit()
    t5=1
    light5.state=1
    addscore(1000)
    if t1+t2+t3+t4+t5=5 then
        multiball
    end if
end sub

    
sub multiball
    kicker4.createball
    kicker4.solenoidpulse
    kicker3.createball
    kicker3.solenoidpulse
    ballsonplayfield=ballsonplayfield+2
    t1=0:t2=0:t3=0:t4=0:t5=0
end sub
 
Based on the manual my guess is that the script will give you a warning on lightX.state=1 and fail after load because the manual specifically specifies .state can be only bulbON, bulbOFF and bulbBLINK.

Assuming that by "=1" means "=bulbON" you just have to change it.

Personally I also avoid the use of more variables than necessary (t1,t2... t5) myself and go to the old fashion way. And sincethis is recurring so I'd add a new sub() since I don't think performance wise is relevant in this case.

Something like this:

Code:
Dim MBLights : MBLights=0
Sub CheckMBLights()
If (light1.state=bulbON and light2.state=bulbON and light3.state=bulbON _
    and light4.state=bulbON and light5.state=bulON) then
    MBLights=1

end if

And then change targetX_hit() to:
Code:
sub target5_hit()
    light5.state=bulbON
    addscore(1000)
    CheckMBLights
    if MBLights=1 then
        multiball
    end if
end sub


But i'm not the best coder here I assure you so hopefully others can do better and / or confirm the .state conditions.
 
For me:
Code:
Dim x
Sub Target1_Hit(): Multiball 1: End Sub
Sub Target2_Hit(): Multiball 2: End Sub
Sub Target3_Hit(): Multiball 3: End Sub
Sub Target4_Hit(): Multiball 4: End Sub
Sub Target5_Hit(): Multiball 5: End Sub
Sub Multiball(Num)
     If fp_Tilted = True Then Exit Sub
     Eval("Light" &Num).State = BulbOn
     AddScore(1000)
     For x = 1 To 5
          If Eval("Light" &x).State = BulbOff Then Exit Sub
     Next
     kicker4.CreateBall
     kicker4.SolenoidPulse
     kicker3.CreateBall
     kicker3.SsolenoidPulse
     BallsOnPlayfield=BallsOnPlayfield +2
     For x = 1 To 5: Eval("Light" &Num).State = BulbOff: Next
End Sub
 
eval is a very powerful instruction that I should use more of.
class too ... and I'm sure it must have some more...
@AnonTet

.state On =1 , .state off=0 .state blink=2....it's the same, shortened typing on the keyboard ; and to have a more airy reading.

generally, we should not rely on the state of lights, but only on variables.
so that allows you to do something else with, an animation by example.
 
Last edited:
And I learned a new thing today. Thanks for the explanation.
 
I am not a script master like @popotte but the "eval" command can cause problems when it runs in the script (at least when it runs with a ball in play). Windows Defender antivirus (which ships with all version of Windows) can hog all the system resources when it scans the script with the "eval" command when it runs. Of course it never finds any viruses but hogging the system resources often results in stuttering or low frame rate on FP. The same is true for the "execute" command. Your better off expanding the script out to the long version and avoid using the "eval" and "execute" commands when a ball is in play. I have changed it on many tables. You can avoid the problem by turning Windows Defender off but it is not recommended because you wouldn't have virus protection then. I have tried turning the scanner off for FP on Windows Defender but it doesn't affect real time protection which is the culprit here. If you are turning lights on or off when no ball is in play, you should be OK.
 
Last edited:
George, it's right just if you use a lot of Eval or Execute. I never had a problem with my tables and I use (and like) Eval.
 
I suppose you are right but EM tables don't use as much memory as many solid state ones so problems may be less likely. Jurassic Park's "shake it" routine that simulates earthquakes caused significant stutter that made the game unplayable. It used only a few execute commands but they repeated continually during the earthquake sequence.

I had a stuttering problem on Creatures from the Black Lagoon. It used many "execute" and "eval" commands. I went through the script and converted all the "execute" commands and still had the problem. So I converted all the "eval" commands and finally eliminated the problem. I guess I didn't need to convert all the execute commands. Personally, I can't tell by looking at the script whether these commands will cause a problem or not. To my thinking, you are better off not using them unless you have no choice but a more skilled coder like yourself might be able to determine which places in the script would cause a problem.
 
Forum activity
Help Users
You can interact with the ChatGPT Bot in any Chat Room and there is a dedicated room. The command is /ai followed by a space and then your ? or inquiry.
ie: /ai What is a EM Pinball Machine?
  • No one is chatting at the moment.
      Mibs Mibs: Poor Man's Pinball Podcast has posted a new reply in the thread "Poor Man's Pinball Podcast".
      Back
      Top