• Log in or sign up for an account here: https://www.sythe.org/login

World Parser - Gives you all info for the worlds.

Flaming Idiots

Active Member

Visual Basic Programmers
Joined
Dec 22, 2005
Sythe Gold
0
Messages
235
Location
Alberta Canada
Two Factor Authentication User
This is a Regular Expression based world parser I made. This code is shorter than using case statements, gives you more information, and is always up to date.

Usage:
Code:
Private Sub Button1_Click()
    Worlds.Update
    Dim World As WorldData
    World = Worlds.World(2)
    
    Me.Text1.Text = World.Number
    Me.Text2.Text = World.Players
    Me.Text3.Text = World.Activity
End Sub
Code:
Notes:
  1. You will need to add the reference Microsoft VBScript Regular Expressions 5.5 to the project for this code to work.
  2. Place this code in a module named Worlds
Code:
Option Explicit

'' Fields

Private WorldArr() As WorldData
Private Init As Boolean

'' Constants

Private Const WorldsUrl = "http://www.runescape.com/slj.ws?lores.x=1&plugin=0&order=WMLP"
Private Const WorldsPattern = "\((\d+),(\d+),\d+,""([a-zA-Z0-9 \-]+)"",""([a-zA-Z0-9]+)"",(\d+),(\d+)\)"

'' Types

Public Type WorldData
    Number As Integer
    Players As Integer
    Members As Boolean
    Location As Integer
    Prefix As String
    Theme As String
    Exists As Boolean
End Type

'' Methods

Public Sub Update()
    Dim tInet As Object
    Set tInet = CreateObject("InetCtls.Inet")
    Dim Html As String
    Html = tInet.OpenURL(WorldsUrl)
    Dim X As New RegExp
    X.Pattern = WorldsPattern
    X.Global = True
    Dim Matches As MatchCollection
    Set Matches = X.Execute(Html)
    ReDim WorldArr(1 To Matches.Count)
    Dim Match As Match
    Dim Count As Integer
    Count = 1
    For Each Match In Matches
        Dim SM As SubMatches
        Set SM = Match.SubMatches
        Dim W As WorldData
        With W
            .Number = Val(SM.Item(0))
            .Members = Val(SM.Item(1)) = 1
            .Theme = SM.Item(2)
            .Prefix = SM.Item(3)
            .Players = Val(SM.Item(4))
            .Location = Val(SM.Item(5))
            .Exists = True
        End With
        WorldArr(Count) = W
        Count = Count + 1
    Next
    Init = True
    DoEvents
End Sub
Public Property Get World(WorldNo As Integer) As WorldData
    Dim X As Integer
    If Init = False Then Update
    For X = LBound(WorldArr) To UBound(WorldArr)
        Dim W As WorldData
        W = WorldArr(X)
        If W.Number = WorldNo Then
            World = W
            Exit Property
        End If
    Next
    World.Exists = False
End Property
Public Property Get AllWorlds() As WorldData()
    If Init = False Then Update
    AllWorlds = WorldArr
End Property
 
This is a Regular Expression based world parser I made. This code is shorter than using case statements, gives you more information, and is always up to date.

Yeah... until Jagex makes more damn changes. :P
But it might be better to either save the location as the string itself, or make another function to load the location list into an array so that you can change the integer to the string. Otherwise you're world list updates, but your locations have to be manually changed when needed.
Thanks for the code! I never used regex in VB before, didn't know how easy it was. :D
 
Quick question.
Do you have to add a reference to Microsoft VBScript Regular Expressions 5.5, so you can use regexp in vb6?
Yeah, unless you write your own class or something...
 
Back
Top