ユーザ用ツール

サイト用ツール


サイドバー

バーチャルキャスト

チュートリアル

カスタマイズ

モデル作成

その他

English

en_model:vci_creation:how_to_create_and_add_vci_script

Creation of VCI script

The VCI script is implemented with Lua language.
Here, we will be using the VCI we created in Creation of VCI to write and add a script into it.
You can use debug feature while running it in Virtual Cast.


Create main.lua

The “EmbeddedScriptWorkspace” folder is a path, which is going to be the root of the script. This is located in

C:/Users/__USER_NAME__/AppData/LocalLow/infiniteloop Co,Ltd/VirtualCast/EmbeddedScriptWorkspace
  • In case the AppData folder is hidden, in folder options, tick [View] > [Hidden file].
  • Open “EmbeddedScriptWorkspace” in VSCode ([Open Folder…])
  • Create a file `main.lua` in the VCI folder of the item we are creating (this is created when you load a VCI in Virtual Cast).
  • We recommend copying the file from EmbeddedScriptWorkspace/template.lua

How to use the console

Debug setting for a VCI item


In config.json, add the following items

  "embedded_script": {
    "websocket_console_port": 8080,
    "vr_debug": true
  },

So the entire config.json would look like this

{
   "niconico":
   {
   },

   "embedded_script": {
      "websocket_console_port": 8080,
      "vr_debug": true
   }
}
  • websocket_console_port
    • A TCP Port number that hosts WebSocket Logger for VCI-Embedded-Script. It will be displayed when this value is larger than 0.
  • vr_debug.description
    • Whether or not to show debug information in VR

WebSocket Console


  • You can see VCI item debug information by accessing localhost:8080 while Virtual Cast is running.

In-VR console


In general
  • A debug console is spawned in Virtual Cast
  • The console display is only visible to you and not being synced with other players
  • As with other items, you can grab, move and stretch it with both hands
LuaSysmteConsole
  • System messages for VCI scripts are displayed
  • When threads stopped or became unresponsive
SharedVariableConsole
  • When you use shared variables, the content is shown as json.
ItemConsole
  • A console for individual items
  • Generated at the time of item spawn, and will be destroyed together with the item
  • You can see the following by pressing grip button while holding it
    • Console
    • List of SubItems
    • List of Materials
    • List of Animations
    • List of Audios
  • Writing below code will display “VCISCript” on the console
main.lua
print("VCIScript")

Test an example script in Virtual Cast

1. Copy and paste the below code into [main.lua] inside the VCI folder.

main.lua
GrabCount = 0
function onGrab(target)
    GrabCount = GrabCount + 1
    print("Grab : "..GrabCount)
    print(target)
end

2. In Virtual Cast, grab the VCI object. If you see log entries on the console that count the number of times you grabbed the object, it’s a success.
Note: this is just a quick sample script for this tutorial.
Note: For basic tutorial of VCI script, see Tutorial.
Note: For detailed information on VCI script, see VCI Script Reference.

Embedding the VCI script

1. Open the project you used to create the VCI item, and load the Scene.
2. In [VCIObject], change [Scripts] > [Size] to 1 and press enter.
3. The inspector expands. Type the following.
 [Name]: [main.lua]
 [Source]: [Paste the script you created]
4. Save the Scene and once again export the VCI.
 On the menu bar, select [VRM] > [UniVCI-x.xx] > [Export], and save it.
5. Overwrite the item on THE SEED ONLINE with the new VCI you just exported. Now you have made a VCI with a script enabled.

Index

en_model/vci_creation/how_to_create_and_add_vci_script.txt · 最終更新: 2019/03/09 13:20 by Ramen

ページ用ツール