Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Dialogue_json_from_XL()
- 'This is an example macro for Excel to be able to parse a Dialogue.diag.json file excel sheet for more complex dialogue in a minecraft
- 'education edition or Bedrock edition NPC. This file would be put in a dialogue folder in your beha'vior pack.
- 'The spreadsheet I used for this has a separate row for each scene_tag. The spreadsheet has 10 columns, not all used in this.
- 'column 1 = scene_tag. Column 2 = npc_name, Column 3 = text, (I did not use any On open or On close commands in my set up.)
- 'Column 4 = Buttons (not needed but the following are all buttons),
- 'Column 5 = name, Column 6 = commands, Column 7 = name, Column 8 = commands, Column 9 = name, Column 10 = commands
- Dim strFile_Path As String
- strFile_Path = "C:\Users\exampleusername\Desktop\example.diag.json" 'fill in your path and file name between the "
- Open strFile_Path For Output As #1
- Dim CurrentRow As Integer
- Dim MyCh
- MyCh = Chr(9) 'MyCh stands for My Character and Chr(9) is Tab
- Print #1, "{"
- Print #1, MyCh & """format_version""" & ": " & """1.14""" & ","
- Print #1, MyCh & """minecraft:npc_dialogue""" & ": {"
- Print #1, MyCh & MyCh & """scenes""" & ": ["
- For CurrentRow = 2 To 576 'my spreadsheet has a header row at 1 so we start at 2 and goes to row 577, we will do the last row below.
- 'Edit actual numbers to suite your spreadsheet. Also Below, I have three buttons per dialogue, they are the name and commands lines.
- 'my spreadsheet has 10 columns Cells(CurrentRow, 1) means current row Column 1
- Print #1, MyCh & MyCh & MyCh & "{"
- Print #1, MyCh & MyCh & MyCh & MyCh & """scene_tag""" & ": " & """" & Cells(CurrentRow, 1) & """" & ","
- Print #1, MyCh & MyCh & MyCh & MyCh & """npc_name""" & ": " & """" & Cells(CurrentRow, 2) & """" & ","
- Print #1, MyCh & MyCh & MyCh & MyCh & """text""" & ": " & """" & Cells(CurrentRow, 3) & """" & ","
- Print #1, MyCh & MyCh & MyCh & MyCh & """buttons""" & ": ["
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & "{"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & MyCh & """name""" & ": " & """" & Cells(CurrentRow, 5) & """" & ","
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & MyCh & """commands""" & ": [" & """" & Cells(CurrentRow, 6) & """" & "]"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & "},"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & "{"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & MyCh & """name""" & ": " & """" & Cells(CurrentRow, 7) & """" & ","
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & MyCh & """commands""" & ": [" & """" & Cells(CurrentRow, 8) & """" & "]"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & "},"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & "{"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & MyCh & """name""" & ": " & """" & Cells(CurrentRow, 9) & """" & ","
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & MyCh & """commands""" & ": [" & """" & Cells(CurrentRow, 10) & """" & "]"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & "}"
- Print #1, MyCh & MyCh & MyCh & MyCh & "]"
- Print #1, MyCh & MyCh & MyCh & "},"
- Next CurrentRow
- For CurrentRow = 577 To 577 'Edit number for your file, last row separately to avoid the extra comma and then close all the brackets.
- Print #1, MyCh & MyCh & MyCh & "{"
- Print #1, MyCh & MyCh & MyCh & MyCh & """scene_tag""" & ": " & """" & Cells(CurrentRow, 1) & """" & ","
- Print #1, MyCh & MyCh & MyCh & MyCh & """npc_name""" & ": " & """" & Cells(CurrentRow, 2) & """" & ","
- Print #1, MyCh & MyCh & MyCh & MyCh & """text""" & ": " & """" & Cells(CurrentRow, 3) & """" & ","
- Print #1, MyCh & MyCh & MyCh & MyCh & """buttons""" & ": ["
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & "{"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & MyCh & """name""" & ": " & """" & Cells(CurrentRow, 5) & """" & ","
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & MyCh & """commands""" & ": [" & """" & Cells(CurrentRow, 6) & """" & "]"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & "},"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & "{"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & MyCh & """name""" & ": " & """" & Cells(CurrentRow, 7) & """" & ","
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & MyCh & """commands""" & ": [" & """" & Cells(CurrentRow, 8) & """" & "]"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & "},"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & "{"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & MyCh & """name""" & ": " & """" & Cells(CurrentRow, 9) & """" & ","
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & MyCh & """commands""" & ": [" & """" & Cells(CurrentRow, 10) & """" & "]"
- Print #1, MyCh & MyCh & MyCh & MyCh & MyCh & "}"
- Print #1, MyCh & MyCh & MyCh & MyCh & "]"
- Print #1, MyCh & MyCh & MyCh & "}"
- Print #1, MyCh & MyCh & "]"
- Print #1, MyCh & "}"
- Print #1, "}"
- Next CurrentRow
- Close #1
- MsgBox ("Done")
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement