Advertisement
Guest User

Compile Brick Pack (BBG)

a guest
Jul 25th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  2.         'Find the path to the Blockland folder (in My Documents) by reading the registry
  3.        Dim blpath As String = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Personal", "error") + "\Blockland\Add-Ons" 'Find the path of the Blockland folder (the one in My Documents)
  4.        If blpath = "error\Blockland\Add-Ons" Then 'If the BBG can't find the path, just set ot tp C:\ and show an error
  5.            MsgBox("Blockland Brick Generator v1 couldn't find the location of your My Documents folder. For now, it'll just be placed in C:\.", 0, "Uh-Oh!")
  6.             blpath = "C:\"
  7.         End If
  8.         'Check if the brick pack already exists in the Add-Ons folder
  9.        If My.Computer.FileSystem.FileExists(blpath + "\Brick_" + TextBox1.Text + ".zip") Then
  10.             'If there is, ask the user if it should be overwritten
  11.            If MsgBox("You already have a brick pack named " + TextBox1.Text + "! Do you want to overwrite it?", 4, "Uh-Oh!") = 6 Then
  12.                 My.Computer.FileSystem.DeleteFile(blpath + "\Brick_" + TextBox1.Text + ".zip")
  13.                 'Have the user give info for description.txt and make sure there aren't any empty strings!
  14.                Dim name As String = InputBox("Here's the last part of making your brick pack: the description. First type your Blockland name in.", "Blockland Brick Generator v1")
  15.                 If name = "" Then
  16.                     MsgBox("Yeah, right. I seriously doubt that your name is blank.", 0, "Blockland Brick Generator v1")
  17.                 Else
  18.                     Dim description As String = InputBox("Now, type in a short description for your brick pack (for example: A few extra baseplates you can use)", "Blockland Brick Generator")
  19.                     If description = "" Then
  20.                         MsgBox("I'm going to have you try that again.", 0, "Blockland Brick Generator v1")
  21.                     Else
  22.                         Using zip As New Ionic.Zip.ZipFile 'Create a new object to put the files in a .zip folder
  23.                            My.Computer.FileSystem.WriteAllText("C:\server.cs", "//Created with Legojak's Blockland Brick Generator v1" + vbNewLine + vbNewLine, False)
  24.                             For i = 0 To ListBox1.Items.Count - 1 'Do for every item item in the listbox:
  25.                                'Create the server.cs file
  26.                                My.Computer.FileSystem.WriteAllText("C:\server.cs", "datablock fxDTSBrickData (brick" + Mid(Replace(ListBox1.Items(i), " ", ""), 1, InStr(1, Replace(ListBox1.Items(i), " ", ""), "/") - 1) + "Data)" + vbNewLine + "{" + vbNewLine + "   brickFile = " + Chr(34) + "./" + Mid(ListBox1.Items(i), 1, InStr(1, ListBox1.Items(i), "/") - 1) + ".blb" + Chr(34) + ";" + vbNewLine + "   category = " + Chr(34) + Mid(Mid(ListBox1.Items(i), InStr(1, ListBox1.Items(i), "/") + 1), 1, InStr(1, Mid(ListBox1.Items(i), InStr(1, ListBox1.Items(i), "/") + 1), "/") - 1) + Chr(34) + ";" + vbNewLine + "   subCategory = " + Chr(34) + Mid(ListBox1.Items(i), InStr(InStr(ListBox1.Items(i), "/") + 1, ListBox1.Items(i), "/") + 1, InStrRev(ListBox1.Items(i), "/") - InStr(InStr(ListBox1.Items(i), "/") + 1, ListBox1.Items(i), "/") - 1) + Chr(34) + ";" + vbNewLine + "   uiName = " + Chr(34) + Mid(ListBox1.Items(i), 1, InStr(1, ListBox1.Items(i), "/") - 1) + Chr(34) + ";" + vbNewLine + "}" + vbNewLine + vbNewLine, True)
  27.                                 'Create the BLB files
  28.                                My.Computer.FileSystem.WriteAllText("C:\" + Mid(ListBox1.Items(i), 1, InStr(1, ListBox1.Items(i), "/") - 1) + ".blb", Replace(Mid(ListBox1.Items(i), InStrRev(ListBox1.Items(i), "/") + 1), "x", " ") + vbNewLine + "BRICK", False)
  29.                                 'Add the BLB file to the .zip folder
  30.                                zip.AddFile("C:\" + Mid(ListBox1.Items(i), 1, InStr(1, ListBox1.Items(i), "/") - 1) + ".blb")
  31.                             Next
  32.                             'Create description.txt
  33.                            My.Computer.FileSystem.WriteAllText("C:\description.txt", "Title: " + TextBox1.Text + vbNewLine + "Author: " + name + vbNewLine + description, False)
  34.                             'Add description.txt to the .zip folder
  35.                            zip.AddFile("C:\description.txt")
  36.                             'Add server.cs to the .zip folder
  37.                            zip.AddFile("C:\server.cs")
  38.                             'Finish the .zip folder by saving it
  39.                            zip.Save(blpath + "\Brick_" + TextBox1.Text + ".zip")
  40.                             'Delete the server.cs that wasn't put into the .zip folder
  41.                            My.Computer.FileSystem.DeleteFile("C:\server.cs")
  42.                             'Delete the description.txt that wasn't put into the .zip folder
  43.                            My.Computer.FileSystem.DeleteFile("C:\description.txt")
  44.                             'Delete the leftover BLB files that aren't in the .zip folder
  45.                            For i = 0 To ListBox1.Items.Count - 1
  46.                                 My.Computer.FileSystem.DeleteFile("C:\" + Mid(ListBox1.Items(i), 1, InStr(1, ListBox1.Items(i), "/") - 1) + ".blb")
  47.                             Next
  48.                             MsgBox("Your brick pack is complete! If Blockland is open right now, you'll have to restart it. When you go start a game and click on Add-Ons, you'll see Brick_" + TextBox1.Text + " in there!")
  49.                         End Using
  50.                     End If
  51.                 End If
  52.             End If
  53.         Else
  54.             'Same thing down here
  55.            Dim name As String = InputBox("Here's the last part of making your brick pack: the description. First type your Blockland name in.", "Blockland Brick Generator v1")
  56.             If name = "" Then
  57.                 MsgBox("Yeah, right. I seriously doubt that your name is blank.", 0, "Blockland Brick Generator v1")
  58.             Else
  59.                 Dim description As String = InputBox("Now, type in a short description for your brick pack (for example: A few extra baseplates you can use)", "Blockland Brick Generator")
  60.                 If description = "" Then
  61.                     MsgBox("I'm going to have you try that again.", 0, "Blockland Brick Generator v1")
  62.                 Else
  63.                     Using zip As New Ionic.Zip.ZipFile
  64.                         My.Computer.FileSystem.WriteAllText("C:\server.cs", "//Created with Legojak's Blockland Brick Generator v1" + vbNewLine + vbNewLine, False)
  65.                         For i = 0 To ListBox1.Items.Count - 1
  66.                             My.Computer.FileSystem.WriteAllText("C:\server.cs", "datablock fxDTSBrickData (brick" + Mid(Replace(ListBox1.Items(i), " ", ""), 1, InStr(1, Replace(ListBox1.Items(i), " ", ""), "/") - 1) + "Data)" + vbNewLine + "{" + vbNewLine + "   brickFile = " + Chr(34) + "./" + Mid(ListBox1.Items(i), 1, InStr(1, ListBox1.Items(i), "/") - 1) + ".blb" + Chr(34) + ";" + vbNewLine + "   category = " + Chr(34) + Mid(Mid(ListBox1.Items(i), InStr(1, ListBox1.Items(i), "/") + 1), 1, InStr(1, Mid(ListBox1.Items(i), InStr(1, ListBox1.Items(i), "/") + 1), "/") - 1) + Chr(34) + ";" + vbNewLine + "   subCategory = " + Chr(34) + Mid(ListBox1.Items(i), InStr(InStr(ListBox1.Items(i), "/") + 1, ListBox1.Items(i), "/") + 1, InStrRev(ListBox1.Items(i), "/") - InStr(InStr(ListBox1.Items(i), "/") + 1, ListBox1.Items(i), "/") - 1) + Chr(34) + ";" + vbNewLine + "   uiName = " + Chr(34) + Mid(ListBox1.Items(i), 1, InStr(1, ListBox1.Items(i), "/") - 1) + Chr(34) + ";" + vbNewLine + "}" + vbNewLine + vbNewLine, True)
  67.                             My.Computer.FileSystem.WriteAllText("C:\" + Mid(ListBox1.Items(i), 1, InStr(1, ListBox1.Items(i), "/") - 1) + ".blb", Replace(Mid(ListBox1.Items(i), InStrRev(ListBox1.Items(i), "/") + 1), "x", " ") + vbNewLine + "BRICK", False)
  68.                             zip.AddFile("C:\" + Mid(ListBox1.Items(i), 1, InStr(1, ListBox1.Items(i), "/") - 1) + ".blb")
  69.                         Next
  70.                         My.Computer.FileSystem.WriteAllText("C:\description.txt", "Title: " + TextBox1.Text + vbNewLine + "Author: " + name + vbNewLine + description, False)
  71.                         zip.AddFile("C:\description.txt")
  72.                         zip.AddFile("C:\server.cs")
  73.                         zip.Save(blpath + "\Brick_" + TextBox1.Text + ".zip")
  74.                         My.Computer.FileSystem.DeleteFile("C:\server.cs")
  75.                         My.Computer.FileSystem.DeleteFile("C:\description.txt")
  76.                         For i = 0 To ListBox1.Items.Count - 1
  77.                             My.Computer.FileSystem.DeleteFile("C:\" + Mid(ListBox1.Items(i), 1, InStr(1, ListBox1.Items(i), "/") - 1) + ".blb")
  78.                         Next
  79.                         MsgBox("Your brick pack is complete! If Blockland is open right now, you'll have to restart it. When you go start a game and click on Add-Ons, you'll see Brick_" + TextBox1.Text + " in there!")
  80.                     End Using 'Lots of End Ifs:
  81.                End If
  82.             End If
  83.         End If
  84.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement