PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Roy on 15 October, 2003, 22:43:56

Title: Multi Timebot
Post by: Roy on 15 October, 2003, 22:43:56
Wondering if anyone can translate this cool script by Gadget into a LUA one. And that it shows all the different times on every hour in main :)  if this can be done it would be great, i think many would love such a script.

Roy


'Time&Date by Gadget
Dim sBotName,bShowTimeOnLogon,iShowTimeOnMainInterval,iTicker

Sub Main
  sBotName="Timekeeper"
  bShowTimeOnLogon=True
  iShowTimeOnMainInterval=0 '<- In minutes, 0=Disabled
  tmrScriptTimer.Interval = 60000
  tmrScriptTimer.Enabled = True
  iTicker=iShowTimeOnMainInterval
End Sub

Sub NewUserConnected(curUser)
  curUser.PrivateMessage cStr(sBotName),CStr("Welcome to "+frmHub.txtName+vbCrLf+DZ+" "+TZ(True)+vbCrLf+"If you need the time just type +time in main and if you need date just type +date in main")
End Sub

Sub OpConnected(curUser)
  Call NewUserConnected(curUser)
End Sub

Sub tmrScriptTimer_Timer()
  iTicker=iTicker+1
  If iTicker>iShowTimeOnMainInterval Then
    iTicker=0
    If iShowTimeOnMainInterval>0 Then
      colUsers.SendChatToAll cStr(sBotName),CStr(TZ(False))
    End If
  End If
End Sub

Sub DataArival(curUser,sCurData)
  If Left(sCurData,1)="<" Then
    If LCase(Right(sCurData,7))="> +time" Then
      colUsers.SendChatToAll cStr(sBotName),CStr(TZ(True))
    End If
    If LCase(Right(sCurData,7))="> +date" Then
      colUsers.SendChatToAll cStr(sBotName),CStr(DZ)
    End If
  End If
End Sub

Function TZ(bLong)
  Set wshShell=CreateObject("WScript.Shell")
  iBias=wshShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias")
  sTZ=CStr(Abs(iBias)Mod 60)
  If Len(sTZ)<2 Then sTZ=CStr(Int(Abs(iBias)/60))+":0"+sTZ Else sTZ=CStr(Int(Abs(iBias)/60))+":"+sTZ
  If iBias>0 Then sTZ="-"+sTZ Else sTZ="+"+sTZ
  TZ=TZ+"Time in hub is now "+FormatDateTime(Now,vbShortTime)+" ("+sTZ+" GMT)."
  If bLong Then
    TZ=TZ+vbCrLF+"Time is now "
    TZ=TZ+FormatDateTime(DateAdd("n",iBias+12*60,Now),vbShortTime)+" in Fiji, "
    TZ=TZ+FormatDateTime(DateAdd("n",iBias+9*60,Now),vbShortTime)+" in Tokyo, "
    TZ=TZ+FormatDateTime(DateAdd("n",iBias+10*60,Now),vbShortTime)+" in Sydney, "
    TZ=TZ+FormatDateTime(DateAdd("n",iBias+4*60,Now),vbShortTime)+" in Moscow, "
    TZ=TZ+FormatDateTime(DateAdd("n",iBias+1*60,Now),vbShortTime)+" in London, "
    TZ=TZ+FormatDateTime(DateAdd("n",iBias-5*60,Now),vbShortTime)+" in Jamaica, "
    TZ=TZ+FormatDateTime(DateAdd("n",iBias-6*60,Now),vbShortTime)+" in Middle America and "
    TZ=TZ+FormatDateTime(DateAdd("n",iBias+2*60,Now),vbShortTime)+" in Oslo."
  End If
End Function

Function DZ
  DZ="Today is "+FormatDateTime(Now,vbLongDate)+"."
End Function
Title:
Post by: pHaTTy on 16 October, 2003, 00:25:19
can you edit it and put code here
like that plzz otherwise i cant read it properly, confiusing :)



-phatty
Title:
Post by: [NL]Pur on 18 October, 2003, 12:30:47
phatty is script won't run in ptokax since it's vb ;)
Title:
Post by: pHaTTy on 18 October, 2003, 20:30:19
i know i just like to read the code ;)