• Google Translate to French or Other Languages Click on the link and a new tab will open with this page translated into French.
    Click on the "To:" pull down option to select a different language. Users will not be logged in on the new Google tab.

Add time to a timer running

AnonTet

Pinball Hall of Famer
Site Supporters
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
 

Gin

Pinball Wizard
Site Supporters
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 ?
 

AnonTet

Pinball Hall of Famer
Site Supporters
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
 

Gin

Pinball Wizard
Site Supporters
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: 25

AnonTet

Pinball Hall of Famer
Site Supporters
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.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
    There are no messages in the chat. Be the first one to say Hi!
    Top