Advertisement
Guest User

faster sols core script mod

a guest
Nov 5th, 2017
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dim strtt   'debug string
  2.  
  3. TimeSneaker 'find an unused object and use it's timer for fast solenoid updates
  4. Sub TimeSneaker()
  5.     dim ii
  6.     for each ii in getelements
  7.         'debug.print TypeName(ii)
  8.         if typename(ii) = "Trigger" then                            'Find a 'trigger' object
  9.              On Error Resume Next
  10.              If Not Isobject(GetRef(ii.name & "_Timer")) Or Err Then 'if the object's timer isn't already in use... (case-safe I think)
  11.                 Err.Clear
  12.                 ii.TimerInterval = 1 : ii.TimerEnabled = 1
  13.                 executeglobal "Sub " & ii.name & "_" & "Timer" & " : " & "UpdateChgSol" & " : End Sub"
  14.                 strtt = "Sub " & ii.name & "_" & "Timer" & " : " & "UpdateChgSol" & " : End Sub"    'debug
  15.                 exit sub
  16.             end if
  17.         end if
  18.     Next
  19. End Sub
  20.  
  21.  
  22. Sub UpdateChgSol()  'copied from main loop. Comment out the chgsol stuff in main loop.
  23.     dim ChgSol
  24.     if UseSolenoids then ChgSol = Controller.ChangedSolenoids
  25.     dim tmp, idx, nsol, solon, ii
  26.     If Not IsEmpty(ChgSol) Then
  27.         For ii = 0 To UBound(ChgSol)
  28.             nsol = ChgSol(ii, 0)
  29.             tmp = SolCallback(nsol)
  30.             solon = ChgSol(ii, 1)
  31.             If solon > 1 Then solon = 1
  32.             'SolMe(chgsol)
  33.             If UseModSol Then
  34.                 If solon <> SolPrevState(nsol) Then
  35.                     SolPrevState(nsol) = solon
  36.                     If tmp <> "" Then Execute tmp & vpmTrueFalse(solon+1)
  37.                 End If
  38.                 tmp = SolModCallback(nsol)
  39.                 If tmp <> "" Then Execute tmp & " " & ChgSol(ii, 1)
  40.             Else
  41.                 If tmp <> "" Then Execute tmp & vpmTrueFalse(solon+1)
  42.             End If
  43.         Next
  44.     End If
  45. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement