Code/Example Add time to a timer running

Coding and examples for future Pinball and BAM

AnonTet

Pinball Master
Site Supporters
Joined
Jun 21, 2020
Messages
1,997
Solutions
1
Reaction score
1,151
Points
125
Favorite Pinball Machine
Indiana Jones
So, I'm trying to add a feature to another table I'm doing and while in ball bonus (special case) that lasts for 30s. The problem is that the award in this mode is more... ball bonus (or 30s more) so I need to add time on top of a running timer.

I came up with a solution and it is working but to be honest I wonder if FP has an undocumented feature for this., some vbscript trick I can use instead and simply add more time :)

This is just example code for a solution I came up with not actual table code. Quite convoluted for what I think should a simple task... any ideias or should I simply go with this and call it a day?

Code:
Sub trigger1_hit()
    if timer1.enabled = true then
        timer1.userdata = timer1.userdata + 1
        adddebugtext "userdata: " &timer1.userdata
     Else
        bulb1.state = bulbon
        timer1.set True, 5000
    End if
End Sub

Sub Timer1_expired()
    if timer1.Userdata > 0 then
        timer1.set True, 5000
        timer1.userdata = timer1.userdata - 1
        adddebugtext "userdata_expire: " &timer1.userdata
     Else
         timer1.enabled = false
         bulb1.state = bulboff
    end if
End Sub
 
Hi AnonTet,

I am no coder... but, what you have provided seems very simple (and not at all convoluted in my opinion). I suppose we shall have to wait to see what other approaches are identified by those who do code ?
 
Guess I didn't want to believe that is not possible to add time to a timer with a simple math operation! Something like
Code:
timer1.interval = timer1.interval + extra_time

Maybe I was missing something in the syntax (happens to me quite often).

Anyway, I think i'm going to use that and call it day. Thank you Gin
 
Hi AnonTet,

I have created an 'Example Timer' table using similar code to what you have quoted above (Line 22 [ ExampleModeTimer1.Interval = ExampleModeTimer1.Interval + 1000 ]), and it works; for me at least. I am attaching my 'very basic' attempt for you to see if it works for you (Run in Debug Mode (F9)); as commented earlier...
I am no coder
but I do like to try and learn.
 

Attachments

  • Example Timer.fpt
    6 KB · Views: 57
So timer.interval = timer.inter (insert math operation here) value does work. I wonder what the hell happened when I tried!

Well, you showed me it works so it was my fault. I'm glad I asked :)

PS: for someone not a coder I think you underestimate yourself a lot. I still have the code you did really quick for this same table I'm coming back to, finally.
 
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.
      Chat Bot Mibs Chat Bot Mibs: MMITG is our newest member. Welcome!
      Back
      Top